[Rt-commit] rt branch, master, updated. rt-4.2.12-364-g31fc2ac

Shawn Moore shawn at bestpractical.com
Thu Oct 29 15:38:38 EDT 2015


The branch, master has been updated
       via  31fc2ac9c8e779245c1986416832fdf22504f6e2 (commit)
       via  870f67a52ca5a2892105aac3950ba2f4f109a586 (commit)
      from  fcdc9436b75dd31f4d9ed78513445e333d184449 (commit)

Summary of changes:
 share/html/Admin/Elements/EditRights             | 62 +++++++++++++++++++++++-
 share/html/Admin/Elements/EditRightsCategoryTabs | 17 ++++---
 share/static/css/base/rights-editor.css          | 18 ++++++-
 3 files changed, 89 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit 870f67a52ca5a2892105aac3950ba2f4f109a586
Author: Matt Zagrabelny <mzagrabe at d.umn.edu>
Date:   Tue Oct 20 10:33:20 2015 -0500

    add highlighting functionality to Edit Rights admin pages
    
    Use CSS to indicate when both category and principal tabs have rights
    granted "underneath" them. This will visually help the administrator
    know where unseen rights are granted in the admin UI. When all
    checkboxes for a given category or principal have been unchecked (rights
    revoked, thought still need to be committed), then the category and/or
    principal tab will return to its unhighlighted state.
    
    In order to keep the original text padding the same as how it is with
    the highlighting, we need to tweak the padding of a couple of CSS
    entries.

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index bd86131..6db874a 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -112,6 +112,66 @@ if ($anchor =~ /AddPrincipal/) {
               });
           }
       });
+
+      // "rights" checkbox state datastore...
+      var categories_check_counts = {};
+      var principals_check_counts = {};
+
+      // Before page loads we need to initialize our "rights" checkbox state
+      // datastore.
+      jQuery("div.category-tabs input[type=checkbox]").each(function(index, element) {
+          // Evaluating each checkbox and its current check state is the same
+          // as evaluating a check event once the page is loaded. However, we
+          // must indicate to the process_check_event that we are initializing
+          // the datastore. That is, we musn't decrement values from count
+          // totals for checkboxes that aren't checked. That only happens when
+          // a user actually unchecks a box, not when we are initially counting
+          // checked or unchecked boxes.
+          process_check_event(element, false);
+      });
+
+      jQuery("div.category-tabs input[type=checkbox]").change(function() {
+          process_check_event(this, true);
+      });
+
+      /*
+       parameters:
+         checkbox - DOM checkbox element that was checked
+         is_initialized - a boolean that defines whether or not this function
+                          can assume that the "rights" checkbox state
+                          datastore has been initialized.
+
+       */
+      function process_check_event(checkbox, is_initialized) {
+          var category_tab  = checkbox.getAttribute('data-category-tab');
+          var principal_tab = checkbox.getAttribute('data-principal-tab');
+
+          classify_tab(checkbox.checked, category_tab, categories_check_counts, is_initialized);
+          classify_tab(checkbox.checked, principal_tab, principals_check_counts, is_initialized);
+      }
+
+      function classify_tab(checked, tab_id, tab_check_counts, is_initialized) {
+          if (typeof tab_check_counts[tab_id] == 'undefined') {
+              tab_check_counts[tab_id] = 0;
+          }
+
+          if (checked) {
+              tab_check_counts[tab_id]++;
+              if (tab_check_counts[tab_id] == 1) {
+                  // Then this is the first check and we need to add a class
+                  // to the tab.
+                  jQuery('#' + tab_id).addClass("tab-aggregates-checked-rights");
+              }
+          }
+          else if (is_initialized) {
+              tab_check_counts[tab_id]--;
+              if (tab_check_counts[tab_id] == 0) {
+                  // Then this is the last uncheck and we need to remove a
+                  // class from the tab.
+                  jQuery('#' + tab_id).removeClass("tab-aggregates-checked-rights");
+              }
+          }
+      }
   });
 </script>
 
