Bug 16238: Use .prop() instead of .attr() for 'checked'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member-flags.tt
blob37fa3f2e684ee09b19478b667e4315e8927935f2
1 [% PROCESS 'permissions.inc' %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha &rsaquo; Patrons &rsaquo; Set permissions for [% surname %], [% firstname %]</title>
4 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/treeview/jquery.treeview.css"/>
5 [% INCLUDE 'doc-head-close.inc' %]
6 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.treeview.pack.js"></script>
7 <!-- set up tree -->
8 <script type="text/javascript">
9     $(document).ready(function() {
10         $("#permissionstree").treeview({animated: "fast", collapsed: true});
12         // Enforce Superlibrarian Privilege Mutual Exclusivity
13         if($('input[id="flag-0"]:checked').length){
14             if ($('input[name="flag"]:checked').length > 1){
15                 alert('Inconsistency Detected!\n\nThe superlibrarian privilege is mutually exclusive of other privileges, as it includes them all.\n\nThis patron\'s privileges will now be reset to include only superlibrarian.');
16             }
18             $('input[name="flag"]').each(function() {
19                 if($(this).attr('id') != "flag-0"){
20                     $(this).attr('disabled', 'disabled');
21                     $(this).prop('checked', false);
22                 }
23             });
24         }
26         $('input#flag-0').click(function() {
27             if($('input[id="flag-0"]:checked').length){
28                 $('input[name="flag"]').each(function() {
29                     if($(this).attr('id') != "flag-0"){
30                         $(this).attr('disabled', 'disabled');
31                         $(this).prop('checked', false);
32                     }
33                 });
34             }
35             else {
36                 $('input[name="flag"]').each(function() {
37                     $(this).removeAttr('disabled', 'disabled');
38                 });
39             }
40         });
42     });
43 </script>
44 <!-- manage checking/unchecking parent permissions -->
45 <script type="text/javascript">
46     var originalChildStates = {}; /* keep track of subpermission checkbox values
47                                      so that user can recover from accidentally
48                                      toggling a parent/module permission */
49     function selectChildren(parentInput) {
50         var childListId = parentInput.id + '-children';
51         var list = document.getElementById(childListId);
52         var children = [];
53         if (list) {
54             var inputs = list.getElementsByTagName('input');
55             for (var i = 0; i < inputs.length; i++) {
56                 if (inputs[i].type == 'checkbox') {
57                     children.push(inputs[i]);
58                 }
59             }
60             
61         } 
62         return children;
63     }
65     function toggleChildren(parentInput) {
66         var children = selectChildren(parentInput);
67         if (children.length == 0) {
68             return;
69         }
70         var checked = parentInput.checked;
71         if (checked && parentInput.parentNode.className == 'expandable') {
72             /* expand the tree */
73             $(".hitarea", parentInput.parentNode).click();
74         }
75         for (var i = 0; i < children.length; i++) {
76             if (checked) {
77                 originalChildStates[children[i].id] = children[i].checked;
78                 children[i].checked = checked;
79             } else {
80                 if (children[i].id in originalChildStates) {
81                     children[i].checked = originalChildStates[children[i].id];
82                 } else {
83                     children[i].checked = checked;
84                 }
85             }
86         }
87     }
89     function toggleParent(childInput) {
90         originalChildStates[childInput.id] = childInput.checked;
91         if (childInput.checked) {
92             return;
93         }
94         var parentId = childInput.parentNode.parentNode.id.replace(/-children$/, '');;
95         var parentInput = document.getElementById(parentId);
96         if (parentInput) {  
97             parentInput.checked = false;
98         }
99     }
101 </script>
102 </head>
103 <body id="pat_member-flags" class="pat">
104 [% INCLUDE 'header.inc' %]
105 [% INCLUDE 'patron-search.inc' %]
107 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Set permissions for [% surname %], [% firstname %]</div>
109 <div id="doc3" class="yui-t2">
110    
111    <div id="bd">
112         <div id="yui-main">
113         <div class="yui-b">
114 [% INCLUDE 'members-toolbar.inc' %]
116 <form method="post" action="/cgi-bin/koha/members/member-flags.pl">
117     <input type="hidden" name="member" id="borrowernumber" value="[% borrowernumber %]" />
118     <input type="hidden" name="newflags" value="1" />
119     <h1>Set permissions for [% surname %], [% firstname %]</h1>
120     <!-- <ul id="permissionstree"><li class="root">All privileges<ul> -->
121     <ul id="permissionstree" class="treeview-grey">
122         <!-- <li class="folder-close">One level down<ul> -->
123     [% FOREACH loo IN loop %]
124         [% IF ( loo.expand ) %]
125         <li class="open">
126         [% ELSE %]
127         <li>
128         [% END %]
129                         [% IF ( loo.checked ) %]
130                            <input type="checkbox" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" onclick="toggleChildren(this)" />
131                         [% ELSE %]
132                                 <input type="checkbox" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]"  onclick="toggleChildren(this)" />
133                         [% END %]
134                 <label class="permissioncode" for="flag-[% loo.bit %]">[% loo.flag %]</label>
135                 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
136             [% IF ( loo.sub_perm_loop ) %]
137                 <ul id="flag-[% loo.bit %]-children">
138                     [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
139                         <li>
140                                     [% IF ( sub_perm_loo.checked ) %]
141                                         <input type="checkbox" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" checked="checked" onclick="toggleParent(this)" />
142                                     [% ELSE %]
143                                         <input type="checkbox" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" onclick="toggleParent(this)" />
144                                     [% END %]
145                     <label class="permissioncode" for="[% sub_perm_loo.id %]">[% sub_perm_loo.code %]</label>
146                              <span class="permissiondesc">[% PROCESS sub_permissions name=sub_perm_loo.code %]</span>
147                         </li>
148                     [% END %]
149                 </ul>
150                 </li>
151             [% ELSE %]
152                 </li>
153                         [% END %]
154     [% END %]
155         <!-- </ul></li> -->
156     <!-- </ul></li></ul> -->
157     </ul>
159 <fieldset class="action"><input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
161 </form>
162 </div>
163 </div>
165 <div class="yui-b">
166 [% INCLUDE 'circ-menu.inc' %]
167 </div>
168 </div>
169 [% INCLUDE 'intranet-bottom.inc' %]