79 lines
2.9 KiB
HTML
79 lines
2.9 KiB
HTML
<table id="book_table" class="table table-striped table-sm small" data-toolbar="#toolbar" data-search="true">
|
|
<thead>
|
|
<tr class="thead-light"><th>Title</th><th>Book Number</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for book in books %}
|
|
<tr>
|
|
<td id="{{book.id}}">
|
|
{% if book.parent|length %}
|
|
{% set style="style=visibility:hidden" %}
|
|
{% endif %}
|
|
<button name="move_button" value="up-{{book.id}}" id="up-{{book.id}}" class="btn btn-outline-primary btn-small" {{style}}
|
|
onClick="$.ajax({
|
|
type: 'POST', url: '/books_for_series/{{series.id}}',
|
|
data: '&id={{series.id}}&move_button=up-{{book.id}}',
|
|
success: function(data){
|
|
$('#books_for_series_bit').html(data); }
|
|
} ); return false;">
|
|
<i class="fas fa-angle-double-up" style="font-size:10px"></i></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}}',
|
|
data: '&id={{series.id}}&move_button=down-{{book.id}}',
|
|
success: function(data){
|
|
$('#books_for_series_bit').html(data); }
|
|
} ); return false;">
|
|
<i class="fas fa-angle-double-down" style="font-size:10px"></i></button>
|
|
<a href="/book/{{book.id}}">{{book.title}}</a>
|
|
</td>
|
|
{% set num = SeriesBookNum( series.id, book.id ) %}
|
|
{% if num == None %}
|
|
{# okay, if this is a parent book, the num == None, so find first child / sub_book's book number in the series #}
|
|
{# then we treat each book_num as a 0-leading 3 digit number - for the parent book we minus 1 from it #}
|
|
{% set tmp = SeriesBookNum( series.id, book.child_ref[0].sub_book_id ) %}
|
|
{% set num = "{:02d}0".format( tmp ) %}
|
|
{% set num = num|int - 1 %}
|
|
<td data-sort="{{series.id}}{{"{:03d}".format( num )}}">
|
|
{% else %}
|
|
<td data-sort="{{series.id}}{{"{:02d}0".format( num )}}">
|
|
{% endif %}
|
|
{% for s in book.series %}
|
|
{% set num = SeriesBookNum( s.id, book.id ) %}
|
|
{% if num != None %}
|
|
{{num}} of <a href="/series/{{s.id}}">{{s.title}}</a><br>
|
|
{% endif %}
|
|
{% if SeriesBookNum( s.id, book.id ) == 1 %}
|
|
<script>
|
|
{% if book.parent|length %}
|
|
$('#up-{{book.parent[0].id}}').prop("disabled", true)
|
|
{% else %}
|
|
$('#up-{{book.id}}').prop("disabled", true)
|
|
{% endif %}
|
|
</script>
|
|
{% endif %}
|
|
{% if SeriesBookNum( s.id, book.id ) == s.num_books %}
|
|
<script>
|
|
{% if book.parent|length %}
|
|
$('#down-{{book.parent[0].id}}').prop("disabled", true)
|
|
{% else %}
|
|
$('#down-{{book.id}}').prop("disabled", true)
|
|
{% endif %}
|
|
</script>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#book_table').DataTable( {
|
|
"paging": false, "searching": false, "info": false,
|
|
"order": [[1, 'asc']],
|
|
"columnDefs": [ { "type": "num", "targets": 1 } ] } );
|
|
} );
|
|
</script>
|