100 lines
3.8 KiB
HTML
100 lines
3.8 KiB
HTML
{% 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"><div class="row"><form class="form col-lg-12">
|
|
{% for key in keys %}
|
|
<div class="form-row">
|
|
<label for="{{key}}" class="col-lg-2 col-form-label">{{key}}:</label>
|
|
{% if key == "genre" %}
|
|
<div class="form-row col-lg-10">
|
|
{% for genre in genre_list %}
|
|
{% set gname=genre.name %}
|
|
<div class="form-control col" style="margin-left:5px;margin-right:-5px;">
|
|
<input id="{{gname}}" name="{{gname}}" type="checkbox"
|
|
{% for book_g in books.genre %}
|
|
{% if book_g['name'] == gname %}
|
|
checked
|
|
{% endif %}
|
|
{% endfor %}
|
|
></input>
|
|
<label style="display:inline" for="{{gname}}" class="col-form-label">{{gname}}</label>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% elif key == "publisher" %}
|
|
<div class="form-row col 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">
|
|
<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="author[{{cnt.idx}}]">
|
|
{% for auth in author_list %}
|
|
{% set aname=auth.surname+", "+auth.firstnames %}
|
|
<option id="{{auth.id}}" value="{{auth.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">
|
|
{% else %}
|
|
<div class="col">
|
|
{{book_form[key](class="form-control", value=books[key], rows="5" )}}
|
|
</div class="col">
|
|
{% endif %}
|
|
</div class="form-row">
|
|
{% endfor %}
|
|
</form></div class="row"></div class="container">
|
|
{% 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 %}
|
|
<p>loan is defined: {{books.loan}}</p>
|
|
{% endif %}
|
|
|
|
{% endblock main_content %}
|