]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/issues-db.tt2
TPAC: Improvement to serials display (under the "issues held" label)
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / record / issues-db.tt2
1 [%-
2 expand_path = CGI.param('sepath') || [];
3 expand_path = expand_path.list; # sic
4
5 seoffset_list = CGI.param('seoffset') || [];
6 seoffset_list = seoffset_list.list; # sic
7
8 IF expand_path.size == 0 AND seoffset_list.size == 0;
9     seoffset_list = [0,0]; # compensate for $auto_expand_first; see ML
10 END;
11
12 selimit = CGI.param('selimit') || 10;
13 ght_sepath = [];
14 ght_depth = 0;
15
16 VIEW grouped_holding_tree;
17     BLOCK list;
18         '<div class="rdetail-holding-group">';
19         prev_seoffset_list = seoffset_list.slice(0, ght_depth);
20         next_seoffset_list = seoffset_list.slice(0, ght_depth);
21
22         prev_seoffset_list.$ght_depth = prev_seoffset_list.$ght_depth - selimit;
23         IF prev_seoffset_list.$ght_depth < 0;
24             prev_seoffset_list.$ght_depth = 0;
25         END;
26
27         next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit;
28         IF item.0.units.size;
29             INCLUDE "opac/parts/record/copy_table.tt2" serial_holdings=item;
30             "<hr />";
31             "</div>";
32         ELSE;
33             FOREACH node IN item;
34                 IF NOT node.label;
35                     has_more = 1;
36                     LAST;
37                 END;
38
39                 IF node.value;
40                     ght_sepath.push(node.value);
41                     new_seoffsets = seoffset_list.slice(0, ght_depth);
42                     new_seoffsets.push(0);
43
44                     expand_link = mkurl(
45                         '', {'sepath' => ght_sepath, 'seoffset' => new_seoffsets},
46                         0, 'issues'
47                     );
48
49                     collapse_sepath = ght_sepath.slice(0, -2);
50                     IF collapse_sepath.size == 0;
51                         collapse_clear_params = ['sepath'];
52                     ELSE;
53                         collapse_clear_params = 0;
54                     END;
55
56                     collapse_link = mkurl(
57                         '', {
58                             'sepath' => collapse_sepath,
59                             'seoffset' => new_seoffsets.slice(0, -2)
60                         }, collapse_clear_params, 'issues'
61                     );
62
63                     "<div class='rdetail-holding-group'>";
64                     IF node.children.size;
65                         # TODO: make images or figure out a CSS trick or
66                         # something. I doubt we can count on all OPAC clients
67                         # having adequate fonts to cover these Unicode glyphs.
68                         "&#x25bc; <a href='"; collapse_link;
69                     ELSE;
70                         "&#x25ba; <a href='"; expand_link;
71                     END;
72                     "'>"; node.label; "</a></div>";
73
74                     IF node.children.size;
75                         ght_depth = ght_depth + 1;
76                         view.print(node.children);
77                         ght_depth = ght_depth - 1;
78                     END;
79
80                     waste = ght_sepath.pop;
81                 ELSE;
82                     "<div class='rdetail-holding-group'>"; node.label; "</div>";
83                     # XXX Hold placement link here? Maybe not if no units.
84                 END;
85             END;
86
87             to_clear = 0;
88             new_sepath_end = ght_depth - 1;
89             IF new_sepath_end < 0;
90                 to_clear = ['sepath'];
91                 new_sepath = [];
92             ELSE;
93                 new_sepath = expand_path.slice(0, ght_depth - 1);
94             END;
95
96             IF has_more;
97                 '<a class="paging" href="';
98                     mkurl('',{seoffset => next_seoffset_list, sepath => new_sepath},to_clear,'issues');
99                 '">&laquo; '; l('Earlier holdings'); '</a>';
100             END;
101             IF seoffset_list.$ght_depth > 0;
102                 '<a class="paging" href="';
103                     mkurl('',{seoffset => prev_seoffset_list, sepath => new_sepath},to_clear,'issues');
104                 '">'; l('Later holdings'); ' &raquo;</a>&nbsp; ';
105             END;
106             '</div>';
107         END;
108     END;
109 END;
110
111 VIEW holding_summary_tree;
112     BLOCK hash;
113         '<div class="rdetail-holding-group">';
114         ctx.get_aou(item.org_unit).name; "<br />";
115         FOREACH summary IN item.holding_summaries;
116             IF summary.holdings;
117                 twisty = '&#x25bc; ';
118                 link = mkurl(
119                     '', {},
120                     ['sid','stype','selimit','sepath','seoffset'], 'issues'
121                 );
122                 link_title = l('Collapse');
123             ELSE;
124                 twisty = '&#x25ba; ';
125                 link = mkurl(
126                     '', {sid => summary.id, stype => summary.summary_type},
127                     ['selimit','sepath','seoffset'], 'issues'
128                 );
129                 link_title = l('Expand');
130             END;
131             '<span>'; twisty;
132             '<a href="' _ link _ '" title="' _ link_title _ '">';
133             summary.generated_coverage.join(", ");
134             '</a></span><br />';
135             IF summary.holdings;
136                 grouped_holding_tree.print(summary.holdings);
137             END;
138         END;
139         FOREACH child IN item.children;
140             view.print(child);
141         END;
142         '</div>';
143     END;
144 END %]
145     <div class="holding-summary-tree">
146     [% holding_summary_tree.print(ctx.holding_summary_tree) %]
147     </div>
148     <div class="holding-summary-tree-pager">
149         [%  slimit = CGI.param('slimit') || 10;
150             soffset = CGI.param('soffset') || 0;
151             soffset_prev = soffset - slimit;
152             IF soffset_prev < 0; soffset_prev = 0; END;
153             soffset_next = soffset + slimit;
154         %]
155         [% IF soffset > 0 %]
156         <a href="[% mkurl('', {soffset => soffset_prev}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]>[% l('Previous') %]</a>
157         [% END %]
158         [% IF ctx.holding_summary_tree.more %]
159         <a href="[% mkurl('', {soffset => soffset_next}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]">[% l('Next') %]</a>
160         [% END %]
161     </div>