TODO 3 and 4 finished. removing parent or sub books from series handled

This commit is contained in:
2021-01-06 23:26:10 +11:00
parent 815cdf0291
commit 9617186279
3 changed files with 69 additions and 9 deletions

View File

@@ -22,6 +22,46 @@
<script>
function ConfirmRemoveParentAndSubsFromSeries(pid,bid)
{
$('#dbox-title').html('Confirm: Removing Parent Book from Series')
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>
</div class="row">
<div class="row col-lg-12">
<button id="RPS" class="btn btn-primary col-lg-2">Remove all children</button>
<button onClick="$('#dbox').modal('hide')"
class="btn btn-outline-danger offset-lg-8 col-lg-2"> Cancel Series change</button>
</div class="row">
`
$('#dbox-content').html(div)
$('#dbox').modal('show')
// have to do this AFTER modal show otherwise it doesnt exist... (grrr)
$('#RPS').attr( 'onClick', "$('#dbox').modal('hide') ; $.post( '/rem_parent_books_from_series/" +pid + "' ) ; window.location='/book/"+ bid + "'" )
}
function ConfirmRemoveThisSubs_ParentAndSubsFromSeries(pid,bid)
{
$('#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>
</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">
Cancel Series change</button>
</div class="row">
`
$('#dbox-content').html(div)
$('#dbox').modal('show')
// have to do this AFTER modal show otherwise it doesnt exist... (grrr)
$('#RPS').attr( 'onClick', "$('#dbox').modal('hide') ; $.post( '/rem_parent_books_from_series/" +pid + "' ) ; window.location='/book/"+ bid + "'" )
}
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>'
}
@@ -337,7 +377,15 @@ function AddAuthorToBook(num) {
<script>
$(document).ready( function() {
$("#sub_book_content").load("/subbooks_for_book/{{books.id}}")
{% if CheckSeriesChange is defined and CheckSeriesChange != None %}
{% if CheckSeriesChange.type == 'parent' %}
ConfirmRemoveParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}} )
{% else %}
ConfirmRemoveThisSubs_ParentAndSubsFromSeries( {{CheckSeriesChange.pid}}, {{CheckSeriesChange.bid}} )
{% endif %}
{% endif %}
} )
</script>
{% endblock script_content %}
{% endif %}