[Rt-commit] rt branch, 4.0/add-existing-principal-in-admin-rights-ui, created. rt-4.0.13-151-g2b7f823

? sunnavy sunnavy at bestpractical.com
Wed Jul 10 11:48:09 EDT 2013


The branch, 4.0/add-existing-principal-in-admin-rights-ui has been created
        at  2b7f82353ba5a32e56e5127843de2c4e900cf30b (commit)

- Log -----------------------------------------------------------------
commit 2b7f82353ba5a32e56e5127843de2c4e900cf30b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jul 10 23:18:43 2013 +0800

    goto existing principal link directly if the principal is selected in "ADD USER" or "ADD GROUP"
    
    usually admins can click a principal link directly to edit its rights, but if
    one missed the link and used the input below "ADD USER" or "ADD GROUP"
    instead, then it's treated like a principal without any right, which is kinda
    misleading. this commit fixes it by automatically switching to existing links.

diff --git a/share/html/Helpers/Autocomplete/Groups b/share/html/Helpers/Autocomplete/Groups
index b6a6f1a..92bea0e 100644
--- a/share/html/Helpers/Autocomplete/Groups
+++ b/share/html/Helpers/Autocomplete/Groups
@@ -83,6 +83,6 @@ foreach (split /\s*,\s*/, $exclude) {
 my @suggestions;
 
 while ( my $group = $groups->Next ) {
-    push @suggestions, $group->Name;
+    push @suggestions, { label => $group->Name, value => $group->Name, id => $group->id };
 }
 </%INIT>
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index 349442a..5b570d7 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -139,7 +139,7 @@ while ( my $user = $users->Next ) {
 
     my $formatted = $m->scomp('/Elements/ShowUser', User => $user, NoEscape => 1);
     $formatted =~ s/\n//g;
-    my $suggestion = { label => $formatted, value => $user->$return };
+    my $suggestion = { label => $formatted, value => $user->$return, id => $user->id };
     $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
     push @suggestions, $suggestion;
 }
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index a267940..77a211e 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -336,6 +336,16 @@ function update_addprincipal_title(title) {
 
 // when a value is selected from the autocompleter
 function addprincipal_onselect(ev, ui) {
+
+    // if principal link exists, we shall go there instead
+    var principal_link = jQuery(ev.target).closest('form').find('ul.ui-tabs-nav a[href="#acl-' + ui.item.id + '"]:first');
+    if (principal_link.size()) {
+        jQuery(this).val('').blur();
+        update_addprincipal_title( '' ); // reset title to blank for #acl-AddPrincipal
+        principal_link.click();
+        return false;
+    }
+
     // pass the item's value along as the title since the input's value
     // isn't actually updated yet
     toggle_addprincipal_validity(this, true, ui.item.value);

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


More information about the Rt-commit mailing list