diff options
Diffstat (limited to 'rt/share/html/Admin/CustomFields')
-rw-r--r-- | rt/share/html/Admin/CustomFields/GroupRights.html | 2 | ||||
-rw-r--r-- | rt/share/html/Admin/CustomFields/Modify.html | 35 | ||||
-rw-r--r-- | rt/share/html/Admin/CustomFields/Objects.html | 27 | ||||
-rw-r--r-- | rt/share/html/Admin/CustomFields/index.html | 47 |
4 files changed, 62 insertions, 49 deletions
diff --git a/rt/share/html/Admin/CustomFields/GroupRights.html b/rt/share/html/Admin/CustomFields/GroupRights.html index 2e0b5b0ec..96024d7a5 100644 --- a/rt/share/html/Admin/CustomFields/GroupRights.html +++ b/rt/share/html/Admin/CustomFields/GroupRights.html @@ -70,7 +70,7 @@ my @results = ProcessACLs( \%ARGS ); my $title = loc('Modify group rights for custom field [_1]', $CustomFieldObj->Name); # Principal collections -my @principals = GetPrincipalsMap($CustomFieldObj, qw(System Groups)); +my @principals = GetPrincipalsMap($CustomFieldObj, qw(System Roles Groups)); </%INIT> <%ARGS> diff --git a/rt/share/html/Admin/CustomFields/Modify.html b/rt/share/html/Admin/CustomFields/Modify.html index f9ca71c21..ae27c589e 100644 --- a/rt/share/html/Admin/CustomFields/Modify.html +++ b/rt/share/html/Admin/CustomFields/Modify.html @@ -45,7 +45,12 @@ %# those contributions and any derivatives thereof. %# %# END BPS TAGGED BLOCK }}} -<& /Admin/Elements/Header, Title => $title &> +<& /Admin/Elements/Header, + Title => $title, + Focus => (($added_cfv or $ARGS{FocusAddValue}) + ? "input[name=CustomField-$id-Value-new-Name]" + : undef), + &> <& /Elements/Tabs &> <& /Elements/ListActions, actions => \@results &> @@ -125,7 +130,7 @@ <i><&|/l&>Some browsers may only load content from the same domain as your RT server.</&></i> </div></td></tr> -% if ( $CustomFieldObj->Id && $CustomFieldObj->IsSelectionType && !$CustomFieldObj->IsExternalValues ) { +% if ( $CustomFieldObj->Id && $CustomFieldObj->IsSelectionType ) { <tr class="categoriesbasedon"><td class="label"><&|/l&>Categories are based on</&></td><td> <& /Admin/Elements/SelectCustomField, Name => "BasedOn", @@ -150,8 +155,8 @@ <tr><td class="label"> </td><td> <input type="hidden" class="hidden" name="SetEnabled" value="1" /> -<input type="checkbox" class="checkbox" name="Enabled" value="1" <% $EnabledChecked |n%> /> -<&|/l&>Enabled (Unchecking this box disables this custom field)</&> +<input type="checkbox" class="checkbox" id="Enabled" name="Enabled" value="1" <% $EnabledChecked |n %> /> +<label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this custom field)</&></label> </td></tr> % $m->callback(CallbackName => 'EndOfTable', CustomField => $CustomFieldObj, CFvalidations => \@CFvalidations); @@ -170,7 +175,7 @@ </form> <%INIT> -my ($title, @results); +my ($title, @results, $added_cfv); my $CustomFieldObj = RT::CustomField->new( $session{'CurrentUser'} ); @@ -191,7 +196,7 @@ else { LinkValueTo => $LinkValueTo, IncludeContentForValue => $IncludeContentForValue, BasedOn => $BasedOn, - Disabled => !$Enabled, + Disabled => ($Enabled ? 0 : 1), NoClone => !$YesClone, ); if (!$val) { @@ -306,6 +311,7 @@ if ( $ARGS{'Update'} && $id ne 'new' ) { $_ => $ARGS{ $paramtag ."-new-$_" } } qw/ Name Description SortOrder Category/ ); push (@results, $msg); + $added_cfv = 1 if $id; my $cfv = RT::CustomFieldValue->new( $session{CurrentUser} ); $cfv->Load($id); @@ -314,12 +320,27 @@ CustomFieldObj => $CustomFieldObj, CustomFieldValueObj => $cfv, ARGSRef => \%ARG } } +if ( $CustomFieldObj->id && $CustomFieldObj->IsOnlyGlobal ) { + my ( $ret, $msg ); + my $object = $CustomFieldObj->RecordClassFromLookupType->new( $session{'CurrentUser'} ); + + if ( $CustomFieldObj->Disabled && $CustomFieldObj->IsGlobal ) { + ( $ret, $msg ) = $CustomFieldObj->RemoveFromObject($object); + } + elsif ( !$CustomFieldObj->Disabled && !$CustomFieldObj->IsGlobal ) { + ( $ret, $msg ) = $CustomFieldObj->AddToObject($object); + } + + # successful msg("object created" or "object deleted ) is useless here + push @results, $msg unless $ret; +} + $id = $CustomFieldObj->id if $CustomFieldObj->id; # This code does automatic redirection if any updates happen. MaybeRedirectForResults( Actions => \@results, - Arguments => { id => $id }, + Arguments => { id => $id, FocusAddValue => ($added_cfv ? 1 : 0) }, ) if $CustomFieldObj->id; diff --git a/rt/share/html/Admin/CustomFields/Objects.html b/rt/share/html/Admin/CustomFields/Objects.html index aac209461..2e0a3dc83 100644 --- a/rt/share/html/Admin/CustomFields/Objects.html +++ b/rt/share/html/Admin/CustomFields/Objects.html @@ -53,23 +53,23 @@ <form action="Objects.html" method="post"> <input type="hidden" class="hidden" name="id" value="<% $id %>" /> -% if ( $is_global ) { +% if ( $CF->IsGlobal ) { <h2><&|/l&>Applies to all objects</&></h2> -<input type="checkbox" name="RemoveCustomField-<% $CF->id %>" value="0" /> -<&|/l&>check this box to remove this Custom Field from all objects and be able to choose specific objects.</&> +<input type="checkbox" id="RemoveCustomField-<% $CF->id %>" name="RemoveCustomField-<% $CF->id %>" value="0" /> +<label for="RemoveCustomField-<% $CF->id %>"><&|/l&>check this box to remove this Custom Field from all objects and be able to choose specific objects.</&></label> % } else { <h2><&|/l&>Apply globally</&></h2> -<input type="checkbox" name="AddCustomField-<% $CF->id %>" value="0" /> -<&|/l&>check this box to apply this Custom Field to all objects.</&> +<input type="checkbox" id="AddCustomField-<% $CF->id %>" name="AddCustomField-<% $CF->id %>" value="0" /> +<label for="AddCustomField-<% $CF->id %>"><&|/l&>check this box to apply this Custom Field to all objects.</&></label> -% unless ( $CF->ApplyGlobally ) { +% unless ( $CF->IsOnlyGlobal ) { <h2><&|/l&>Selected objects</&></h2> <& /Elements/CollectionList, OrderBy => 'id', Order => 'ASC', %ARGS, - Collection => $applied, + Collection => $added, Rows => 0, Page => 1, Format => $format, @@ -86,8 +86,8 @@ OrderBy => 'id', Order => 'ASC', %ARGS, - Collection => $not_applied, - Rows => 50, + Collection => $not_added, + Rows => $rows, Format => $format, DisplayFormat => "'__CheckBox.{AddCustomField-". $CF->id ."}__',". $format, AllowSorting => 1, @@ -141,16 +141,15 @@ if ( $UpdateObjs ) { } } -my $is_global = $CF->IsApplied(0); +my $added = $CF->AddedTo; +my $not_added = $CF->NotAddedTo; -my $applied = $CF->AppliedTo; -my $not_applied = $CF->NotAppliedTo; - -my $collection_class = ref($applied); +my $collection_class = ref($added); $collection_class =~ s/^RT:://; my $format = RT->Config->Get('AdminSearchResultFormat')->{$collection_class} || '__id__,__Name__'; +my $rows = RT->Config->Get('AdminSearchResultRows')->{$collection_class} || 50; my $title = loc('Modify associated objects for [_1]', $CF->Name); diff --git a/rt/share/html/Admin/CustomFields/index.html b/rt/share/html/Admin/CustomFields/index.html index e8687ed21..cd9884f15 100644 --- a/rt/share/html/Admin/CustomFields/index.html +++ b/rt/share/html/Admin/CustomFields/index.html @@ -49,24 +49,7 @@ <& /Elements/Tabs &> % my $tmp = RT::CustomField->new( $session{'CurrentUser'} ); -% if ( $Type ) { -<h2><% loc("Custom Fields for [_1]", $tmp->FriendlyLookupType( $Type )) %></h2> -% } - -<& /Elements/CollectionList, - OrderBy => 'LookupType|Name', - Order => 'ASC|ASC', - Rows => 50, - %ARGS, - Collection => $CustomFields, - Format => $Format, - DisplayFormat => ($Type? '' : '__FriendlyLookupType__,'). $Format, - AllowSorting => 1, - PassArguments => [ - qw(Format Rows Page Order OrderBy), - qw(Type ShowDisabled) - ], -&> +<h1><% $Type ? loc("Custom Fields for [_1]", $Type) : loc('All Custom Fields') %></h1> <form action="<%RT->Config->Get('WebPath')%>/Admin/CustomFields/index.html" method="get"> <&|/l&>Only show custom fields for:</&> @@ -77,15 +60,30 @@ % } </select> <br /> -<input type="checkbox" class="checkbox" name="ShowDisabled" value="1" <% $ShowDisabled && 'checked="checked"' |n%> /> -<&|/l&>Include disabled custom fields in listing.</&> +<input type="checkbox" class="checkbox" id="ShowDisabled" name="ShowDisabled" value="1" <% $ShowDisabled && 'checked="checked"' |n %> /> +<label for="ShowDisabled"><&|/l&>Include disabled custom fields in listing.</&></label> <br /> % $m->callback(CallbackName => 'BeforeSubmit'); -<input type="submit" value="<% loc('Go!') %>" /> +<div align="right"><input type="submit" value="<% loc('Go!') %>" /></div> </form> +<& /Elements/CollectionList, + OrderBy => 'LookupType|Name', + Order => 'ASC|ASC', + Rows => $Rows, + %ARGS, + Collection => $CustomFields, + Format => $Format, + DisplayFormat => ($Type? '' : '__FriendlyLookupType__,'). $Format, + AllowSorting => 1, + PassArguments => [ + qw(Format Rows Page Order OrderBy), + qw(Type ShowDisabled) + ], +&> + <%args> $Type => '' $ShowDisabled => 0 @@ -95,12 +93,6 @@ $Format => undef <%INIT> my $title = loc('Select a Custom Field'); -$Type ||= $ARGS{'type'} || ''; -if ( !$Type && $ARGS{'type'} ) { - $Type ||= $ARGS{'type'}; - $RT::Logger->warning("'type' argument is deprecated use 'Type' instead"); -} - my $CustomFields = RT::CustomFields->new($session{'CurrentUser'}); $CustomFields->UnLimit; $CustomFields->FindAllRows if $ShowDisabled; @@ -109,5 +101,6 @@ $CustomFields->LimitToLookupType( $Type ) if $Type; $m->callback(CallbackName => 'MassageCustomFields', CustomFields => $CustomFields); $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'CustomFields'}; +my $Rows = RT->Config->Get('AdminSearchResultRows')->{'CustomFields'} || 50; </%INIT> |