[Rt-commit] rt branch, 4.0/add-existing-principal-in-admin-rights-ui, created. rt-4.0.13-151-g2156e32
? sunnavy
sunnavy at bestpractical.com
Sun Jul 14 08:01:15 EDT 2013
The branch, 4.0/add-existing-principal-in-admin-rights-ui has been created
at 2156e32e1553e154295ad3fd7a498ccf6271af5d (commit)
- Log -----------------------------------------------------------------
commit 2156e32e1553e154295ad3fd7a498ccf6271af5d
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);
diff --git a/t/web/case-sensitivity.t b/t/web/case-sensitivity.t
index f9c61b5..5f40ef6 100644
--- a/t/web/case-sensitivity.t
+++ b/t/web/case-sensitivity.t
@@ -22,7 +22,7 @@ $m->login;
require JSON;
is_deeply(
JSON::from_json( $m->content ),
- [{"value" => "root\@localhost","label" => "Enoch Root"}]
+ [{"value" => "root\@localhost","label" => "Enoch Root", id=>$root_id}]
);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list