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