]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac-new/parts/record/issues-db.tt2
LP#1778972: (follow-up) remove a NFPL-specific template
[Evergreen.git] / Open-ILS / src / templates / opac-new / 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         level_description = item.shift;
19         level_description.caption =
20             level_description.caption.replace('[\(\)]', '');
21
22         '<div class="rdetail-holding-group">';
23         prev_seoffset_list = seoffset_list.slice(0, ght_depth);
24         next_seoffset_list = seoffset_list.slice(0, ght_depth);
25
26         prev_seoffset_list.$ght_depth = prev_seoffset_list.$ght_depth - selimit;
27         IF prev_seoffset_list.$ght_depth < 0;
28             prev_seoffset_list.$ght_depth = 0;
29         END;
30
31         has_more = 0;
32         at_deepest_level = 0;
33
34         next_seoffset_list.$ght_depth = next_seoffset_list.$ght_depth + selimit;
35         IF item.0.units;
36             INCLUDE "opac/parts/record/copy_table.tt2" serial_holdings=item;
37             "<hr />";
38
39             at_deepest_level = 1;
40             IF NOT item.last.label;
41                 has_more = 1;
42             END;
43         ELSE;
44             FOREACH node IN item;
45                 IF NOT node.label;
46                     has_more = 1;
47                     LAST;
48                 END;
49
50                 IF node.value;
51                     ght_sepath.push(node.value);
52                     new_seoffsets = seoffset_list.slice(0, ght_depth);
53                     new_seoffsets.push(0);
54
55                     expand_link = mkurl(
56                         '', {'sepath' => ght_sepath, 'seoffset' => new_seoffsets},
57                         0, 'issues'
58                     );
59
60                     collapse_sepath = ght_sepath.slice(0, -2);
61                     IF collapse_sepath.size == 0;
62                         collapse_clear_params = ['sepath'];
63                     ELSE;
64                         collapse_clear_params = 0;
65                     END;
66
67                     collapse_link = mkurl(
68                         '', {
69                             'sepath' => collapse_sepath,
70                             'seoffset' => new_seoffsets.slice(0, -2)
71                         }, collapse_clear_params, 'issues'
72                     );
73
74                     "<div class='rdetail-holding-group'>";
75                     IF node.children.size;
76                         # TODO: make images or figure out a CSS trick or
77                         # something. I doubt we can count on all OPAC clients
78                         # having adequate fonts to cover these Unicode glyphs.
79                         "&#x25bc; <a href='"; collapse_link;
80                     ELSE;
81                         "&#x25ba; <a href='"; expand_link;
82                     END;
83                     "'>"; node.label; "</a></div>";
84
85                     IF node.children.size;
86                         ght_depth = ght_depth + 1;
87                         view.print(node.children);
88                         ght_depth = ght_depth - 1;
89                     END;
90
91                     waste = ght_sepath.pop;
92                 ELSE;
93                     "<div class='rdetail-holding-group'>"; node.label; "</div>";
94                     at_deepest_level = 1;
95                 END;
96             END;
97         END;
98
99         to_clear = 0;
100         new_sepath_end = ght_depth - 1;
101         IF new_sepath_end < 0;
102             to_clear = ['sepath'];
103             new_sepath = [];
104         ELSE;
105             new_sepath = expand_path.slice(0, ght_depth - 1);
106         END;
107
108         # So the "holdings" level of the tree is sorted ascending, while all
109         # the higher levels are sorted descending.  This seems weird until you
110         # look at it.  I dunno. I think it feels right.  It could be changed I
111         # guess.  Anyway, this means we have to be careful about which
112         # paging link we label "earlier" and which one we label "later."
113
114         next_link = ''; prev_link = '';
115         IF has_more;
116             next_link = '<a class="paging" href="' _
117                 mkurl('',{seoffset => next_seoffset_list, sepath => new_sepath},to_clear,'issues') _ '">LABEL_HERE</a>&nbsp; ';
118         END;
119         IF seoffset_list.$ght_depth > 0;
120             prev_link = '<a class="paging" href="' _
121                 mkurl('',{seoffset => prev_seoffset_list, sepath => new_sepath},to_clear,'issues') _ '">LABEL_HERE</a>&nbsp; ';
122         END;
123
124         IF at_deepest_level;
125             prev_link.replace('LABEL_HERE', '&laquo; ' _ l('Earlier issues'));
126             next_link.replace('LABEL_HERE', l('Later issues') _ ' &raquo;');
127         ELSE;
128             # XXX this is really bad for i18n (notice the sloppy pluralization),
129             # but then the middle layer for serials only knows English names
130             # for things like "month". There's a bigger problem to solve
131             # here...
132             caption = level_description.caption;
133             IF level_description.display_grouping == 'chron';
134                 caption = caption _ 's';
135             END;
136             next_link.replace(
137                 'LABEL_HERE',
138                 '&laquo; ' _ l('Earlier') _ ' ' _ caption
139             );
140             prev_link.replace(
141                 'LABEL_HERE',
142                 l('Later') _ ' ' _ caption _ ' &raquo;'
143             );
144         END;
145         '</div>';
146     END;
147 END;
148
149 VIEW holding_summary_tree;
150     BLOCK hash;
151         '<div class="rdetail-holding-group">';
152         ctx.get_aou(item.org_unit).name; "<br />";
153         FOREACH summary IN item.holding_summaries;
154             IF summary.holdings;
155                 twisty = '&#x25bc; ';
156                 link = mkurl(
157                     '', {},
158                     ['sid','stype','selimit','sepath','seoffset'], 'issues'
159                 );
160                 link_title = l('Collapse');
161             ELSE;
162                 twisty = '&#x25ba; ';
163                 link = mkurl(
164                     '', {sid => summary.id, stype => summary.summary_type},
165                     ['selimit','sepath','seoffset'], 'issues'
166                 );
167                 link_title = l('Expand');
168             END;
169             '<span>'; twisty;
170             '<a href="' _ link _ '" title="' _ link_title _ '">';
171             summary.generated_coverage.join(", ");
172             '</a></span><br />';
173             IF summary.holdings;
174                 grouped_holding_tree.print(summary.holdings);
175             END;
176         END;
177         FOREACH child IN item.children;
178             view.print(child);
179         END;
180         '</div>';
181     END;
182 END %]
183     <div class="holding-summary-tree">
184     [% holding_summary_tree.print(ctx.holding_summary_tree) %]
185     </div>
186     <div class="holding-summary-tree-pager">
187         [%  slimit = CGI.param('slimit') || 10;
188             soffset = CGI.param('soffset') || 0;
189             soffset_prev = soffset - slimit;
190             IF soffset_prev < 0; soffset_prev = 0; END;
191             soffset_next = soffset + slimit;
192         %]
193         [% IF soffset > 0 %]
194         <a href="[% mkurl('', {soffset => soffset_prev}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]>[% l('Previous') %]</a>
195         [% END %]
196         [% IF ctx.holding_summary_tree.more %]
197         <a href="[% mkurl('', {soffset => soffset_next}, ['sid','stype','sepath','selimit','seoffset'], 'issues') %]">[% l('Next') %]</a>
198         [% END %]
199     </div>