Bug 30952: Staff interface redesign (header)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / library_groups.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaSpan %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Library groups &rsaquo; Administration &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
9 </head>
10
11 <body id="admin_library_groups" class="admin">
12 [% WRAPPER 'header.inc' %]
13     [% INCLUDE 'cat-search.inc' %]
14 [% END %]
15
16 [% WRAPPER 'sub-header.inc' %]
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
18     <ol>
19         <li>
20             <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
21         </li>
22         <li>
23             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
24         </li>
25         <li>
26             <a href="#" aria-current="page">Library groups</a>
27         </li>
28     </ol>
29 </nav>
30 [% END %]
31
32 [% FOR m IN messages %]
33     <div class="dialog [% m.type | html %]">
34         [% SWITCH m.code %]
35         [% CASE 'error_on_insert' %]
36             <span>An error occurred when adding this library. The library id might already exist in this group.</span>
37         [% CASE %]
38             <span>[% m.code | html %]</span>
39         [% END %]
40     </div>
41 [% END %]
42
43 [% IF added %]
44     <div class="dialog message group-added">
45         [% IF added.branchcode %]
46             <span>[% added.library.branchname | html | $KohaSpan class = 'name' %] added to group.</span>
47         [% ELSE %]
48             <span>Group [% added.title | html | $KohaSpan class = 'name' %] created.</span>
49         [% END %]
50     </div>
51 [% ELSIF deleted %]
52     <div class="dialog message group-deleted">
53         [% IF deleted.title %]
54             <span>Group [% deleted.title | html | $KohaSpan class = 'name' %] has been deleted.</span>
55         [% ELSE %]
56             <span>[% deleted.library | html | $KohaSpan class = 'name' %] has been removed from group.</span>
57         [% END %]
58     </div>
59 [% ELSIF error_duplicate_title %]
60     <div class="dialog alert error-duplicate-group-title">
61             A group with the title [% error_duplicate_title | html | $KohaSpan class = 'name' %] already exists.
62     </div>
63 [% END %]
64
65 <div class="main container-fluid">
66     <div class="row">
67         <div class="col-sm-10 col-sm-push-2">
68             <main>
69
70                     <div id="toolbar" class="btn-toolbar">
71                         <div class="btn-group">
72                             <a id="add-group-root" class="btn btn-default add-group" href="#">
73                                 <i class="fa fa-plus"></i> Add group
74                             </a>
75                         </div>
76                     </div>
77
78                 <h1>Library groups</h1>
79
80                 [% FOREACH root_group IN root_groups %]
81                     <table class="library-groups">
82                         <tr>
83                             <th>&nbsp;</th>
84                             <th>Description</th>
85                             <th>Features enabled</th>
86                             <th>&nbsp;</th>
87                         </tr>
88                         [% PROCESS tree group=root_group %]
89                     </table>
90                 [% END %]
91
92             </main>
93         </div> <!-- /.col-sm-10.col-sm-push-2 -->
94
95         <div class="col-sm-2 col-sm-pull-10">
96             <aside>
97                 [% INCLUDE 'admin-menu.inc' %]
98             </aside>
99         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
100     </div> <!-- /.row -->
101
102     <div id="add-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="add-group-modal-label" aria-hidden="true">
103         <form id="add-group-form" action="/cgi-bin/koha/admin/library_groups.pl" class="form-horizontal">
104             <div class="modal-dialog">
105                 <div class="modal-content">
106                     <div class="modal-header">
107                         <h3 id="add-group-modal-label">Add group</h3>
108                     </div>
109                     <div class="modal-body">
110                         <fieldset class="rows">
111                             <input type="hidden" id="add-group-modal-parent-id" name="parent_id" value="" />
112                             <input type="hidden" id="add-group-modal-action" name="action" value="add">
113                             <ol>
114                                 <li>
115                                     <label for="add-group-modal-title">Title: </label>
116                                     <input type="text" size="40" maxlength="100" name="title" id="add-group-modal-title" required="required" />
117                                     <span class="required">Required</span>
118                                     <div class="hint">Displayed in the library group search dropdowns.</div>
119                                 </li>
120                                 <li>
121                                     <label for="add-group-modal-description">Description: </label>
122                                     <input type="text" size="40" name="description" id="add-group-modal-description" />
123                                 </li>
124                             </ol>
125                         </fieldset>
126                         <div id="root-group-features-add">
127                             <h3>Features</h3>
128                             <div class="checkbox">
129                                 <p>
130                                     <label>
131                                         <input type="checkbox" name="ft_hide_patron_info" id="add-group-modal-ft_hide_patron_info" value="1" />
132                                         Limit patron data access by group
133                                     </label>
134                                 </p>
135                                 <p>
136                                     <label>
137                                         <input type="checkbox" name="ft_search_groups_opac" id="add-group-modal-ft_search_groups_opac" value="1" />
138                                         Use for OPAC search groups
139                                     </label>
140                                 </p>
141                                 <p>
142                                     <label>
143                                         <input type="checkbox" name="ft_search_groups_staff" id="add-group-modal-ft_search_groups_staff" value="1" />
144                                         Use for staff search groups
145                                     </label>
146                                 </p>
147                                 <p>
148                                     <label>
149                                         <input type="checkbox" name="ft_local_hold_group" id="add-group-modal-ft_local_hold_group" value="1" />
150                                         Is local hold group
151                                     </label>
152                                 </p>
153                             </div>
154                         </div>
155                     </div>
156                     <div class="modal-footer">
157                         <button type="submit" class="btn btn-default">Save</button>
158                         <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
159                     </div>
160                 </div>
161             </div>
162         </form>
163     </div>
164
165     <div id="edit-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="edit-group-modal-label" aria-hidden="true">
166         <form id="edit-group-form" action="/cgi-bin/koha/admin/library_groups.pl" class="form-horizontal">
167             <div class="modal-dialog">
168                 <div class="modal-content">
169                     <div class="modal-header">
170                         <h3 id="edit-group-modal-label">Edit group</h3>
171                     </div>
172                     <div class="modal-body">
173                         <input type="hidden" id="edit-group-modal-id" name="id" value="" />
174                         <input type="hidden" id="edit-group-modal-action" name="action" value="edit" />
175                         <fieldset class="rows">
176                             <ol>
177                                 <li>
178                                     <label for="edit-group-modal-title">Title: </label>
179                                     <input type="text" size="40" maxlength="100" id="edit-group-modal-title" name="title" value="" required="required" />
180                                     <span class="required">Required</span>
181                                     <div class="hint">Displayed in the library group search dropdowns.</div>
182                                 </li>
183
184                                 <li>
185                                     <label for="edit-group-modal-description">Description: </label>
186                                     <input type="text" size="40" id="edit-group-modal-description" name="description" value="" />
187                                 </li>
188                             </ol>
189                         </fieldset>
190                         <div id="root-group-features-edit">
191                             <h3>Features</h3>
192                             <div class="checkbox">
193                                 <p>
194                                     <label>
195                                         <input type="checkbox" id="edit-group-modal-ft_hide_patron_info" name="ft_hide_patron_info" value="1" />
196                                         Limit patron data access by group
197                                     </label>
198                                 </p>
199                                 <p>
200                                     <label>
201                                         <input type="checkbox" id="edit-group-modal-ft_search_groups_opac" name="ft_search_groups_opac" value="1" />
202                                         Use for OPAC search groups
203                                     </label>
204                                 </p>
205                                 <p>
206                                     <label>
207                                         <input type="checkbox" id="edit-group-modal-ft_search_groups_staff" name="ft_search_groups_staff" value="1" />
208                                         Use for staff search groups
209                                     </label>
210                                 </p>
211                                 <p>
212                                     <label>
213                                         <input type="checkbox" id="edit-group-modal-ft_local_hold_group" name="ft_local_hold_group" value="1" />
214                                         Is local hold group
215                                     </label>
216                                 </p>
217                             </div>
218                         </div>
219                     </div>
220                     <div class="modal-footer">
221                         <button type="submit" class="btn btn-default">Update</button>
222                         <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
223                     </div>
224                 </div>
225             </div>
226         </form>
227     </div>
228
229     <div id="delete-group-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete-group-modal-label" aria-hidden="true">
230         <form action="/cgi-bin/koha/admin/library_groups.pl">
231             <div class="modal-dialog">
232                 <div class="modal-content">
233                     <input id="delete-group-modal-action" type="hidden" name="action" value="delete" />
234                     <input id="delete-group-modal-id" type="hidden" name="id" value="" />
235                     <div class="modal-header">
236                         <h3 id="delete-group-modal-label">Delete group</h3>
237                     </div>
238                     <div class="modal-body">
239                         Are you sure you want to delete <span id="delete-group-modal-title" class="name"></span>?
240                     </div>
241                     <div class="modal-footer">
242                         <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Delete</button>
243                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
244                     </div>
245                 </div>
246             </div>
247         </form>
248     </div>
249
250     <div id="remove-library-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="remove-library-modal-label" aria-hidden="true">
251         <form action="/cgi-bin/koha/admin/library_groups.pl">
252             <div class="modal-dialog">
253                 <div class="modal-content">
254                     <input id="remove-library-modal-action" type="hidden" name="action" value="delete" />
255                     <input id="remove-library-modal-id" type="hidden" name="id" value="" />
256                     <div class="modal-header">
257                         <h3 id="remove-library-modal-label">Remove library from group</h3>
258                     </div>
259                     <div class="modal-body">
260                         Are you sure you want to remove <span id="remove-library-modal-library" class="name"></span> from <span id="remove-library-modal-group" class="name"></span>?
261                     </div>
262                     <div class="modal-footer">
263                         <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Remove</button>
264                         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
265                     </div>
266                 </div>
267             </div>
268         </form>
269     </div>
270
271 [% MACRO jsinclude BLOCK %]
272     [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
273     <script>
274         $(document).ready(function() {
275             $('.library-groups').treetable({
276                 expandable: true,
277                 initialState: 'expanded',
278                 clickableNodeNames: true,
279             });
280
281             $('.add-group').on('click', function(e) {
282                 e.preventDefault();
283                 var id = $(this).data('groupId');
284                 add_group( id );
285             });
286
287             $('.edit-group').on('click', function(e) {
288                 e.preventDefault();
289                 var id = $(this).data('groupId');
290                 var parent_id = $(this).data('groupParentId');
291                 var title = $(this).data('groupTitle');
292                 var description = $(this).data('groupDescription');
293                 var ft_hide_patron_info = $(this).data('groupFt_hide_patron_info');
294                 var ft_search_groups_opac = $(this).data('groupFt_search_groups_opac');
295                 var ft_search_groups_staff = $(this).data('groupFt_search_groups_staff');
296                 var ft_local_hold_group = $(this).data('groupFt_local_hold_group');
297                 edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group );
298             });
299
300             $('.delete-group').on('click', function(e) {
301                 e.preventDefault();
302                 var id = $(this).data('groupId');
303                 var title = $(this).data('groupTitle');
304                 delete_group( id, title );
305             });
306
307             $('.remove-library').on('click', function(e) {
308                 e.preventDefault();
309                 var id = $(this).data('groupId');
310                 var library = $(this).data('groupLibrary');
311                 var parent_title = $(this).data('groupParentTitle');
312                 remove_library( id, library, parent_title );
313             });
314             $('#add-group-modal').on('shown.bs.modal', function() {
315                 $('#add-group-modal-title').focus();
316             });
317             $('#edit-group-modal').on('shown.bs.modal', function() {
318                 $('#edit-group-modal-title').focus();
319             });
320         });
321
322         function add_group( parent_id ) {
323             $('#add-group-modal-parent-id').val( parent_id );
324
325             $('#add-group-modal-description').val("");
326             $('#add-group-modal-title').val("");
327
328
329             $('#add-group-modal-ft_hide_patron_info').prop('checked', false);
330             $('#add-group-modal-ft_search_groups_opac').prop('checked', false);
331             $('#add-group-modal-ft_search_groups_staff').prop('checked', false);
332             $('#add-group-modal-ft_local_hold_group').prop('checked', false);
333             if ( parent_id ) {
334                 $('#root-group-features-add').hide();
335             } else {
336                 $('#root-group-features-add').show();
337             }
338             $('#add-group-modal').modal('show');
339
340         }
341
342         function edit_group( id, parent_id, title, description, ft_hide_patron_info, ft_search_groups_opac, ft_search_groups_staff, ft_local_hold_group ) {
343             $('#edit-group-modal-id').val( id );
344             $('#edit-group-modal-title').val( title );
345             $('#edit-group-modal-description').val( description );
346
347             if ( parent_id ) {
348                 $('#edit-group-modal-ft_hide_patron_info').prop('checked', false);
349                 $('#edit-group-modal-ft_search_groups_opac').prop('checked', false);
350                 $('#edit-group-modal-ft_search_groups_staff').prop('checked', false);
351                 $('#edit-group-modal-ft_local_hold_group').prop('checked', false);
352                 $('#root-group-features-edit').hide();
353             } else {
354                 $('#edit-group-modal-ft_hide_patron_info').prop('checked', ft_hide_patron_info ? true : false );
355                 $('#edit-group-modal-ft_search_groups_opac').prop('checked', ft_search_groups_opac ? true : false );
356                 $('#edit-group-modal-ft_search_groups_staff').prop('checked', ft_search_groups_staff ? true : false );
357                 $('#edit-group-modal-ft_local_hold_group').prop('checked', ft_local_hold_group ? true : false );
358                 $('#root-group-features-edit').show();
359             }
360
361             $('#edit-group-modal').modal('show');
362         }
363
364         function delete_group( id, title ) {
365             $('#delete-group-modal-title').text( title );
366             $('#delete-group-modal-id').val( id );
367             $('#delete-group-modal').modal('show');
368         }
369
370         function remove_library( id, library, parent_title ) {
371             $('#remove-library-modal-library').text( library );
372             $('#remove-library-modal-group').text( parent_title );
373             $('#remove-library-modal-id').val( id );
374             $('#remove-library-modal').modal('show');
375         }
376
377     </script>
378 [% END %]
379
380 [% INCLUDE 'intranet-bottom.inc' %]
381
382 [% BLOCK tree %]
383     <tr data-tt-id="[% group.id | html %]" data-tt-parent-id="[% group.parent_id | html %]">
384         <td>
385             [% IF group.branchcode %]
386                 [% group.branchcode | html %]
387             [% ELSE %]
388                 [% group.title | html %]
389             [% END %]
390         </td>
391         <td>
392             [% IF group.branchcode %]
393                 [% group.library.branchname | html %]
394             [% ELSE %]
395                 [% group.description | html %]
396             [% END %]
397         </td>
398         <td>
399             [% UNLESS group.branchcode %]
400               <ul>
401                 [% IF group.ft_hide_patron_info %]
402                     <li>Hide patron's info for librarians outside of this group.</li>
403                 [% END %]
404                 [% IF group.ft_search_groups_opac %]
405                     <li>Use for OPAC search groups</li>
406                 [% END %]
407                 [% IF group.ft_search_groups_staff %]
408                     <li>Use for staff search groups</li>
409                 [% END %]
410                 [% IF group.ft_local_hold_group %]
411                     <li>Is local hold group</li>
412                 [% END %]
413               </ul>
414             [% END %]
415         </td>
416         <td>
417             [% IF group.branchcode %]
418                 <button class="btn btn-default btn-xs remove-library" data-group-id="[% group.id | html %]" data-group-library="[% group.library.branchname | html %]" data-group-parent-title="[% group.parent.title | html %]" ><i class="fa fa-trash"></i> Remove from group</button>
419             [% ELSE %]
420                 <div class="btn-group">
421                     <button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> Actions <span class="caret"></span></button>
422                     <ul class="dropdown-menu">
423                         <li>
424                             <a id="add-group-[% group.id | html %]" href="#" class="add-group" data-group-id="[% group.id | html %]">
425                                 <i class="fa fa-plus"></i> Add sub-group
426                             </a>
427                        </li>
428
429                         <li>
430                             <a class="edit-group" id="edit-group-[% group.id | html %]" href="#" data-group-id="[% group.id | html %]" data-group-parent-id="[% group.parent_id | html %]" data-group-title="[% group.title | html %]" data-group-description="[% group.description | html %]" data-group-ft_hide_patron_info="[% group.ft_hide_patron_info | html %]" data-group-ft_search_groups_opac="[% group.ft_search_groups_opac | html %]" data-group-ft_search_groups_staff="[% group.ft_search_groups_staff | html %]" data-group-ft_local_hold_group="[% group.ft_local_hold_group | html %]" >
431                                 <i class="fa fa-pencil"></i> Edit
432                             </a>
433                        </li>
434
435                         <li>
436                             <a class="delete-group" id="delete-group-[% group.id | html %]" href="#" data-group-id="[% group.id | html %]" data-group-title="[% group.title | html %]">
437                                 <i class="fa fa-trash"></i> Delete
438                             </a>
439                        </li>
440                     </ul>
441                 </div>
442
443                 <div class="btn-group">
444                     <button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> Add library <span class="caret"></span></button>
445                     <ul class="dropdown-menu">
446                         [% FOREACH library IN group.libraries_not_direct_children %]
447                             <li>
448                                 <a class="add-library" id="add-library[% library.id | html %]-[% group.id | html %]" href="/cgi-bin/koha/admin/library_groups.pl?action=add&parent_id=[% group.id | html %]&branchcode=[% library.id | html %]">
449                                     [% library.branchname | html %]
450                                 </a>
451                            </li>
452                         [% END %]
453                     </ul>
454                 </div>
455             [% END %]
456         </td>
457     </tr>
458
459     [% FOREACH g IN group.children %]
460         [% PROCESS tree group=g %]
461     [% END %]
462 [% END %]