reordered add button to be consistent with author and publisher, then allowed author to be a drop-down with a + or - button as appropriate

This commit is contained in:
2020-11-22 12:02:01 +11:00
parent 60619c9d9c
commit fc12536a83
3 changed files with 40 additions and 13 deletions

View File

@@ -68,3 +68,6 @@ def author(id):
author_form = AuthorForm(request.values, obj=author)
message=""
return render_template("author.html", author=author, alert=alert, message=message, author_form=author_form)
def GetAuthors():
return Author.query.order_by('surname','firstnames').all()

View File

@@ -15,7 +15,7 @@ db = SQLAlchemy(app)
ma = Marshmallow(app)
Bootstrap(app)
from author import Author, AuthorForm, AuthorSchema
from author import Author, AuthorForm, AuthorSchema, GetAuthors
from publisher import Publisher, PublisherForm, PublisherSchema, GetPublishers
from genre import Genre, GenreForm, GenreSchema, GetGenres
from condition import Condition, ConditionForm, ConditionSchema, GetConditionById
@@ -173,9 +173,10 @@ def book(id):
book_form.owned.default = book.owned
book_form.rating.default = book.rating
book_form.process()
author_list = GetAuthors()
genre_list = GetGenres()
publisher_list = GetPublishers()
return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, genre_list=genre_list, publisher_list=publisher_list, covertype_list=covertypes )
return render_template("book.html", books=book_s, subs=sub_book, book_form=book_form, author_list=author_list, publisher_list=publisher_list, genre_list=genre_list )
@app.route("/", methods=["GET"])
def main_page():

View File

@@ -28,13 +28,13 @@
<div class="col-lg-10">
<div class="form-row input-group" style="margin-left:0px; margin-right:0px;">
<div class="input-group-prepend">
<button class="btn btn-outline-primary" type="button">
<a style="color:inherit" href="{{url_for(key, id=books[key][0].id)}}"><i class="far fa-edit"></i>
<button class="btn btn-outline-success" type="button">
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
</button>
</div>
<div class="input-group-prepend">
<button class="btn btn-outline-success" type="button">
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
<button class="btn btn-outline-primary" type="button">
<a style="color:inherit" href="{{url_for(key, id=books[key][0].id)}}"><i class="far fa-edit"></i></a>
</button>
</div>
<select class="form-control" id="publisher">
@@ -51,17 +51,40 @@
</div class="col-lg-10">
{% elif key == "author" %}
<div class="col-lg-10">
<div class="form-row" style="margin-left:0px; margin-right:0px;">
<div class="form-row" style="margin-left:0px;margin-right:0px">
{% set cnt = namespace(idx=0) %}
{% for objects in books[key] %}
<span class="form-control col" id="{{key}}[{{cnt.idx}}]">
<a href="{{url_for(key, id=books[key][cnt.idx].id)}}">
{{books.author[cnt.idx].surname + ", " + books.author[cnt.idx].firstnames}}
</a>
</span>
<div class="col input-group" style="padding-left:0px;padding-right:0px">
<div class="input-group-prepend">
{% if cnt.idx == 0 %}
<button class="btn btn-outline-success" type="button">
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
</button>
{% else %}
<button class="btn btn-outline-danger" type="button">
<a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-minus"></i></a>
</button>
{% endif %}
</div>
<div class="input-group-prepend">
<button class="btn btn-outline-primary" type="button">
<a style="color:inherit" href="{{url_for(key, id=books[key][cnt.idx].id)}}"><i class="far fa-edit"></i></a>
</button>
</div>
<select class="form-control" id="publisher">
{% for auth in author_list %}
{% set aname=auth.surname+", "+auth.firstnames %}
<option id="{{books.author[cnt.idx].id}}" value="{{books.author[cnt.idx].id}}"
{% if books.author[cnt.idx].id == auth.id %}
selected
{% endif %}
>{{aname}}</option>
{% endfor %}
</select>
</div class="col">
{% set cnt.idx = cnt.idx+1 %}
{% endfor %}
</div class="row">
</div class="form-row">
</div class="col-lg-10">
{% else %}
<div class="col-lg-10">