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