LP1907866 Bootstrap Opac: fix adding basket to existing List
[Evergreen.git] / Open-ILS / src / templates-bootstrap / opac / myopac / lists.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     WRAPPER "opac/parts/myopac/base.tt2";
4     myopac_page = "lists"
5     limit = ctx.bookbags_limit;
6     offset = ctx.bookbags_offset;
7     item_page = ctx.bookbags_item_page;
8     bb_publish_text = l(
9 "Sharing a list means that the contents " _
10 "of the list will be visible to others. " _
11 "To see the public view of a shared list, " _
12 "click on the HTML View link in the Saved Lists section.");
13 %]
14
15
16 <h3>[% l('My Lists') %]</h3>
17 <div id='myopac_bookbag_div'>
18
19     <!-- new list creation -->
20     <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post" id="create_form">
21         <h4>[% l('Create New List') %]</h4><a id="createnewlist"></a>
22         <table class="table" >
23             <tr>
24                 <td class="list_create_table_label">
25                     <label for="list_create_name">[% l('Enter the name of the new list:') %]</label>
26                 </td>
27                 <td class="px-3 my-2">
28                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
29                     <input id="list_create_name" type="text" name="name" class="form-control"/>
30                     <input type="hidden" name="action" value="create" class="form-control" />
31                     [% IF ctx.add_rec %]
32                     <input type="hidden" name="add_rec" value="[% ctx.add_rec %]" class="form-control" />
33                     [% END %]
34                     [% IF ctx.where_from %]
35                     <input type="hidden" name="where_from" value="[% ctx.where_from %]" class="form-control" />
36                     [% END %]
37                 </td>
38             </tr>
39             <tr>
40                 <td class="list_create_table_label">
41                     <label for="list_description">[% l("List description (optional):") %]</label>
42                 </td>
43                 <td class="px-3">
44                     <textarea name="description" id="list_description" class="form-control"></textarea>
45                 </td>
46             </tr>
47             <tr>
48                 <td class="list_create_table_label">
49                     <label for="list_create_shared">[% l('Share this list?') %]</label>
50                 </td>
51                 <td class="px-3">
52                     <select class="d-inline-block form-control mini-control" name="shared" id="list_create_shared">
53                         <option value="0">[% l('No') %]
54                         <option value="1">[% l('Yes') %]
55                     </select>
56                     <a href="#" title="Allows the list to be shared through a link or RSS." data-toggle="tooltip">
57                         <i class="fas fa-question-circle" aria-hidden="true"></i>
58                     </a>
59                 </td>
60             </tr>
61             [% IF ctx.mylist.size %]
62             <tr>
63                 <td class="list_create_table_label">
64                     <label for="list_move_cart">[% l('Move contents of basket to this list?') %]</label>
65                 </td>
66                 <td>
67                     <select class="d-inline-block form-control mini-control" name="move_cart" id="list_move_cart">
68                         <option value="0">[% l('No') %]
69                         <option value="1" [% IF CGI.param('move_cart_by_default') %]selected="selected"[% END%]>[% l('Yes') %]
70                     </select>
71                 </td>
72             </tr>
73             [% END %]
74             <tr>
75                 <td>&nbsp;</td>
76                 <td class="list-create-table-buttons">
77                                     <button type="submit" class="btn btn-confirm"><i class="fas fa-plus-square" aria-hidden="true"></i> [% l('Create List') %]</button>
78
79                     <button type="reset" class="btn btn-deny" ><i class="fas fa-ban" aria-hidden="true"></i> [% l('Cancel') %]</button>
80                 </td>
81             </tr>
82         </table>
83     </form>
84
85       [% IF (CGI.param('from_basket') && ctx.mylist.size)  %]
86     <h3>[% l("... from basket") %]</h3>
87     [% INCLUDE "opac/parts/anon_list.tt2" %]
88     [% ELSE %]
89     <h3>[% l("My Existing Basket and Lists") %]</h3>
90     [% INCLUDE "opac/parts/anon_list.tt2" %]
91
92     [% IF ctx.bookbags.size %]
93     <div class="header_middle">
94         <span class="float-left">[% l('Saved Lists') %]</span>
95         [% IF limit < ctx.bookbag_count; %]
96         <span class='float-left' style='padding-left: 10px;'>
97             [%- IF offset > 0 -%]
98                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
99                     offset => (offset - limit)
100                 }) %]'><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
101             [%- END; -%]
102             [%- IF (offset - (limit * 3)) >= 0 -%]
103                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
104                     offset => (offset - (limit * 3))
105                 }) %]'>[% ((offset - (limit * 3)) / limit) + 1 %]</a>
106             [%- END; -%]
107             [%- IF (offset - (limit * 2)) >= 0 -%]
108                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
109                     offset => (offset - (limit * 2))
110                 }) %]'>[% ((offset - (limit * 2)) / limit) + 1 %]</a>
111             [%- END; -%]
112             [%- IF (offset - limit) >= 0 -%]
113                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
114                     offset => (offset - limit)
115                 }) %]'>[% ((offset - limit) / limit) + 1 %]</a>
116             [%- END; -%]
117             <span class="bookbag-paginator-selected" >[% (offset / limit) + 1 %]</span>
118             [%- IF (offset + limit) < ctx.bookbag_count -%]
119                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
120                     offset => (offset + limit)
121                 }) %]'>[% ((offset + limit) / limit) + 1 %]</a>
122             [%- END; -%]
123             [%- IF (offset + (limit * 2)) < ctx.bookbag_count -%]
124                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
125                     offset => (offset + (limit * 2))
126                 }) %]'>[% ((offset + (limit * 2)) / limit) + 1 %]</a>
127             [%- END; -%]
128             [%- IF (offset + (limit * 3)) < ctx.bookbag_count -%]
129                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
130                     offset => (offset + (limit * 3))
131                 }) %]'>[% ((offset + (limit * 3)) / limit) + 1 %]</a>
132             [%- END; -%]
133             [%- IF (ctx.bookbag_count - offset) > limit; -%]
134                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
135                     offset => (offset + limit)
136                 }) %]'>[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
137             </span>
138             [%- END; -%]
139         [% END %]
140     </div>
141
142     <div id='acct_lists_prime'>
143         [% FOR bbag IN ctx.bookbags %]
144         <div>
145          <table class="table"><tr>
146             <td class="listTitleText">
147             <div class="bookbag-controls-title-block">
148                 [% baseurl = ctx.opac_root _ '/myopac/lists';
149                 IF bbag.id != CGI.param("bbid");
150                     url = mkurl(baseurl,{bbid => bbag.id, item_page => 1},['edit_notes','sort']);
151                     ltitle = l("Show items in list");
152                 ELSE;
153                     url = mkurl(baseurl, {}, ['bbid', 'edit_notes', 'sort']);
154                     ltitle = l("Hide items in list");
155                 END %]
156                 <h4 class="bookbag-name"><a title="[% ltitle %]" href="[% url %]">[% bbag.name | html %]</a>[% IF bbag.pub == 't'; %]
157                 <a target='_blank' href='/opac/extras/feed/bookbag/rss2-full/[% bbag.id %]' aria-label="RSS Feed">
158                 <i class="fas fa-rss-square" aria-hidden="true"></i></a>
159                 [% END %]</h4>
160                 [% IF bbag.description %]<div class="bookbag-description">[% bbag.description | html %]</div>[% END %]
161             </div>
162             </td>
163
164             <td>
165             [% IF ctx.add_rec %]
166             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update', {}, 1) %]" method="post">
167                 <div class="bookbag-controls">
168                     <input type="hidden" name="action" value="add_rec" />
169                     <input type="hidden" name="list" value="[% bbag.id %]" />
170                     <input type="hidden" name="add_rec" value="[% ctx.add_rec %]" />
171                     [% IF ctx.where_from %]
172                     <input type="hidden" name="where_from" value="[% ctx.where_from %]" />
173                     [% END %]
174                     <button class="fixed btn btn-success btn-sm m-1" type="submit" ><i class="fas fa-plus-square" aria-hidden="true"></i> [% l('Add to this list') %]</button>
175                 </div>
176             </form>
177             [% END %]
178             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
179                 <div class="bookbag-share">
180                     <input type="hidden" name="list" value="[% bbag.id %]" />
181                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
182                     [% IF bbag.pub != 't' %]
183                     <input type="hidden" name="action" value="show" />
184                     <button class="fixed btn btn-action btn-sm m-1" type="submit" ><i class="fas fa-share-square" aria-hidden="true"></i> [% l('Share') %]</button>
185                     [% ELSE %]
186                     <input type="hidden" name="action" value="hide" />
187                     <button class="fixed btn btn-secondary btn-sm m-1" type="submit"><i class="fas fa-eye-slash" aria-hidden="true"></i> [% l('Hide') %]</button>
188                     [% END %]
189                 </div>
190             </form>
191
192             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/print') %]" method="post">
193                 <div class="bookbag-controls">
194                     <input type="hidden" name="list" value="[% bbag.id %]" />
195                     <input type="hidden" name="sort" value="[% CGI.param('sort') | html %]" />
196                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
197                     <button type="submit" class="btn btn-action btn-sm m-1"><i class="fas fa-file-download" aria-hidden="true"></i> [% l('Download CSV') %]</button>
198                 </div>
199             </form>
200             [% setting = 'opac.default_list'; %]
201             <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
202                 <div class="bookbag-controls">
203                     <input type="hidden" name="list" value="[% bbag.id %]" />
204                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
205                     [% IF ctx.user_setting_map.$setting == bbag.id %]
206                     <input type="hidden" name="action" value="remove_default" />
207                     <button type="submit" class="btn btn-deny btn-sm m-1"><i class="fas fa-minus-circle" aria-hidden="true"></i> [% l('Remove Default List') %]</button>
208                     [% ELSE %]
209                     <input type="hidden" name="action" value="make_default" />
210                     <button type="submit" class="btn btn-action btn-sm m-1"><i class="fas fa-th-list" aria-hidden="true"></i> [% l('Make Default List') %]</button>
211                     [% END %]
212                 </div>
213             </form>
214             [% IF ctx.is_staff %]
215             <div class="bookbag-controls">
216                 <button
217                     type="submit"
218                     onclick='
219                        var path =
220                           "oils://remote/xul/server/cat/bucketz39_dialog.xul";
221                         window.openDialog(
222                             xulG.url_prefix(path),
223                             "bucketz39_dialog",
224                             "width=800,height=500",
225                             "[% ctx.user.id %]",
226                             "[% ctx.authtoken %]",
227                             "[% ctx.user.ws_ou %]",
228                             "[% bbag.id %]",
229                             xulG
230                         )'
231                     value="[% l('Locate Z39.50 Matches') %]"
232                 ><i class="fas fa-external-link-alt" aria-hidden="true"></i></button>
233             </div>
234             [% END %]
235             [% IF bbag.pub == 't'; %]
236             <div class="bookbag-controls">
237                 <a class="btn btn-sm btn-opac m-1" href='[%-
238                     mkurl(
239                         ctx.opac_root _ '/results',
240                         {page => '0', bookbag => bbag.id, depth => 0, locg => ctx.search_ou},
241                         1
242                     )
243                 -%]'><i class="fas fa-glasses" aria-hidden="true"></i> [% l('View in Catalogue') %]</a>
244
245             </div>
246                [% END %]
247                  <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post" onsubmit="return confirm('[% l('Do you really want to delete this list?') %]')">
248                 <div class="bookbag-controls float-right">
249                     <input type="hidden" name="list" value="[% bbag.id %]" />
250                     <input type="hidden" name="action" value="delete" />
251                     [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
252                     <button type="submit" class="btn btn-deny btn-sm m-1"><i class="fas fa-trash-alt" aria-hidden="true"></i> [% l('Delete List') %]</button>
253                 </div>
254             </form>
255             </td>
256             </tr>
257             </table>
258         </div>
259         [% IF CGI.param("bbid") == bbag.id %]
260
261         <div>
262         <h5 class="text-center my-2">List Items</h5>
263         <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post" >
264         <input type="hidden" name="list" value="[% bbag.id %]" />
265         <input type="hidden" name="sort" value="[% CGI.param('sort') | uri %]" />
266         <div>
267         [% IF bbag.items.size %]
268             <div class="my-2">
269                 <button name="action" class="btn btn-action" type="submit" value="place_hold" id="place_hold">[% l('Place hold') %]</button>
270                 <button name="action" class="btn btn-action" type="submit" value="print">[% l('Print title details') %]</button>
271                 <button name="action" class="btn btn-action" type="submit" value="email">[% l('Email title details') %]</button>
272                 <button name="action" class="btn btn-action" type="submit" value="del_item">[% l('Remove from list') %]</button>
273             </div>
274         [% END %]
275
276         <div>
277          <div class="d-block d-md-none">
278
279
280             <input id="check_all_list_items" checked="checked" type="checkbox" onclick="var inputs=document.getElementsByTagName('input');
281                         for (i = 0; i < inputs.length; i++) {
282                             if (inputs[i].name == 'selected_item' &amp;&amp; !inputs[i].disabled &amp;&amp; inputs[i].getAttribute('bbag') == [% bbag.id %])
283                                 inputs[i].checked = this.checked;}"/>
284
285             <label for="check_all_list_items">[% l('Check/Uncheck All') %]</label>
286         </div>
287         <table class="table table-hover miniTable w-100 bookbagTable">
288             <thead>
289                 <tr>
290                     <th class="list_checkbox">
291                     <input type="checkbox"
292                       onclick="var inputs=document.getElementsByTagName('input');
293                         for (i = 0; i < inputs.length; i++) {
294                             if (inputs[i].name == 'selected_item' &amp;&amp; !inputs[i].disabled &amp;&amp; inputs[i].getAttribute('bbag') == [% bbag.id %])
295                                 inputs[i].checked = this.checked;}"/>
296
297                     </th>
298                     <th class="list_entry">
299                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=> (CGI.param('sort') == 'titlesort' ? 'titlesort.descending' : 'titlesort')}) %]">[% l('Title') %]</a>
300                     </th>
301                     <th class="list_entry">
302                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=>(CGI.param('sort') == 'authorsort' ? 'authorsort.descending' : 'authorsort')}) %]">[% l('Author(s)') %]</a>
303                     </th>
304                     <th class='list_entry'>
305                         [% l('Local Call Number') %]
306                     </th>
307                     <th class="list_entry">
308                         <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {sort=>(CGI.param('sort') == 'pubdate' ? 'pubdate.descending' : 'pubdate')}) %]">[% l('Publication Date') %]</a>
309                     </th>
310                     <th class="list_entry">
311                          [% l('Format') %]
312                     </th>
313                     <th class="list_entry">
314                         [% l('Notes') %]
315                         [% IF CGI.param("edit_notes") != bbag.id %]
316                         | <a href="[% mkurl(ctx.opac_root _ '/myopac/lists', {edit_notes=> bbag.id}) %]">[% l('Edit') %]</a>
317                         [% END %]
318                     </th>
319                 </tr>
320             </thead>
321             <tbody>
322                 [% UNLESS bbag.items.size %]
323                 <tr><td colspan="6" class="list_is_empty">
324                     [% l("This list contains no items.") %]
325                 </td></tr>
326                 [% END %]
327                 [% FOR item IN bbag.items;
328                     rec_id = item.target_biblio_record_entry.id;
329                     attrs = {marc_xml => ctx.bookbags_marc_xml.$rec_id};
330                     PROCESS get_marc_attrs args=attrs %]
331                 <tr class="bookbag-item-row">
332                     <td class="list_checkbox">
333                         <input type="checkbox" name="selected_item" value="[% item.id %]" bbag='[% bbag.id %]'/>
334                     </td>
335                     <td class="list_entry" data-label="[% l('Title') %]">
336                         <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec_id, {}, ['edit_notes', 'bbid']) %]">[% attrs.title | html %]</a>
337                     </td>
338                     <td class="list_entry" data-label="[% l('Author(s)') %]">
339                         <a href="[%-
340                             authorquery = attrs.author | replace('[,\.:;]', '');
341                             mkurl(ctx.opac_root _ '/results', {qtype => 'author', query => authorquery}, ['page', 'bbid', 'edit_notes'])
342                             -%]">[% attrs.author | html %]</a>
343                     </td>
344                     <td class="list_entry" data-label="[% l('Local Call Number') %]">
345                         [%
346                             copy = attrs.holdings.0;
347                             IF copy;
348                                 # only show a relevant call number
349                                 copy_org = ctx.get_aou_by_shortname(copy.owner);
350                                 FOR ctx_org IN [ctx.pref_ou, ctx.search_ou, ctx.home_ou, ctx.physical_loc];
351                                     NEXT UNLESS ctx_org;
352                                     ctx_org = ctx.get_aou(ctx_org);
353                                     IF ctx.org_within_scope(ctx_org, copy_org, ctx_org.ou_type.depth);
354                                         l('[_1] ([_2])', copy.label, copy_org.name) | html;
355                                         LAST;
356                                     END;
357                                 END;
358                             END;
359                         %]
360                     </td>
361                     <td class="list_entry" data-label="[% l('Publication Date') %]">
362                           [% attrs.pubdate | html %]
363                     </td>
364                     <td class="list_entry" data-label="[% l('Format') %]">
365                           [% attrs.format_label | html %]
366                     </td>
367                     [% IF CGI.param("edit_notes") == bbag.id %]
368                     <td class="list_entry" data-label="[% l('Notes') %]">
369                         [% FOR note IN item.notes %]
370                         <input type="text" name="note-[% note.id %]" value="[% note.note | html %]" />
371                         [% END %]
372                         <input type="text" name="item-[% item.id %]" />
373                     </td>
374                     [% ELSE %]
375                     <td class="list_entry" data-label="[% l('Notes') %]">
376                         [% FOR note IN item.notes %]
377                         <div>[% note.note | html %]</div>
378                         [% END %]
379                     </td>
380                     [% END %]
381                 </tr>
382                 [% END %]
383                 [% IF CGI.param("edit_notes") == bbag.id %]
384                 <tr class="mobile_hide">
385                     <td colspan="6"><!-- All space left of notes column --></td>
386                     <td class="save-notes">
387                         [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
388                         <input type="hidden" name="bbid" value="[% CGI.param('bbid') | html %]" />
389                         <button type="submit" class="btn btn-confirm" ><i class="fas fa-save" aria-hidden="true"></i> [% l('Save Notes') %]</button>
390                     </td>
391                 </tr>
392                 [% END %]
393             </tbody>
394         </table>
395         </div>
396
397
398
399
400         [% IF ctx.bb_page_count > 1; %]
401             <div class="header_middle" style="padding-top:7px;">
402                 <div class="bbag-navigate-list">[% l('Navigate Selected List ') %]</div>
403                 <div class="bbag-navigate-list-pages">
404                     [%- IF item_page > 1 -%]
405                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
406                             item_page => item_page - 1
407                         }) %]'><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
408                     [%- END; -%]
409
410                     [%- IF (item_page - 3) >= 1 -%]
411                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
412                             item_page => item_page - 3
413                         }) %]'>[% item_page - 3 %]</a>
414                     [%- END; -%]
415                     [%- IF (item_page - 2) >= 1 -%]
416                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
417                             item_page => item_page - 2
418                         }) %]'>[% item_page - 2 %]</a>
419                     [%- END; -%]
420                     [%- IF (item_page - 1) >= 1 -%]
421                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
422                             item_page => item_page - 1
423                         }) %]'>[% item_page - 1%]</a>
424                     [%- END; -%]
425                     <span class="bookbag-paginator-selected" >[% item_page %]</span>
426                     [%- IF (item_page + 1) <= ctx.bb_page_count -%]
427                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
428                             item_page => item_page + 1
429                         }) %]'>[% item_page + 1 %]</a>
430                     [%- END; -%]
431                     [%- IF (item_page + 2) <= ctx.bb_page_count -%]
432                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
433                             item_page => item_page + 2
434                         }) %]'>[% item_page + 2 %]</a>
435                     [%- END; -%]
436                     [%- IF (item_page + 3) <= ctx.bb_page_count -%]
437                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
438                             item_page => item_page + 3
439                         }) %]'>[% item_page + 3 %]</a>
440                     [%- END; -%]
441
442                     [%- IF (item_page + 1) <= ctx.bb_page_count; -%]
443                         <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
444                             item_page => item_page + 1
445                         }) %]'>[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
446                     [%- END; -%]
447                  </div>
448             </div>
449         [% END %]
450         <br/>
451  </div></div>
452         </form>
453         </div>
454         [% END %]
455         [% END %]
456     </div>
457     [% END %][% END %]
458 </div>
459
460 [% END %]
461