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