Bug 16494 - Remove the use of "onclick" from some patron pages
authorOwen Leonard <oleonard@myacpl.org>
Tue, 10 May 2016 18:56:14 +0000 (14:56 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 24 Jun 2016 13:46:54 +0000 (13:46 +0000)
This patch removes the use of "onclick" attributes from some patron
pages.

To test, apply the patch and:

- In Patrons, perform any search which will return multiple results.
  Confirm that the "select all" and "clear all" links work as expected.
  Font Awesome icons have been added to these links.

  In the left-hand sidebar, change any of the filters and click the
  "Clear" button. The form (and your search results) should reset.

- Open the 'Set permissions' page for any patron. Checking any
  permission with sub-permissions should correctly expand the tree and
  select all sub-permissions. The reverse should also work.

  Also changed in this file: The "Inconsistency detected" alert has been
  reformatted to make it translatable.

- View the detail page for a patron with one or more restrictions.
  Clicking the "View restrictions" link at the top of the page should
  jump you to and activate the restrictions tab.

- View the 'Notices' tab for a patron who has been sent one or more
  notices. Click any notice title to expand the notice. Clicking the
  "resend" button should resend the notice.

- Create a new patron with the same first and last name as an existing
  patron. This should trigger a duplicate warning message. Click the
  "View existing record" link to trigger a pop-up window with a patron
  detail brief view.

  In this window an "email" class has been added to the primary and
  secondary email lines so that long email addresses don't overlap the
  second column of data.

  Confirm that clicking the "close" button in this window closes the
  window. The changes to staff-global.css are included in this patch to
  prevent the close button from having an incorrect color change on
  hover.

Signed-off-by: FILIPPOS KOLOVOS <f.kolovos@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt

index 278cd85..d2db82e 100644 (file)
@@ -2438,12 +2438,16 @@ a.disabled {
 }
 
 .close:hover {
-    color: #538200;
+    color: inherit;
     filter: inherit;
     font-size: inherit;
     opacity: inherit;
 }
 
+a.close:hover {
+    color: #538200;
+}
+
 /* Redefine a new style for Bootstrap's class "close" since we use that already */
 /* Use <a class="closebtn" href="#">&times;</a> */
 .alert .closebtn{position:relative;top:-2px;right:-21px;line-height:20px;}
index d9d95af..039c8ec 100644 (file)
@@ -12,7 +12,7 @@
         // Enforce Superlibrarian Privilege Mutual Exclusivity
         if($('input[id="flag-0"]:checked').length){
             if ($('input[name="flag"]:checked').length > 1){
-                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.');
+                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() {
             }
         });
 
+        $(".flag").on("change",function(){
+            if( $(this).hasClass("parent") ){
+                toggleChildren(this);
+            } else {
+                toggleParent(this);
+            }
+        });
+
     });
-</script>
-<!-- manage checking/unchecking parent permissions -->
-<script type="text/javascript">
+
+    // manage checking/unchecking parent permissions
     var originalChildStates = {}; /* keep track of subpermission checkbox values
                                      so that user can recover from accidentally
                                      toggling a parent/module permission */
         <li>
         [% END %]
                        [% IF ( loo.checked ) %]
-                          <input type="checkbox" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" onclick="toggleChildren(this)" />
+                <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" checked="checked" />
                        [% ELSE %]
-                               <input type="checkbox" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]"  onclick="toggleChildren(this)" />
+                <input type="checkbox" class="flag parent" id="flag-[% loo.bit %]" name="flag" value="[% loo.flag %]" />
                        [% END %]
                 <label class="permissioncode" for="flag-[% loo.bit %]">[% loo.flag %]</label>
                 <span class="permissiondesc">[% PROCESS main_permissions name=loo.flag %]</span>
                     [% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
                         <li>
                                    [% IF ( sub_perm_loo.checked ) %]
-                                       <input type="checkbox" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" checked="checked" onclick="toggleParent(this)" />
+                            <input type="checkbox" class="flag child" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" checked="checked" />
                                    [% ELSE %]
-                                       <input type="checkbox" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" onclick="toggleParent(this)" />
+                            <input type="checkbox" class="flag child" id="[% sub_perm_loo.id %]" name="flag" value="[% sub_perm_loo.perm %]" />
                                    [% END %]
                     <label class="permissioncode" for="[% sub_perm_loo.id %]">[% sub_perm_loo.code %]</label>
                              <span class="permissiondesc">[% PROCESS sub_permissions name=sub_perm_loo.code %]</span>
index 0bb4bfa..06fbc75 100644 (file)
@@ -97,6 +97,18 @@ $(document).ready(function() {
         e.preventDefault();
         filterByFirstLetterSurname($(this).text());
     });
+    $("#select_all").on("click",function(e){
+        e.preventDefault();
+        $(".selection").prop("checked", true);
+    });
+    $("#clear_all").on("click",function(e){
+        e.preventDefault();
+        $(".selection").prop("checked", false);
+    });
+    $("#clear_search").on("click",function(e){
+        e.preventDefault();
+        clearFilters(true);
+    });
 });
 
 var dtMemberResults;
