TODO-6 (add books to loan) is now complete, so loans are now fully functional... the whole pybook is now at least functional, more features/validation to come :)
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
<div id="bfl-new" class="col-lg-10 px-0 py-4">
|
||||
</div>
|
||||
<div class="col py-4">
|
||||
<button id="bfl-addsel-btn" class="btn btn-success disabled" disabled style="display:none" onClick="">Add Selected</button>
|
||||
<button id="bfl-addsel-btn" class="btn btn-success disabled" disabled style="display:none" onClick="AddSelToLoan()">Add Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
|
||||
{% if not InDBox %}
|
||||
<h3>All Books</h1>
|
||||
{% set tab_id = 'book_table' %}
|
||||
{% else %}
|
||||
{% set tab_id = 'addsel_table' %}
|
||||
{% endif %}
|
||||
<table id="book_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||
<table id="{{tab_id}}" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
|
||||
<thead>
|
||||
<tr class="thead-light"><th>Title</th><th>Author(s)</th>
|
||||
{% if not InDBox %}
|
||||
@@ -42,7 +45,7 @@
|
||||
{% endif %}
|
||||
<td>{{ GetCovertypeById(book.covertype) }}</td>
|
||||
{% if InDBox %}
|
||||
<td> <input type="checkbox"></td>
|
||||
<td><input name="addsel-{{book.id}}" type="checkbox" onClick="ActivateBFLAddSelButton()"></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -5,10 +5,17 @@
|
||||
$('#bfl-remsel-btn').attr('disabled',false)
|
||||
}
|
||||
|
||||
function DeactivateBFLRemSelButton()
|
||||
{
|
||||
$('#bfl-remsel-btn').addClass('disabled')
|
||||
$('#bfl-remsel-btn').attr('disabled',true)
|
||||
}
|
||||
|
||||
function RemoveSelFromLoan()
|
||||
{
|
||||
var params=$("#book_table :input").serializeArray()
|
||||
$.post( "/rem_books_from_loan/" + {{loan_id}}, params, function(data) {
|
||||
DeactivateBFLRemSelButton()
|
||||
$('#bfl-existing').load('/books_for_loan/' + {{loan_id}}, { 'InDBox' : 1 } )
|
||||
} )
|
||||
}
|
||||
@@ -18,10 +25,36 @@
|
||||
$('#dbox').modal('show')
|
||||
$.post( "/books_for_loan/" + {{loan_id}}, function(data) {$('#bfl-existing').html(data) } );
|
||||
}
|
||||
|
||||
function FindNewBFL()
|
||||
{
|
||||
$.post( "/search",{ 'term': $('#bfl-search-term').val(), 'InDBox': 1 }, function(data) { $('#bfl-new').html(data) ; $('#bfl-addsel-btn').show() } );
|
||||
}
|
||||
|
||||
function ActivateBFLAddSelButton()
|
||||
{
|
||||
$('#bfl-addsel-btn').removeClass('disabled')
|
||||
$('#bfl-addsel-btn').attr('disabled',false)
|
||||
}
|
||||
|
||||
function DeactivateBFLAddSelButton()
|
||||
{
|
||||
$('#bfl-addsel-btn').addClass('disabled')
|
||||
$('#bfl-addsel-btn').attr('disabled',true)
|
||||
$('#bfl-addsel-btn').attr('style','display:none')
|
||||
}
|
||||
|
||||
function AddSelToLoan()
|
||||
{
|
||||
var params=$("#addsel_table :input").serializeArray()
|
||||
$.post( "/add_books_to_loan/" + {{loan_id}}, params, function(data) {
|
||||
DeactivateBFLAddSelButton()
|
||||
DeactivateBFLRemSelButton()
|
||||
$('#bfl-search-term').val('')
|
||||
$('#bfl-new').html('')
|
||||
$('#bfl-existing').load('/books_for_loan/' + {{loan_id}}, { 'InDBox' : 1 } )
|
||||
} )
|
||||
}
|
||||
</script>
|
||||
|
||||
{% if not InDBox %}
|
||||
|
||||
Reference in New Issue
Block a user