]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/list_books.tmpl
Feat(web/views/list_books): Toggle checkboxes for series
[m_librarian.git] / m_librarian / web / views / list_books.tmpl
1 #encoding utf-8
2 #import cgi
3 #from m_librarian.translations import translations
4 #extends views.layout
5 #attr $title = 'Список книг'
6 #def body
7 <h1>$title</h1>
8
9 <script type="text/javascript" language="Javascript">
10 <!--
11 function toggleBooks(name, value) {
12   cboxes = document.querySelectorAll(
13     'input[type=checkbox][name^=' + name + '_book]');
14   for (var i = 0; i < cboxes.length; i++) {
15     cboxes[i].checked = value;
16   }
17 }
18 // -->
19 </script>
20
21 #if $books_by_author
22   <form action="/download/" method="POST" style="height: 80%">
23   <table style="width: 100%; height: 90%">
24   <tr>
25   <td>&nbsp;</td>
26   #set $_ = $getattr($translations, 'ugettext', None) or $translations.gettext
27   #for $column in $columns
28     <td style="text-align: center">$cgi.escape($_($column))</td>
29   #end for
30   </tr>
31   #set $columns1 = $len($columns)+1
32   #for $anum, $author in $enumerate($sorted($books_by_author))
33     #set $series = None
34     #set $snum = 0
35     #set $books = $books_by_author[$author]
36     #for $book in $books
37     #if $book.series != $series
38     #set $series = $book.series
39     #set $snum += 1
40   <tr>
41   <td><input type=checkbox name="a${anum+1}_s${snum}"
42   onClick="toggleBooks(this.name, this.checked)"></td>
43   <td colspan="${columns1-1}"><b>
44   $author — <i>
45   #if $book.series
46 $cgi.escape($series, 1)#slurp
47   #else
48 Вне серий#slurp
49   #end if
50   </i></b></td>
51   </tr>
52     #end if
53   <tr>
54   <td><input type=checkbox name="a${anum+1}_s${snum}_books" value="$book.id"></td>
55   #for $column in $columns
56   #if $column in ('ser_no', 'size')
57   #set $style = ' style="text-align: right; width: 5ex"'
58   #else
59   #set $style = ''
60   #end if
61   <td$style>$cgi.escape(unicode($getattr($book, $column) or ''))</td>
62   #end for
63   </tr>
64     #end for
65   #end for
66   <tr>
67   <td colspan="$columns1" style="text-align: center"><input type="submit" value="Скачать"></td>
68   </tr>
69   </table>
70   </form>
71 #else
72   <p>Не найдено ни одной книги!</p>
73 #end if
74 #end def