Bug 20100: (QA follow-up) Use template logic instead of js to disable superlib box
authorNick Clemens <nick@bywatersolutions.com>
Fri, 20 Apr 2018 11:52:17 +0000 (11:52 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 25 Apr 2018 13:23:53 +0000 (10:23 -0300)
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt

index f5631f2..8cb5135 100644 (file)
         <li>
         [% END %]
                        [% IF ( loo.checked ) %]
-                <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" />
+          [% IF disable_superlibrarian_privs && loo.bit == 0 %]
+              <input type="checkbox" disabled="disabled" class="flag parent superlib" id="flag-[% loo.bit %]_disabled" name="flag" value="[% loo.flag %]" checked="checked" />
+              <input type="hidden" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" >
+          [% ELSE %]
+              <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" />
+          [% END %]
                        [% ELSE %]
-                <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" />
+          [% IF disable_superlibrarian_privs && loo.bit == 0 %]
+              <input type="checkbox" disabled="disabled" class="flag parent" id="flag-[% loo.bit %]_disabled" name="flag" value="[% loo.flag %]" />
+          [% ELSE %]
+              <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" />
+          [% END %]
                        [% END %]
                 <label class="permissioncode" for="flag-[% loo.bit %]">[% loo.flag %]</label>
                 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
             $("#permissionstree").treeview({animated: "fast", collapsed: true});
 
             // Enforce Superlibrarian Privilege Mutual Exclusivity
-            if($('input[id="flag-0"]:checked').length){
+            if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
                 if ($('input[name="flag"]:checked').length > 1){
                     alert(_("Inconsistency detected! The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all. This patron's privileges will now be reset to include only superlibrarian."));
                 }
 
                 $('input[name="flag"]').each(function() {
-                    if($(this).attr('id') != "flag-0"){
+                    if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
                         $(this).prop('disabled', true);
                         $(this).prop('checked', false);
                     }
             }
 
             $('input#flag-0').click(function() {
-                if($('input[id="flag-0"]:checked').length){
+                if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
                     $('input[name="flag"]').each(function() {
-                        if($(this).attr('id') != "flag-0"){
+                        if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
                             $(this).prop('disabled', true);
                             $(this).prop('checked', false);
                         }
                 }
             });
 
-            [% IF disable_superlibrarian_privs %]
-                $("input#flag-0").attr("disabled", true);
-                $("form").submit(function(e) {
-                    $("input#flag-0").removeAttr("disabled");
-                });
-            [% END %]
         });
 
         // manage checking/unchecking parent permissions