[Rt-commit] rt branch, 4.4/admin-rights-unselected, created. rt-4.4.1-127-gf373194b2

Maureen Mirville maureen at bestpractical.com
Thu Mar 8 15:42:49 EST 2018


The branch, 4.4/admin-rights-unselected has been created
        at  f373194b23d3fc73f14450832481c2979572af58 (commit)

- Log -----------------------------------------------------------------
commit 10aff1ecd1acb21e28edf019532bb20da38c4fcb
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Nov 10 23:36:06 2016 +0000

    Factor out an "input" variable
    
    jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>)
    
    is rather verbose and confusing to repeat three times

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index 57dc2fb30..c48e497a7 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -205,14 +205,15 @@ for my $category (@$Principals) {
                id="AddPrincipalForRights-<% lc $AddPrincipal %>" />
         <script type="text/javascript">
         jQuery(function() {
-            jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).keyup(function(){
+            var input = jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>);
+            input.keyup(function(){
                 toggle_addprincipal_validity(this, true);
             }).keydown(function(event){
                 event.stopPropagation() // Disable tabs keyboard nav
             });
 
-            jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).on("autocompleteselect", addprincipal_onselect);
-            jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).on("autocompletechange", addprincipal_onchange);
+            input.on("autocompleteselect", addprincipal_onselect);
+            input.on("autocompletechange", addprincipal_onchange);
         });
         </script>
 % my $type = lc $AddPrincipal eq 'user' ? loc('username') : loc($AddPrincipal);

commit 7dd7e512581442143ed715dfad1bb52b1f36cbb3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Nov 10 23:37:11 2016 +0000

    Factor out an addprincipal_test_validity function
    
    This lets us reuse it in multiple places

diff --git a/share/static/js/util.js b/share/static/js/util.js
index 5cd61dd15..8bc1b7671 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -493,27 +493,31 @@ function addprincipal_onselect(ev, ui) {
     toggle_addprincipal_validity(this, true, ui.item.value);
 }
 
