fixed up author and publisher drop-down lists to have right id/val, not sure if array subscripting the names will work. To be tested, also removed as many divs and margins and paddings as I can, still dont fully understand why some indent more than others, etc. but it works for now

This commit is contained in:
2020-11-22 23:56:34 +11:00
parent afb132820b
commit 7bd3ff4c26

View File

@@ -25,67 +25,63 @@
{% endfor %} {% endfor %}
</div> </div>
{% elif key == "publisher" %} {% elif key == "publisher" %}
<div class="col-lg-10"> <div class="form-row col input-group" style="margin-left:0px; margin-right:0px;">
<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></a>
</button>
</div>
<select class="form-control" id="publisher">
{% for pub in publisher_list %}
{% set pname=pub.name %}
<option id="{{pub.id}}" value="{{pub.id}}"
{% if books.publisher[0].name == pname %}
selected
{% endif %}
>{{pname}}</option>
{% endfor %}
</select>
</div class="row">
{% elif key == "author" %}
<div class="form-row col" style="margin-left:0px;margin-right:0px">
{% set cnt = namespace(idx=0) %}
{% for objects in books[key] %}
<div class="col input-group" style="padding-left:0px;padding-right:0px">
{% if cnt.idx > 0 %}
<div class="input-group-prepend">
<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>
</div>
{% endif %}
<div class="input-group-prepend"> <div class="input-group-prepend">
<button class="btn btn-outline-primary" type="button"> <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> <a style="color:inherit" href="{{url_for(key, id=books[key][cnt.idx].id)}}"><i class="far fa-edit"></i></a>
</button> </button>
</div> </div>
<select class="form-control" id="publisher"> <select class="form-control" id="author[{{cnt.idx}}]">
{% for pub in publisher_list %} {% for auth in author_list %}
{% set pname=pub.name %} {% set aname=auth.surname+", "+auth.firstnames %}
<option id="{{books.publisher[0].id}}" value="{{books.publisher[0].id}}" <option id="{{auth.id}}" value="{{auth.id}}"
{% if books.publisher[0].name == pname %} {% if books.author[cnt.idx].id == auth.id %}
selected selected
{% endif %} {% endif %}
>{{pname}}</option> >{{aname}}</option>
{% endfor %} {% endfor %}
</select> </select>
</div class="row"> </div class="col">
</div class="col-lg-10"> {% set cnt.idx = cnt.idx+1 %}
{% elif key == "author" %} {% endfor %}
<div class="col-lg-10"> <div class="input-group-append">
<div class="form-row" style="margin-left:0px;margin-right:0px"> <button class="btn btn-outline-success" type="button">
{% set cnt = namespace(idx=0) %} <a style="color:inherit" href="{{url_for(key, id=-1)}}"><i class="fas fa-plus"></i></a>
{% for objects in books[key] %} </button>
<div class="col input-group" style="padding-left:0px;padding-right:0px"> </div>
{% if cnt.idx > 0 %} </div class="form-row">
<div class="input-group-prepend">
<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>
</div>
{% endif %}
<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="input-group-append">
<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="form-row">
</div class="col-lg-10">
{% else %} {% else %}
<div class="col-lg-10"> <div class="col">
{{book_form[key](class="form-control", value=books[key], rows="5" )}} {{book_form[key](class="form-control", value=books[key], rows="5" )}}
</div class="col-lg-10"> </div class="col">
{% endif %} {% endif %}
</div class="form-row"> </div class="form-row">
{% endfor %} {% endfor %}