fixed add/rem author funtionality for bs5 and converted to svg icons away from fontawesome
This commit is contained in:
10
BUGs
10
BUGs
@@ -1,18 +1,14 @@
|
||||
### fix to get this working with bs 5...
|
||||
editing a book needs to use input groups
|
||||
+/- buttons (add/rem say authors) are in wrong spot / input-group
|
||||
get rid of font-awesome and use bootstrap5 icons
|
||||
|
||||
upgrade bootstrap, dataTables, etc.
|
||||
|
||||
|
||||
#### BUGS (next-20)
|
||||
#### BUGS (next-21)
|
||||
|
||||
### DB/back-end
|
||||
|
||||
### UI not updating after DB change:
|
||||
BUG-3: alter a condition, covertype, etc. and its not in drop-down list (even though db look via index is correct, e.g books.html shows updated covertype)
|
||||
BUG-7: if you remove a series from a book, it won't appear in the series drop-down if it is the first 'missing' book in that series -- either reset the list, or show all series always?
|
||||
BUG-20: broken gui with bs5:
|
||||
* series add/rem needs to lose divs inside divs of input groups (and templ)
|
||||
|
||||
### ordering of data in UI:
|
||||
BUG-6: author,series, etc. do not have explicit ordering like sub-books... sort of irritating / needs code and DB fix
|
||||
|
||||
2
README
2
README
@@ -52,3 +52,5 @@ Maybe:
|
||||
TODO-20: ORM all books load is slow
|
||||
- should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....)
|
||||
TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book)
|
||||
TODO-22: upgrade bootstrap, dataTables, etc.
|
||||
|
||||
|
||||
1
main.py
1
main.py
@@ -745,7 +745,6 @@ def add_books_to_loan(id):
|
||||
add_id=int(re.findall( '\d+', field )[0])
|
||||
try:
|
||||
db.engine.execute("insert into book_loan_link (book_id, loan_id) values ( {}, {} )".format( add_id, id ))
|
||||
print("insert into book_loan_link (book_id, loan_id) values ( {}, {} )".format( add_id, id ))
|
||||
db.session.commit()
|
||||
except SQLAlchemyError as e:
|
||||
st.SetAlert("danger")
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
{# use tmpl-series-div as a template & keep it hidden always #}
|
||||
<div id="tmpl-series-div" class="col input-group" style="display:none">
|
||||
<div id="series-minus-div-NUM" class="input-group-prepend">
|
||||
<button id="series-minus-but-NUM" class="btn btn-outline-danger" type="button"><i class="fas fa-minus"></i></button>
|
||||
<button id="series-minus-but-NUM" class="btn btn-outline-danger" type="button">
|
||||
<svg width="22" height="22" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#minus"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<input type="hidden" id="bsl-book_id-NUM" name="bsl-book_id-NUM" value="{{books.id}}">
|
||||
<span class="form-control col-2">Book </span>
|
||||
@@ -16,7 +20,9 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
<div id="series-plus-div-NUM" class="input-group-append">
|
||||
<button id="series-plus-but-NUM" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()"><i class="fas fa-plus"></i></button>
|
||||
<button id="series-plus-but-NUM" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()">
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div id="tmpl-series-div">
|
||||
|
||||
@@ -89,7 +95,9 @@ function ConfirmRemoveThisSubs_ParentAndSubsFromSeries(pid,bid,rem)
|
||||
}
|
||||
|
||||
function SeriesButPlus(num) {
|
||||
return '<div id="series-plus-div'+num+'" class="input-group-append"><button id="series-plus-but-'+num+'" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()"><i class="fas fa-plus"></i></button></div>'
|
||||
return '<div id="series-plus-div'+num+'" class="input-group-append"><button id="series-plus-but-'+num+'" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()">
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button></div>'
|
||||
}
|
||||
|
||||
function AddBookToSeries() {
|
||||
@@ -172,27 +180,32 @@ function RemoveBookFromSeries(sid) {
|
||||
|
||||
function RemoveAuthorFromBook(num) {
|
||||
console.log("remove an author at slot: " + num )
|
||||
$('#auth-div-'+num).remove()
|
||||
$('#author-'+num).remove()
|
||||
$('#author-rem-'+num).remove()
|
||||
}
|
||||
function AddAuthorToBook(num) {
|
||||
console.log("insert a new author at slot: " + num )
|
||||
div = `
|
||||
<div id="auth-div-NUM" class="col input-group px-0">
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-outline-danger" type="button" onClick="RemoveAuthorFromBook(NUM)"><i class="fas fa-minus"></i></button>
|
||||
</div>
|
||||
<button id="author-rem-NUM" class="btn btn-outline-danger input-group-append" type="button" onClick="RemoveAuthorFromBook(NUM)">
|
||||
<svg width="22" height="22" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#minus"/>
|
||||
</svg>
|
||||
</button>
|
||||
<select class="form-select" name="author-NUM" id="author-NUM">
|
||||
{% for auth in author_list %}
|
||||
{% set aname=auth.surname+", "+auth.firstnames %}
|
||||
<option value="{{auth.id}}">{{aname}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
`
|
||||
div=div.replace( /NUM/g, num )
|
||||
$('#auth-div-'+(num-1)).after( div )
|
||||
$('#author-plus').prev().after(div)
|
||||
new_add_func_str='AddAuthorToBook('+(num+1)+')'
|
||||
$('#author-plus').attr( 'onclick', new_add_func_str )
|
||||
$('#author-rem-'+num).hover(
|
||||
function() { $('#author-'+num).prop( 'style', 'color:red' ) },
|
||||
function() { $('#author-'+num).prop( 'style', '' ) } )
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -218,8 +231,7 @@ function AddAuthorToBook(num) {
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for key in keys %}
|
||||
<div class="form-row">
|
||||
<div class="input-group">
|
||||
<div class="form-row input-group">
|
||||
<label for="{{key}}" class="input-group-text col-2 justify-content-end">{{key}}:</label>
|
||||
{% if key == "genre" %}
|
||||
<div class="row col-10">
|
||||
@@ -237,16 +249,16 @@ function AddAuthorToBook(num) {
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% elif key == "author" %}
|
||||
<div class="form-row col mx-0">
|
||||
{% set cnt = namespace(idx=0) %}
|
||||
{% for objects in books[key] %}
|
||||
<div id="auth-div-{{cnt.idx}}" class="col input-group px-0">
|
||||
{% if cnt.idx > 0 %}
|
||||
<div class="input-group-prepend">
|
||||
<button class="btn btn-outline-danger" type="button" onClick="RemoveAuthorFromBook({{cnt.idx}})"><i class="fas fa-minus"></i></button>
|
||||
</div>
|
||||
<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" name="author-{{cnt.idx}}" id="author-{{cnt.idx}}">
|
||||
<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}}"
|
||||
@@ -256,25 +268,20 @@ function AddAuthorToBook(num) {
|
||||
>{{aname}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div class="col">
|
||||
{% set cnt.idx = cnt.idx+1 %}
|
||||
{% endfor %}
|
||||
{% if cnt.idx == 0 %}
|
||||
<div id="auth-div-{{cnt.idx}}" class="col input-group px-0">
|
||||
<select class="form-select" name="author-{{cnt.idx}}" id="author-{{cnt.idx}}">
|
||||
<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}}">{{aname}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div class="col">
|
||||
{% endif %}
|
||||
<div class="input-group-append">
|
||||
<button id="author-plus" class="btn btn-outline-success" type="button" onClick="AddAuthorToBook({{cnt.idx}})"><i class="fas fa-plus"></i></button>
|
||||
</div>
|
||||
</div class="form-row">
|
||||
<button id="author-plus" class="btn btn-outline-success input-group-append" type="button" onClick="AddAuthorToBook({{cnt.idx}})">
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button>
|
||||
{% else %}
|
||||
<div class="col">
|
||||
{% set rows=4 %}
|
||||
{% if key == "notes" %}
|
||||
{% set rows=2 %}
|
||||
@@ -287,14 +294,12 @@ function AddAuthorToBook(num) {
|
||||
<input type="hidden" name="{{key}}" value="{{book_form[key].data}}">
|
||||
{% elif key == 'publisher' or key == 'owned' or key == 'covertype'
|
||||
or key == 'condition' or key == 'rating' %}
|
||||
{{book_form[key](class="form-select" )}}
|
||||
{{book_form[key](class="form-select input-group-append" )}}
|
||||
{% else %}
|
||||
{{book_form[key](class="form-control", rows=rows )}}
|
||||
{{book_form[key](class="form-control input-group-append", rows=rows )}}
|
||||
{% endif %}
|
||||
</div class="col">
|
||||
{% endif %}
|
||||
</div class="input-group">
|
||||
</div class="form-row">
|
||||
</div class="form-row input-group">
|
||||
{% endfor %}
|
||||
<div id="series_row" class="form-row">
|
||||
<label for="series" class="col-2 col-form-label">Series:</label>
|
||||
@@ -305,7 +310,9 @@ function AddAuthorToBook(num) {
|
||||
<div id="series-div-0" class="form-row col mx-0 input-group" style="display:none">
|
||||
<span class="form-control input-group-text bg-white"> </span>
|
||||
<div id="series-plus-div-0" class="input-group-append">
|
||||
<button id="series-plus-but-0" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()"><i class="fas fa-plus"></i></button>
|
||||
<button id="series-plus-but-0" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()">
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div id="series-div-0" class="form-row col mx-0 input-group">
|
||||
{% for s in books.series %}
|
||||
@@ -322,7 +329,9 @@ function AddAuthorToBook(num) {
|
||||
<div id="series-minus-div-{{loop.index}}" class="input-group-prepend disabled" >
|
||||
<button id="series-minus-but-{{loop.index}}" class="btn btn-outline-danger {{dsiabled}}" {{disabled}} type="button"
|
||||
onClick="RemoveBookFromSeries('series-div-{{loop.index}}')">
|
||||
<i class="fas fa-minus"></i>
|
||||
<svg width="22" height="22" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#minus"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-control input-group-text bg-white">
|
||||
@@ -332,7 +341,9 @@ function AddAuthorToBook(num) {
|
||||
{% set hiddens.txt=hiddens.txt+"<input type='hidden' name='bsl-book_num-{}' value='PARENT'>".format(loop.index) %}
|
||||
<div id="series-minus-div-{{loop.index}}" class="input-group-prepend">
|
||||
<button id="series-minus-but-{{loop.index}}" class="btn btn-outline-danger" type="button" onClick="RemoveBookFromSeries('series-div-{{loop.index}}')">
|
||||
<i class="fas fa-minus"></i>
|
||||
<svg width="22" height="22" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#minus"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-control input-group-text bg-white">
|
||||
@@ -342,7 +353,7 @@ function AddAuthorToBook(num) {
|
||||
{% if books.series|length == loop.index %}
|
||||
<div id="series-plus-div-{{loop.index}}" class="input-group-append">
|
||||
<button id="series-plus-but-{{loop.index}}" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()">
|
||||
<i class="fas fa-plus"></i>
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -354,7 +365,9 @@ function AddAuthorToBook(num) {
|
||||
<div id="series-div-0" class="form-row col mx-0 input-group">
|
||||
<span class="form-control input-group-text bg-white"> </span>
|
||||
<div id="series-plus-div-0" class="input-group-append">
|
||||
<button id="series-plus-but-0" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()"><i class="fas fa-plus"></i></button>
|
||||
<button id="series-plus-but-0" class="btn btn-outline-success" type="button" onClick="AddBookToSeries()">
|
||||
<svg width="22" height="22" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#plus"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div id="series-div-0" class="form-row col mx-0 input-group">
|
||||
{% endif %}
|
||||
@@ -435,8 +448,14 @@ function AddAuthorToBook(num) {
|
||||
{{CheckSeriesChange.removing_series|safe}} )
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% set cnt = namespace(idx=1) %}
|
||||
{% for authors in books['author'] %}
|
||||
$('#author-rem-{{cnt.idx}}').hover(
|
||||
function() { $('#author-{{cnt.idx}}').prop( 'style', 'color:red' ) },
|
||||
function() { $('#author-{{cnt.idx}}').prop( 'style', '' ) } )
|
||||
{% set cnt.idx = cnt.idx+1 %}
|
||||
{% endfor %}
|
||||
} )
|
||||
|
||||
</script>
|
||||
{% endblock script_content %}
|
||||
{% endif %}
|
||||
|
||||
@@ -54,11 +54,14 @@
|
||||
{% else %}
|
||||
<td align="center">
|
||||
{% if cond == "Good" %}
|
||||
<i class="fas fa-book" style="color:black"></i>
|
||||
<svg width="22" height="22" fill="black">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#book"/></svg>
|
||||
{% elif cond == "Average" %}
|
||||
<i class="fas fa-book" style="color:orange"></i>
|
||||
<svg width="22" height="22" fill="orange">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#book"/></svg>
|
||||
{% elif cond == "Needs Replacing" %}
|
||||
<i class="fas fa-book" style="color:red"></i>
|
||||
<svg width="22" height="22" fill="red">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#book"/></svg>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
success: function(data){
|
||||
$('#books_for_series_bit').html(data); }
|
||||
} ); return false;">
|
||||
<i class="fas fa-angle-double-up" style="font-size:10px"></i></button>
|
||||
<svg width="12" height="12" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#caret-up-fill"/>
|
||||
</svg>
|
||||
</button>
|
||||
<button name="move_button" value="down-{{book.id}}" id="down-{{book.id}}" class="btn btn-outline-primary btn-small" {{style}}
|
||||
onClick="$.ajax({
|
||||
type: 'POST', url: '/books_for_series/{{series.id}}',
|
||||
@@ -24,7 +27,10 @@
|
||||
success: function(data){
|
||||
$('#books_for_series_bit').html(data); }
|
||||
} ); return false;">
|
||||
<i class="fas fa-angle-double-down" style="font-size:10px"></i></button>
|
||||
<svg width="12" height="12" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#caret-down-fill"/>
|
||||
</svg>
|
||||
</button>
|
||||
<a href="/book/{{book.id}}">{{book.title}}</a>
|
||||
</td>
|
||||
{% set num = SeriesBookNum( series.id, book.id ) %}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
<div class="row px-3 my-5 col-6" style="border: 3px solid #5bc0de; border-radius: 15px;">
|
||||
<h3 class="my-3 text-center" style="color: #5bc0de">
|
||||
<svg width="64" height="64" fill="currentColor"><use xlink:href="{{url_for('static', filename='book.svg')}}#logo" /></svg> Book DB Login</h3>
|
||||
<svg width="64" height="64" fill="currentColor"><use xlink:href="{{url_for('static', filename='icons.svg')}}#logo" /></svg> Book DB Login</h3>
|
||||
<form class="" method="POST">
|
||||
<div class="input-group">
|
||||
<label for="username" class="text-right input-group-text col-4 text-info">Username:</label>
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
success: function(data){
|
||||
$('#sub_book_content').html(data); }
|
||||
} ); return false;">
|
||||
<i class="fas fa-angle-double-up" style="font-size:10px"></i></button>
|
||||
<svg width="12" height="12" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#caret-up-fill"/>
|
||||
</svg>
|
||||
</button>
|
||||
{% set state="" %}
|
||||
{% if loop.index == sub_books|length %}
|
||||
{% set state="disabled" %}
|
||||
@@ -29,7 +32,10 @@
|
||||
success: function(data){
|
||||
$('#sub_book_content').html(data); }
|
||||
} ); return false;">
|
||||
<i class="fas fa-angle-double-down" style="font-size:10px"></i></button>
|
||||
<svg width="12" height="12" fill="currentColor">
|
||||
<use xlink:href="{{url_for('static', filename='icons.svg')}}#caret-down-fill"/>
|
||||
</svg>
|
||||
</button>
|
||||
<a href="/book/{{book.sub_book_id}}">{{book.title}}</a>
|
||||
</td>
|
||||
<td>{{book.rating}}</td><td>{{book.author}}</td><td>{{book.year_published}}</td>
|
||||
|
||||
Reference in New Issue
Block a user