converted over to bal from author, and fixed up the way sub books / series interact

This commit is contained in:
2023-07-01 14:26:36 +10:00
parent 90792728b3
commit 6cef2e0d9c
5 changed files with 230 additions and 92 deletions

View File

@@ -200,7 +200,11 @@ function AddAuthorToBook(num) {
}
</script>
{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
{#
{% set keys = [ 'title', 'bals', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
#}
{% set keys = [ 'title', 'bals', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<div class="container-fluid">
<div class="form-row"><h3 class="offset-2">{{page_title}}</h3></div>
<div class="row" id="main-row">
@@ -223,7 +227,11 @@ function AddAuthorToBook(num) {
{% endif %}
{% for key in keys %}
<div class="form-row input-group">
<label for="{{key}}" class="input-group-text col-2 justify-content-end">{{key}}:</label>
{% if key == "bals" %}
<label for="author(s)" class="input-group-text col-2 justify-content-end">author(s):</label>
{% else %}
<label for="{{key}}" class="input-group-text col-2 justify-content-end">{{key}}:</label>
{% endif %}
{% if key == "genre" %}
<div class="row col-10">
{% for genre in genre_list %}
@@ -239,6 +247,42 @@ function AddAuthorToBook(num) {
</div>
{% endfor %}
</div>
{% elif key == "bals" %}
{% set cnt = namespace(idx=1) %}
{% for a in books[key] %}
{% if cnt.idx > 1 %}
<button id="author-rem-{{cnt.idx}}" class="btn btn-outline-danger input-group-append" type="button" onClick="RemoveAuthorFromBook({{cnt.idx}})">
<svg width="22" height="22" fill="currentColor">
<use xlink:href="{{url_for('static', filename='icons.svg')}}#minus"/>
</svg>
</button>
{% endif %}
<select class="form-select input-group-append" name="author-{{cnt.idx}}" id="author-{{cnt.idx}}">
{% for auth in author_list %}
{% set aname=auth.surname+", "+auth.firstnames %}
<option value="{{auth.id}}"
{% if a.author.id == auth.id %}
selected
{% endif %}
>{{aname}}</option>
{% endfor %}
</select>
{% set cnt.idx = cnt.idx+1 %}
{% endfor %}
{# if idx is still 1, then no authors - new book, just put one there - book HAS to have an author #}
{% if cnt.idx == 1 %}
<select class="form-select input-group-append" name="author-1" id="author-1">
{% for auth in author_list %}
{% set aname=auth.surname+", "+auth.firstnames %}
<option value="{{auth.id}}">{{aname}}</option>
{% endfor %}
</select>
<button id="author-plus" class="btn btn-outline-success input-group-append" type="button" onClick="AddAuthorToBook(2)">
{% else %}
<button id="author-plus" class="btn btn-outline-success input-group-append" type="button" onClick="AddAuthorToBook({{cnt.idx}})">
{% endif %}
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
</button>
{% elif key == "author" %}
{% set cnt = namespace(idx=0) %}
{% for objects in books[key] %}