%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
$AddPrincipal => undef
</%args>
<%init>
-use Scalar::Util qw(blessed);
-
# Let callbacks get at principals and context before we do anything with them
$m->callback( Principals => $Principals, Context => $Context );
$AddPrincipal = 'user'; # loc
}
}
+
+my $anchor = $DECODED_ARGS->{Anchor} || '';
+if ($anchor =~ /AddPrincipal/) {
+ for my $type ("group", "user") {
+ my $record = _ParseACLNewPrincipal($DECODED_ARGS, $type)
+ or next;
+ if ($record->PrincipalId) {
+ $anchor = "#acl-" . $record->PrincipalId;
+ last;
+ }
+ }
+}
</%init>
%# Principals is an array of arrays, where the inner arrays are like:
%# [ 'Category name' => $CollectionObj => 'DisplayColumn' => 1 ]
<script type="text/javascript">
jQuery(function() {
+ function sync_anchor(hash) {
+ if (!hash.length) return;
+ window.location.hash = hash;
+ jQuery(".rights-editor input[name=Anchor]").val(hash);
+ }
+ sync_anchor(<% $anchor |n,j %>);
+
jQuery(".rights-editor").tabs({
- select: function(ev, ui) {
- window.location.hash = ui.tab.hash;
+ beforeActivate: function(ev, ui) {
+ sync_anchor(ui.newPanel.selector);
+ if ( ui.newTab.find('input[type=text]').size() > 0 ) {
+ ui.newTab.find('input[type=text]:first').focus();
+ }
+ }
+ });
+
+ jQuery(".rights-editor .category-tabs").tabs({
+ active: jQuery.cookie('rights-category-tab') || 0,
+ activate: function(ev, ui) {
+ jQuery.cookie('rights-category-tab', ui.newTab.index());
+ jQuery(".rights-editor .category-tabs").not(this).each(function() {
+ var item = jQuery(this);
+ var selected = item.tabs("option", "active") || 0;
+ if (selected != ui.newTab.index())
+ item.tabs("option", "active", ui.newTab.index());
+ });
}
});
- jQuery(".rights-editor .category-tabs").tabs();
});
</script>
<div class="rights-editor clearfix">
+ <input type="hidden" value="" name="Anchor" />
+
<ul>
<%perl>
for my $category (@$Principals) {
<%perl>
while ( my $obj = $collection->Next ) {
my $display = ref $col eq 'CODE' ? $col->($obj) : $obj->$col;
- my $id = "acl-$name-" . $obj->PrincipalId;
- $id =~ s/[^a-zA-Z0-9\-]/_/g;
+ my $id = "acl-" . $obj->PrincipalId;
</%perl>
<li><a href="#<% $id %>"><% $loc ? loc($display) : $display %></a></li>
<%perl>
<li class="addprincipal">
<a href="#acl-AddPrincipal">
<input type="text" value=""
+ data-autocomplete="<% lc $AddPrincipal eq 'user' ? 'Users' : 'Groups' %>"
+% if ( lc $AddPrincipal eq 'user' ) {
+ data-autocomplete-return="Name"
+ data-autocomplete-privileged="1"
+% }
name="AddPrincipalForRights-<% lc $AddPrincipal %>"
id="AddPrincipalForRights-<% lc $AddPrincipal %>" />
<script type="text/javascript">
jQuery(function() {
jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).keyup(function(){
toggle_addprincipal_validity(this, true);
+ }).keydown(function(event){
+ event.stopPropagation() // Disable tabs keyboard nav
});
-% if (lc $AddPrincipal eq 'group') {
- jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).autocomplete({
- source: <% RT->Config->Get('WebPath') |n,j%>+"/Helpers/Autocomplete/Groups",
- select: addprincipal_onselect,
- change: addprincipal_onchange
- });
-% }
+ jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).on("autocompleteselect", addprincipal_onselect);
+ jQuery("#AddPrincipalForRights-"+<% lc $AddPrincipal |n,j%>).on("autocompletechange", addprincipal_onchange);
});
</script>
% my $type = lc $AddPrincipal eq 'user' ? loc('username') : loc($AddPrincipal);
my ($name, $collection, $col, $loc) = @$category;
while ( my $obj = $collection->Next ) {
my $display = ref $col eq 'CODE' ? $col->($obj) : $obj->$col;
- my $id = "acl-$name-" . $obj->PrincipalId;
- $id =~ s/[^a-zA-Z0-9\-]/_/g;
+ my $id = "acl-" . $obj->PrincipalId;
</%perl>
<div id="<% $id %>">
if ($obj->isa('RT::Group') and $obj->Domain eq 'UserDefined') {
my $subgroups = $obj->GroupMembersObj( Recursively => 1 );
$subgroups->LimitToUserDefinedGroups;
- $subgroups->Limit( FIELD => 'Name', OPERATOR => '!=', VALUE => $obj->Name );
+ $subgroups->Limit( FIELD => 'Name', OPERATOR => '!=', VALUE => $obj->Name, CASESENSITIVE => 0 );
if ( $subgroups->Count ) {
my $inc = join ", ", map $_->Name, @{$subgroups->ItemsArrayRef};