can now remove just 1 sub book - TODO-25 -- DONE
This commit is contained in:
1
README
1
README
@@ -28,7 +28,6 @@ python3 main.py
|
||||
|
||||
|
||||
#### TODOS (next 26):
|
||||
TODO-25: allow removing of just this sub-book from a series -- can cause a need by messing with UI, so should just add it as a possible in the dialog box
|
||||
TODO-23: when moving a book in a series (which is part of 2 series), do we pop-up offer to move parent/child series orders as well to match (think Thomas Covenant)
|
||||
TODO-24: get this into docker (as per TODO above)
|
||||
gunicorn and it seems easy enough: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04
|
||||
|
||||
15
main.py
15
main.py
@@ -508,21 +508,24 @@ def book(id):
|
||||
if 'author-' in el:
|
||||
book.author.append( Author.query.get( request.form[el] ) )
|
||||
|
||||
removing_series=[]
|
||||
for field in request.form:
|
||||
if 'removed-book_num' in field:
|
||||
cnt=int(re.findall( '\d+', field )[0])
|
||||
removing_series.append( { 'series_id' : request.form['removed-series_id-{}'.format(cnt)] } )
|
||||
still_in_series=0
|
||||
still_in_series_sid=99999
|
||||
if book.IsParent():
|
||||
for field in request.form:
|
||||
if 'bsl-book_num-' in field and field != 'bsl-book_num-NUM' and request.form[field] == 'PARENT':
|
||||
cnt=int(re.findall( '\d+', field )[0])
|
||||
print("cnt={}".format(cnt))
|
||||
still_in_series_sid=request.form['bsl-series_id-{}'.format(cnt)]
|
||||
still_in_series=1
|
||||
|
||||
if book.IsChild() or (book.IsParent() and not still_in_series):
|
||||
print ("okay should raise DBox")
|
||||
print ("{}".format( removing_series ))
|
||||
if book.IsParent():
|
||||
CheckSeriesChange={'type':'parent', 'pid': book.id, 'bid': book.id}
|
||||
CheckSeriesChange={'type':'parent', 'pid': book.id, 'bid': book.id, 'removing_series': removing_series }
|
||||
else:
|
||||
CheckSeriesChange={'type':'child', 'pid': book.parent[0].id, 'bid': book.id }
|
||||
CheckSeriesChange={'type':'child', 'pid': book.parent[0].id, 'bid': book.id, 'removing_series': removing_series }
|
||||
else:
|
||||
# delete all bsls
|
||||
db.engine.execute("delete from book_series_link where book_id = {}".format( book.id ) )
|
||||
|
||||
@@ -22,13 +22,21 @@
|
||||
|
||||
<script>
|
||||
|
||||
function ConfirmRemoveParentAndSubsFromSeries(pid,bid)
|
||||
function ConfirmRemoveParentAndSubsFromSeries(pid,bid,rem)
|
||||
{
|
||||
$('#dbox-title').html('Confirm: Removing Parent Book from Series')
|
||||
if( rem.length > 1 )
|
||||
all='<span style="background:red" class="text-white"><em>ALL</em></span>'
|
||||
else
|
||||
all='this '
|
||||
div=`
|
||||
<div class="row col-lg-12">
|
||||
<p class="lead">You have chosen to remove this (parent) book from a series.
|
||||
What should we do with the sub-books for <span style="background:red" class="text-white"><em>ALL</em></span> series?</p>
|
||||
What should we do with the sub-books for
|
||||
`
|
||||
div += all
|
||||
div += `
|
||||
series?</p>
|
||||
</div class="row">
|
||||
<div class="row col-lg-12">
|
||||
<button id="RPS" class="btn btn-primary col-lg-2">Remove all children</button>
|
||||
@@ -42,24 +50,43 @@ function ConfirmRemoveParentAndSubsFromSeries(pid,bid)
|
||||
$('#RPS').attr( 'onClick', "$('#dbox').modal('hide') ; $.post( '/rem_parent_books_from_series/" +pid + "' ) ; window.location='/book/"+ bid + "'" )
|
||||
}
|
||||
|
||||
function ConfirmRemoveThisSubs_ParentAndSubsFromSeries(pid,bid)
|
||||
function ConfirmRemoveThisSubs_ParentAndSubsFromSeries(pid,bid,rem)
|
||||
{
|
||||
$('#dbox-title').html('Confirm: Removing Sub Book from Series')
|
||||
div=`
|
||||
<div class="row col-lg-12">
|
||||
<p>You have chosen to remove this (sub) book from a series.
|
||||
What should we do with the parent and all its sub-books for <span style="background:red" class="text-white"><em>ALL</em></span>series?</p>
|
||||
<p class="lead">You have chosen to remove this (sub) book from a series.
|
||||
What should we do with the sub-books <span id="RPS-text"></span>
|
||||
</p>
|
||||
</div class="row">
|
||||
<div class="row col-lg-12">
|
||||
<button id="RPS" class="btn btn-primary col-lg-2">Remove parent and all children too</button>
|
||||
<button onClick="$('#dbox').modal('hide')" class="btn btn-outline-danger offset-lg-8 col-lg-2">
|
||||
<button id="RPS" class="btn btn-primary col"></button>
|
||||
<button id="RPS-one" onClick="alert('not yet')" class="btn btn-outline-primary col"></button>
|
||||
<button onClick="$('#dbox').modal('hide')" class="btn btn-outline-danger col">
|
||||
Cancel Series change</button>
|
||||
</div class="row">
|
||||
`
|
||||
console.log(rem.length)
|
||||
if( rem.length > 1 )
|
||||
{
|
||||
all='for <span style="background:red" class="text-white"><em>ALL</em></span> series'
|
||||
b_RPS="Remove parent and all children too " + all
|
||||
b_RPS_one="Remove just this (sub) book " + all
|
||||
}
|
||||
else
|
||||
{
|
||||
all='for this series '
|
||||
b_RPS="Remove parent and all children too"
|
||||
b_RPS_one="Remove just this (sub) book"
|
||||
}
|
||||
$('#dbox-content').html(div)
|
||||
$('#dbox').modal('show')
|
||||
// have to do this AFTER modal show otherwise it doesnt exist... (grrr)
|
||||
$('#RPS-text').html(all)
|
||||
$('#RPS').html(b_RPS)
|
||||
$('#RPS').attr( 'onClick', "$('#dbox').modal('hide') ; $.post( '/rem_parent_books_from_series/" +pid + "' ) ; window.location='/book/"+ bid + "'" )
|
||||
$('#RPS-one').html(b_RPS_one)
|
||||
$('#RPS-one').attr( 'onClick', "$('#dbox').modal('hide') ; $.post( '/rem_parent_books_from_series/" +bid + "' ) ; window.location='/book/"+ bid + "'" )
|
||||
}
|
||||
|
||||
function SeriesButPlus(num) {
|
||||
@@ -117,10 +144,19 @@ function RemoveBookFromSeries(sid) {
|
||||
$('#'+sid).remove()
|
||||
|
||||
var num = parseInt( sid.match(/\d+/g), 10 );
|
||||
// remove the bsl data (its appended outside of div to avoid bootstrap issues
|
||||
$('[name=bsl-book_id-'+num+']').remove()
|
||||
$('[name=bsl-series_id-'+num+']').remove()
|
||||
$('[name=bsl-book_num-'+num+']').remove()
|
||||
// move real DB data or delete 'new' bsl data (its appended outside of div to avoid bootstrap issues)
|
||||
if( $('input:hidden[name=bsl-series_id-'+num+']').length )
|
||||
{
|
||||
$('[name=bsl-book_id-'+num+']').attr('name', 'removed-book_id-'+num)
|
||||
$('[name=bsl-series_id-'+num+']').attr('name', 'removed-series_id-'+num)
|
||||
$('[name=bsl-book_num-'+num+']').attr('name', 'removed-book_num-'+num)
|
||||
}
|
||||
else
|
||||
{
|
||||
$('[name=bsl-book_id-'+num+']').remove()
|
||||
$('[name=bsl-series_id-'+num+']').remove()
|
||||
$('[name=bsl-book_num-'+num+']').remove()
|
||||
}
|
||||
|
||||
if( sid == 'series-div-1' ) {
|
||||
console.log("remove Book: and it was the only series, so hide series-div-1 and put 'plus / empty' div back" )
|
||||
@@ -377,11 +413,14 @@ function AddAuthorToBook(num) {
|
||||
<script>
|
||||
$(document).ready( function() {
|
||||
$("#sub_book_content").load("/subbooks_for_book/{{books.id}}")
|
||||
console.log( {{CheckSeriesChange.removing_series|safe}} )
|
||||
{% if CheckSeriesChange is defined and CheckSeriesChange != None %}
|
||||
{% if CheckSeriesChange.type == 'parent' %}
|
||||
ConfirmRemoveParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}} )
|
||||
ConfirmRemoveParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}},
|
||||
{{CheckSeriesChange.removing_series|safe}} )
|
||||
{% else %}
|
||||
ConfirmRemoveThisSubs_ParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}} )
|
||||
ConfirmRemoveThisSubs_ParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}},
|
||||
{{CheckSeriesChange.removing_series|safe}} )
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
} )
|
||||
|
||||
Reference in New Issue
Block a user