+function addprincipal_test_validity(input) {
+    // Check using the same autocomplete source if the value typed would
+    // have been autocompleted and is therefore valid
+    jQuery.ajax({
+        url: input.autocomplete("option", "source"),
+        data: {
+            op: "=",
+            term: input.val()
+        },
+        dataType: "json",
+        success: function(data) {
+            if (data)
+                toggle_addprincipal_validity(input, data.length ? true : false );
+            else
+                toggle_addprincipal_validity(input, true);
+        }
+    });
+}
+
 // when the input is actually changed, through typing or autocomplete
 function addprincipal_onchange(ev, ui) {
     // if we have a ui.item, then they selected from autocomplete and it's good
     if (!ui.item) {
         var input = jQuery(this);
-        // Check using the same autocomplete source if the value typed would
-        // have been autocompleted and is therefore valid
-        jQuery.ajax({
-            url: input.autocomplete("option", "source"),
-            data: {
-                op: "=",
-                term: input.val()
-            },
-            dataType: "json",
-            success: function(data) {
-                if (data)
-                    toggle_addprincipal_validity(input, data.length ? true : false );
-                else
-                    toggle_addprincipal_validity(input, true);
-            }
-        });
+        addprincipal_test_validity(input);
     } else {
         toggle_addprincipal_validity(this, true);
     }

commit 6100f8dc2a3a1f0ff7566ca6a97e8cf2288253c8
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Nov 10 23:39:10 2016 +0000

    Improve hiding/showing of rights UI for unselected principal
    
    If you're assigning rights to a user or group and you're using the "Add
    Group" or "Add User" text field but have not yet typed in a valid group
    or user name, RT will still display the three-tab list of checkboxes UI
    on the right-hand side of the page. This is confusing to administrators
    since they should not be selecting rights, as there is no principal
    selected yet, but we show the UI anyway.
    
    This re-engineering hides and shows the panel itself based on whether
    there is a valid principal selected. This also improves the
    responsiveness of the "no user/group selected" warning which previously
    required you to blur the autocomplete field to render. Now, it provides
    more instantaneous feedback.
    
    Fixes: #29892

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index c48e497a7..9a8de28b0 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -207,7 +207,7 @@ for my $category (@$Principals) {
         jQuery(function() {
             var input = jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>);
             input.keyup(function(){
-                toggle_addprincipal_validity(this, true);
+                addprincipal_test_validity(input);
             }).keydown(function(event){
                 event.stopPropagation() // Disable tabs keyboard nav
             });
@@ -216,8 +216,6 @@ for my $category (@$Principals) {
             input.on("autocompletechange", addprincipal_onchange);
         });
         </script>
-% my $type = lc $AddPrincipal eq 'user' ? loc('username') : loc($AddPrincipal);
-        <span class="warning"><&|/l, $type &>Invalid [_1]</&></span>
       </a>
     </li>
 % }
@@ -259,8 +257,13 @@ if ($obj->isa('RT::Group') and $obj->Domain eq 'UserDefined') {
 if ( $AddPrincipal ) {
 </%perl>
   <div id="acl-AddPrincipal">
-    <h3><&|/l, loc($AddPrincipal) &>Add rights for this [_1]</&></h3>
-    <& EditRightsCategoryTabs, Context => $Context, id => 'acl-AddPrincipal' &>
+    <div class="valid-group hidden">
+      <h3><&|/l, loc($AddPrincipal) &>Add rights for this [_1]</&></h3>
+      <& EditRightsCategoryTabs, Context => $Context, id => 'acl-AddPrincipal' &>
+    </div>
+    <div class="invalid-group">
+      <p><&|/l, loc($AddPrincipal)&>Please select a [_1]</&></p>
+    </div>
   </div>
 % }
 
diff --git a/share/static/css/base/rights-editor.css b/share/static/css/base/rights-editor.css
index 6236b5f8e..ac42202aa 100644
--- a/share/static/css/base/rights-editor.css
+++ b/share/static/css/base/rights-editor.css
@@ -38,11 +38,6 @@ li.category ~ li.category {
     margin-top: 1em;
 }
 
-.rights-editor li.addprincipal .warning {
-    color: #a00;
-    display: none;
-}
-
 /* Position the outer-most panel */
 .rights-editor > .ui-tabs-panel {
     position: static;
@@ -144,3 +139,8 @@ span.rights-editor-label {
 .category-tabs.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
     padding: .5em 0.5em;
 }
+
+.rights-editor #acl-AddPrincipal .invalid-group p {
+    color: gray;
+    text-align: center;
+}
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 8bc1b7671..99aa6c222 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -458,11 +458,11 @@ function AddAttachmentWarning() {
 
 function toggle_addprincipal_validity(input, good, title) {
     if (good) {
-        jQuery(input).nextAll(".warning").hide();
-        jQuery("#acl-AddPrincipal input[type=checkbox]").removeAttr("disabled");
+        jQuery("#acl-AddPrincipal .valid-group").removeClass("hidden");
+        jQuery("#acl-AddPrincipal .invalid-group").addClass("hidden");
     } else {
-        jQuery(input).nextAll(".warning").css("display", "block");
-        jQuery("#acl-AddPrincipal input[type=checkbox]").attr("disabled", "disabled");
+        jQuery("#acl-AddPrincipal .invalid-group").removeClass("hidden");
+        jQuery("#acl-AddPrincipal .valid-group").addClass("hidden");
     }
 
     if (title == null)
@@ -472,7 +472,7 @@ function toggle_addprincipal_validity(input, good, title) {
 }
 
 function update_addprincipal_title(title) {
-    var h3 = jQuery("#acl-AddPrincipal h3");
+    var h3 = jQuery("#acl-AddPrincipal .valid-group h3");
     h3.text( h3.text().replace(/: .*$/,'') + ": " + title );
 }
 
@@ -494,6 +494,13 @@ function addprincipal_onselect(ev, ui) {
 }
 
 function addprincipal_test_validity(input) {
+    // autocomplete won't run if the input field is empty
+    // and we know that an empty input field should hide the panel
+    if (input.val() == "") {
+        toggle_addprincipal_validity(input, false);
+        return;
+    }
+
     // Check using the same autocomplete source if the value typed would
     // have been autocompleted and is therefore valid
     jQuery.ajax({

commit 36fbe5a751bb38e42b55895f8a9ab57df8f92965
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Thu Mar 8 15:32:39 2018 -0500

    Removed whitespaces/tab indents

diff --git a/share/static/css/base/rights-editor.css b/share/static/css/base/rights-editor.css
index ac42202aa..19d793e5a 100644
--- a/share/static/css/base/rights-editor.css
+++ b/share/static/css/base/rights-editor.css
@@ -79,7 +79,7 @@ li.category ~ li.category {
 .rights-editor li.ui-tabs-active {
     background: white !important;
     color: #222 !important;
-    border-color: #aaa !important; 
+    border-color: #aaa !important;
     font-weight: bold;
 }
 
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 99aa6c222..1f943c82d 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -53,7 +53,7 @@ function delClass(id, value) {
 function rollup(id) {
     var e = jQueryWrap(id);
     var e2  = e.parent();
-    
+
     if (e.hasClass('hidden')) {
         set_rollup_state(e,e2,'shown');
         createCookie(id,1,365);
@@ -166,7 +166,7 @@ function showShredderPluginTab( plugin )
 {
     var plugin_tab_id = 'shredder-plugin-'+ plugin +'-tab';
     var root = jQuery('#shredder-plugin-tabs');
-    
+
     root.children(':not(.hidden)').addClass('hidden');
     root.children('#' + plugin_tab_id).removeClass('hidden');
 
@@ -189,7 +189,7 @@ function checkAllObjects()
     }
 }
 
-function checkboxToInput(target,checkbox,val){    
+function checkboxToInput(target,checkbox,val){
     var tar = jQuery('#' + escapeCssSelector(target));
     var box = jQuery('#' + escapeCssSelector(checkbox));
     if(box.prop('checked')){
@@ -197,7 +197,7 @@ function checkboxToInput(target,checkbox,val){
             tar.val(val);
         }
         else{
-            tar.val( val+', '+ tar.val() );        
+            tar.val( val+', '+ tar.val() );
         }
     }
     else{

commit f373194b23d3fc73f14450832481c2979572af58
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Thu Mar 8 15:34:29 2018 -0500

    Further improve modify rights UI for unselected principal
    
    Previous commit (#6100f8dc) hid all rights options from UI when
    a valid principal user or group was not selected. Rather than
    hiding the list of rights, the list is now disabled and faded
    for a less aggressive visual cue.
    
    Fixes: I#29892

diff --git a/share/html/Admin/Elements/EditRights b/share/html/Admin/Elements/EditRights
index 9a8de28b0..6ac0e648b 100644
--- a/share/html/Admin/Elements/EditRights
+++ b/share/html/Admin/Elements/EditRights
@@ -257,12 +257,12 @@ if ($obj->isa('RT::Group') and $obj->Domain eq 'UserDefined') {
 if ( $AddPrincipal ) {
 </%perl>
   <div id="acl-AddPrincipal">
-    <div class="valid-group hidden">
-      <h3><&|/l, loc($AddPrincipal) &>Add rights for this [_1]</&></h3>
-      <& EditRightsCategoryTabs, Context => $Context, id => 'acl-AddPrincipal' &>
-    </div>
     <div class="invalid-group">
-      <p><&|/l, loc($AddPrincipal)&>Please select a [_1]</&></p>
+      <h3><&|/l, loc($AddPrincipal)&>Please select a [_1]</&></h3>
+      <div class="valid-group disabled-grey">
+        <h3><&|/l, loc($AddPrincipal) &>Add rights for this [_1]</&></h3>
+        <& EditRightsCategoryTabs, Context => $Context, id => 'acl-AddPrincipal' &>
+      </div>
     </div>
   </div>
 % }
diff --git a/share/static/css/base/rights-editor.css b/share/static/css/base/rights-editor.css
index 19d793e5a..5989b4cd1 100644
--- a/share/static/css/base/rights-editor.css
+++ b/share/static/css/base/rights-editor.css
@@ -140,7 +140,13 @@ span.rights-editor-label {
     padding: .5em 0.5em;
 }
 
-.rights-editor #acl-AddPrincipal .invalid-group p {
-    color: gray;
-    text-align: center;
+.rights-editor #acl-AddPrincipal .invalid-group {
+    background-color: rgba( 0, 0, 0, 0.1 );
+    position: center;
+    padding: 5px;
+    pointer-events: none;
+}
+
+.rights-editor #acl-AddPrincipal .disabled-grey {
+    opacity: 0.2;
 }
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 1f943c82d..ce8d2f9a1 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -458,11 +458,13 @@ function AddAttachmentWarning() {
 
 function toggle_addprincipal_validity(input, good, title) {
     if (good) {
-        jQuery("#acl-AddPrincipal .valid-group").removeClass("hidden");
-        jQuery("#acl-AddPrincipal .invalid-group").addClass("hidden");
+        jQuery( '#acl-AddPrincipal .invalid-group').unwrap();
+        jQuery( '#acl-AddPrincipal .valid-group' ).removeClass( 'disabled-grey' );
     } else {
-        jQuery("#acl-AddPrincipal .invalid-group").removeClass("hidden");
-        jQuery("#acl-AddPrincipal .valid-group").addClass("hidden");
+        if( !jQuery( '#acl-AddPrincipal' ).find( '.invalid-group' ) ) {
+            jQuery( '#acl-AddPrincipal' ).wrapInner( '<div class="invalid-group"></div>' );
+        }
+        jQuery( '#acl-AddPrincipal .valid-group' ).addClass( 'disabled-grey' );
     }
 
     if (title == null)

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


More information about the rt-commit mailing list