@@ -129,7 +189,7 @@ for my $category (@$Principals) {
         my $display = ref $col eq 'CODE' ? $col->($obj) : $obj->$col;
         my $id = "acl-" . $obj->PrincipalId;
 </%perl>
-<li><a href="#<% $id %>"><% $loc ? loc($display) : $display %></a></li>
+<li><a href="#<% $id %>"><span class="rights-editor-label" id="<% "principal-tab-$id" %>"><% $loc ? loc($display) : $display %></span></a></li>
 <%perl>
     }
 }
diff --git a/share/html/Admin/Elements/EditRightsCategoryTabs b/share/html/Admin/Elements/EditRightsCategoryTabs
index 6174e68..ffb6f34 100644
--- a/share/html/Admin/Elements/EditRightsCategoryTabs
+++ b/share/html/Admin/Elements/EditRightsCategoryTabs
@@ -105,7 +105,7 @@ $available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;
     <div class="category-tabs">
       <ul>
 % for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) {
-        <li><a href="#<% "$id-$category" %>"><% $category_desc{$category} || loc($category) %></a></li>
+        <li><a href="#<% "$id-$category" %>"><span class="rights-editor-label" id="<% "category-tab-$id-$category" %>"><% $category_desc{$category} || loc($category) %></span></a></li>
 % }
       </ul>
 % for my $category (sort { $catsort{$a} <=> $catsort{$b} } keys %categories) {
@@ -113,11 +113,16 @@ $available_rights{$_} = loc( $available_rights{$_} ) for keys %available_rights;
     <ul class="rights-list">
 %     for my $right (sort { $available_rights{$a} cmp $available_rights{$b} } @{$categories{$category}}) {
       <li>
-        <input type="checkbox" class="checkbox"
-               name="SetRights-<% $acldesc %>"
-               id="SetRights-<% $acldesc %>-<% $right %>"
-               value="<% $right %>"
-               <% $current_rights{$right} ? 'checked' : '' %> />
+        <input
+            type="checkbox"
+            class="checkbox"
+            name="SetRights-<% $acldesc %>"
+            id="SetRights-<% $acldesc %>-<% $right %>"
+            value="<% $right %>"
+            data-category-tab="<% "category-tab-$id-$category" %>"
+            data-principal-tab="<% "principal-tab-$id" %>"
+            <% $current_rights{$right} ? 'checked' : '' %>
+        />
         <label for="SetRights-<% $acldesc %>-<% $right %>" title="<% $right %>">
           <% $available_rights{$right} %>
           <span class="separator">—</span>
diff --git a/share/static/css/base/rights-editor.css b/share/static/css/base/rights-editor.css
index acfc3d9..f0d2547 100644
--- a/share/static/css/base/rights-editor.css
+++ b/share/static/css/base/rights-editor.css
@@ -25,7 +25,7 @@
 .rights-editor > .ui-tabs-nav li a {
     float: none;
     display: block;
-    padding: 0 0 0.2em 1em;
+    padding: 0 0 0.2em 0.5em;
     overflow: hidden;
     text-overflow: ellipsis;
 }
@@ -128,3 +128,19 @@ li.category ~ li.category {
 
     text-align: right;
 }
+
+span.rights-editor-label {
+    padding: 0.15em 0.5em;
+    border-radius: 6px;
+}
+
+.tab-aggregates-checked-rights {
+    background: #cfcfcf;
+}
+
+/* override jquery-ui by using a more specific
+ * class identifier.
+ */
+.category-tabs.ui-tabs .ui-tabs-nav li a {
+    padding: .5em 0.5em;
+}

commit 31fc2ac9c8e779245c1986416832fdf22504f6e2
Merge: fcdc943 870f67a
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Oct 29 19:37:02 2015 +0000

    Merge branch '4.4/highlight-rights-tabs-containing-granted-rights'


-----------------------------------------------------------------------


More information about the rt-commit mailing list