@@ -354,9 +366,9 @@ function filterByFirstLetterSurname(letter) {
             [% IF CAN_user_tools_manage_patron_lists %]
               <div id="searchheader">
                   <div>
-                      <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
+                      <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
                       |
-                      <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
+                      <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
                       |
                       <span>
                           <label for="add_to_patron_list">Add selected patrons to:</label>
@@ -515,7 +527,7 @@ function filterByFirstLetterSurname(letter) {
           </ol>
           <fieldset class="action">
             <input type="submit" value="Search" />
-            <input type="button" value="Clear" onclick="clearFilters(true);" />
+            <input type="button" value="Clear" id="clear_search" />
           </fieldset>
         </fieldset>
       </form>
index 34367d8..33061fa 100644 (file)
@@ -44,8 +44,8 @@
     [% END %]
        [% IF ( fax ) %]<li><span class="label">Fax: </span>[% fax %]</li>[% END %]
     [% UNLESS ( I ) %]
-        [% IF ( email ) %]<li><span class="label">Primary email:</span><a href="mailto:[% email %]">[% email %]</a></li>[% END %]
-        [% IF ( emailpro ) %]<li><span class="label">Secondary email: </span><a href="mailto:[% emailpro %]">[% emailpro %]</a></li>[% END %]
+        [% IF ( email ) %]<li class="email"><span class="label">Primary email:</span><a href="mailto:[% email %]">[% email %]</a></li>[% END %]
+        [% IF ( emailpro ) %]<li class="email"><span class="label">Secondary email: </span><a href="mailto:[% emailpro %]">[% emailpro %]</a></li>[% END %]
     [% END %]
     <li><span class="label">Initials: </span>[% initials %]</li>
     <li><span class="label">Date of birth:</span>[% dateofbirth | $KohaDates %]</li>
@@ -86,7 +86,7 @@
        </ol>
        </div>
        </div>
-       <fieldset class="action"><input type="button" class="submit" value="Close window" onclick="window.close();" /></fieldset>
+    <fieldset class="action"><input type="button" class="close" value="Close window" /></fieldset>
        </div>
        </div>
 </div>
index 2213a7c..0847fca 100644 (file)
@@ -89,6 +89,9 @@ $(document).ready(function() {
         hour: 23,
         minute: 59
     });
+    $("#view_restrictions").on("click",function(){
+        $('#debarments-tab-link').click();
+    });
  });
 function uncheck_sibling(me){
 nodename=me.getAttribute("name");
@@ -188,7 +191,7 @@ function validate1(date) {
                [% IF ( debarredcomment ) %]
                    with the explanation: <i>[% debarredcomment | html_line_break %]</i>
                [% END %]
-                <a href="#reldebarments" onclick="$('#debarments-tab-link').click()">View restrictions</a>
+                <a href="#reldebarments" id="view_restrictions">View restrictions</a>
             </li>
         [% END %]
         [% IF ( gonenoaddress ) %]<li class="blocker">Patron's address is in doubt.</li>[% END %]
index dbe5713..a771b7e 100644 (file)
@@ -80,7 +80,9 @@
                     <input type="hidden" name="op" value="resend_notice" />
                     <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
                     <input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id %]" />
-                    <a href="#" onclick="$(this).closest('form').submit();return false;" title="Attempt to resend the notice">Resend</a>
+                    <fieldset class="action">
+                        <button class="btn btn-mini" type="submit">Resend</button>
+                    </fieldset>
                 </form>
             </div>
             [% END %]