added html for subbooks, made up/down buttons that work too. Also put back reference from subbook to parent book, via ORM data - need to investigate more, but it all works

This commit is contained in:
2020-11-30 21:59:50 +11:00
parent 5cc03fe7e7
commit ce34f68254
3 changed files with 78 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
{% extends "base.html" %}
{% block main_content %}
<h3><center>View/Edit Book</center></h1>
{% set keys = [ 'title', 'author', 'publisher', 'genre', 'owned', 'covertype', 'condition', 'year_published', 'rating', 'notes', 'blurb' ] %}
<div class="container-fluid"><div class="row"><form class="form col-lg-10">
@@ -80,7 +79,11 @@
</div class="form-row">
{% else %}
<div class="col">
{{book_form[key](class="form-control", value=books[key], rows="5" )}}
{% set rows=4 %}
{% if key == "notes" %}
{% set rows=2 %}
{% endif %}
{{book_form[key](class="form-control", value=books[key], rows=rows )}}
</div class="col">
{% endif %}
</div class="form-row">
@@ -91,19 +94,32 @@
<table>
{% for s in books.series %}
<tr><td>
Book {{ SeriesBookNum( s.id, books.id ) }} of {{s.num_books}} in <a href="/series/{{s.id}}">{{s.title}}</a>
{% if SeriesBookNum( s.id, books.id ) %}
<label class="form-control-plaintext">Book {{ SeriesBookNum( s.id, books.id ) }} of {{s.num_books}} in <a href="/series/{{s.id}}">{{s.title}}</a></label>
{% else %}
<label class="form-control-plaintext">Contains books in <a href='/series/{{s.id}}'>{{s.title}}</a></label>
{% endif %}
</td></tr>
{% endfor %}
</table>
</div>
{% endif %}
{% if books.child_ref|length %}
<div class="form-row">
<label class="col-lg-2 col-form-label">Sub Books:</label>
<div class="col" id="sub_book_content">
</div>
</div>
{% endif %}
{% if books.parent_ref|length %}
<div class="form-row">
<label class="col-lg-2 col-form-label">Parent Book:</label>
<div class="col">
<label class="form-control-plaintext"><a href="/book/{{b.parent[0].id}}">{{b.parent[0].title}}</a></label>
</div>
</div>
{% endif %}
</form>
{% endif %}
{% if books.sub_book|length %}
<p>sub_book is defined: {{books.sub_book}}</p>
{% endif %}
{% if books.subs|length %}
<p>subs is defined {{ books.subs }}</p>
{% endif %}
{% if books.loan|length %}
<div class="col">
<div class="card border-primary" style="max-width: 18rem;">
@@ -122,3 +138,12 @@
</div class="container">
{% endblock main_content %}
{% if books.child_ref|length %}
{% block script_content %}
<script>
$(document).ready( function() {
$("#sub_book_content").load("/subbooks_for_book/{{books.id}}")
} )
</script>
{% endblock script_content %}
{% endif %}