78 lines
2.9 KiB
HTML
78 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>
|
|
{% set last = namespace(val=0) %}
|
|
{% for book in books %}
|
|
<tr>
|
|
<td id="{{book.id}}">
|
|
{% if book.parent_ref|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); }
|
|
} );">
|
|
<i class="fas fa-angle-double-up" ></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); }
|
|
} );">
|
|
<i class="fas fa-angle-double-down"></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 make it use last real-book and add .01 to it to make sure it sorts just after the last one #}
|
|
<td data-sort="{{series.id}}.{{"{:02d}1".format( last.val )}}">
|
|
{% else %}
|
|
<td data-sort="{{series.id}}.{{"{:02d}".format( num )}}">
|
|
{% endif %}
|
|
{% for s in book.series %}
|
|
{% if not book.child_ref|length %}
|
|
{{ SeriesBookNum( s.id, book.id ) }} of <a href="/series/{{s.id}}">{{s.title}}</a><br>
|
|
{% endif %}
|
|
{% if SeriesBookNum( s.id, book.id ) == 1 %}
|
|
<script>
|
|
{% if book.parent_ref|length %}
|
|
$('#up-{{book.parent_ref[0].book_id}}').addClass("disabled")
|
|
{% else %}
|
|
$('#up-{{book.id}}').addClass("disabled")
|
|
{% endif %}
|
|
</script>
|
|
{% endif %}
|
|
{% if SeriesBookNum( s.id, book.id ) == s.num_books %}
|
|
<script>
|
|
{% if book.parent_ref|length %}
|
|
$('#down-{{book.parent_ref[0].book_id}}').addClass("disabled")
|
|
{% else %}
|
|
$('#down-{{book.id}}').addClass("disabled")
|
|
{% endif %}
|
|
</script>
|
|
{% endif %}
|
|
{% set last.val = num %}
|
|
{% endfor %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
|
|
<script src="https://cdn.datatables.net/1.10.22/js/dataTables.bootstrap4.min.js"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#book_table').DataTable( {
|
|
"paging": false, "searching": false, "info": false,
|
|
"order": [[1, 'asc']],
|
|
"columnDefs": [ { "type": "num", "targets": 1 } ] } );
|
|
} );
|
|
</script>
|