]> git.phdru.name Git - m_librarian.git/blob - m_librarian/web/views/list_books.tmpl
Docs: Update TODO
[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(selector, value) {
12   cboxes = document.querySelectorAll(selector);
13   for (var i = 0; i < cboxes.length; i++) {
14     cboxes[i].checked = value;
15   }
16 }
17
18 function toggleAll(value) {
19   toggleBooks('input[type=checkbox]', value);
20 }
21
22 function toggleAuthor(name, value) {
23   toggleBooks('input[type=checkbox][name^=' + name + ']', value);
24 }
25
26 function toggleSeries(name, value) {
27   toggleBooks('input[type=checkbox][name^=' + name + '_book]', value);
28 }
29 // -->
30 </script>
31
32 #if $books_by_author
33   <form action="/download/" method="POST" style="height: 80%">
34   <table style="width: 100%; height: 90%">
35   <tr>
36   <td><input type=checkbox name="_toggleAll"
37   onClick="toggleAll(this.checked)"></td>
38   #set $_ = $getattr($translations, 'ugettext', None) or $translations.gettext
39   #for $column in $columns
40     <td style="text-align: center">$cgi.escape($_($column))</td>
41   #end for
42   </tr>
43   #set $columns1 = $len($columns)+1
44   #for $anum, $author in $enumerate($sorted($books_by_author))
45     #set $series = None
46     #set $snum = 0
47     #set $books = $books_by_author[$author]
48   <tr>
49   <td><input type=checkbox name="a${anum+1}_"
50   onClick="toggleAuthor(this.name, this.checked)"></td>
51   <td colspan="${columns1-1}"><b>$author</b></td>
52   </tr>
53     #for $book in $books
54     #if $book.series != $series
55     #set $series = $book.series
56     #set $snum += 1
57   <tr>
58   <td><input type=checkbox name="a${anum+1}_s${snum}"
59   onClick="toggleSeries(this.name, this.checked)"></td>
60   <td colspan="${columns1-1}"><b>
61   $author — <i>
62   #if $book.series
63 $cgi.escape($series, 1)#slurp
64   #else
65 Вне серий#slurp
66   #end if
67   </i></b></td>
68   </tr>
69     #end if
70   <tr>
71   <td><input type=checkbox name="a${anum+1}_s${snum}_books" value="$book.id"></td>
72   #for $column in $columns
73   #if $column in ('ser_no', 'size')
74   #set $style = ' style="text-align: right; width: 5ex"'
75   #else
76   #set $style = ''
77   #end if
78   <td$style>$cgi.escape(unicode($getattr($book, $column) or ''))</td>
79   #end for
80   </tr>
81     #end for
82   #end for
83   <tr>
84   <td colspan="$columns1" style="text-align: center"><input type="submit" value="Скачать"></td>
85   </tr>
86   </table>
87   </form>
88 #else
89   <p>Не найдено ни одной книги!</p>
90 #end if
91 #end def