X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FAdmin%2FCustomFields%2FModify.html;h=4b1d8d8a6362a5b72051c08aa38e53fa9588cc21;hp=4ed86b60bfa0cc3e9999d43fbcc0aa1b6093ed95;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7 diff --git a/rt/share/html/Admin/CustomFields/Modify.html b/rt/share/html/Admin/CustomFields/Modify.html index 4ed86b60b..4b1d8d8a6 100644 --- a/rt/share/html/Admin/CustomFields/Modify.html +++ b/rt/share/html/Admin/CustomFields/Modify.html @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -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 @@ <&|/l&>Some browsers may only load content from the same domain as your RT server. -% if ( $CustomFieldObj->Id && $CustomFieldObj->IsSelectionType && !$CustomFieldObj->IsExternalValues ) { +% if ( $CustomFieldObj->Id && $CustomFieldObj->IsSelectionType ) { <&|/l&>Categories are based on <& /Admin/Elements/SelectCustomField, Name => "BasedOn", @@ -144,9 +149,14 @@   + /> +<&|/l&>Copy this field to new tickets + + +  - /> -<&|/l&>Enabled (Unchecking this box disables this custom field) + /> + % $m->callback(CallbackName => 'EndOfTable', CustomField => $CustomFieldObj, CFvalidations => \@CFvalidations); @@ -164,12 +174,13 @@ <& /Elements/Submit, Name => 'Update', Label => $id eq 'new'? loc('Create'): loc('Save Changes') &> +% $m->callback(%ARGS, CallbackName => 'EndOfPage', CustomFieldObj => $CustomFieldObj); <%INIT> -my ($title, @results); +my ($title, @results, $added_cfv); my $CustomFieldObj = RT::CustomField->new( $session{'CurrentUser'} ); -$m->callback(CallbackName => 'Initial', Pattern => \$Pattern, ARGSRef => \%ARGS); +$m->callback(CallbackName => 'Initial', Pattern => \$Pattern, Results => \@results, ARGSRef => \%ARGS); unless ( $id ) { $title = loc("Create a CustomField"); @@ -186,7 +197,8 @@ else { LinkValueTo => $LinkValueTo, IncludeContentForValue => $IncludeContentForValue, BasedOn => $BasedOn, - Disabled => !$Enabled, + Disabled => ($Enabled ? 0 : 1), + NoClone => !$YesClone, ); if (!$val) { push @results, loc("Could not create CustomField: [_1]", $msg); @@ -207,16 +219,26 @@ else { if ( $ARGS{'Update'} && $id ne 'new' ) { #we're asking about enabled on the web page but really care about disabled. $ARGS{'Disabled'} = $Enabled? 0 : 1; + # likewise + $ARGS{'NoClone'} = $YesClone ? 0 : 1; $ARGS{'Required'} ||= 0; - my @attribs = qw(Disabled Required Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue); + my @attribs = qw(Disabled Required Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue NoClone); push @results, UpdateRecordObject( AttributesRef => \@attribs, Object => $CustomFieldObj, ARGSRef => \%ARGS ); - $CustomFieldObj->SetValuesClass( $ValuesClass ); + if ( ($ValuesClass||'RT::CustomFieldValues') ne $CustomFieldObj->ValuesClass ) { + my $original = $CustomFieldObj->ValuesClass; + my ($good, $msg) = $CustomFieldObj->SetValuesClass( $ValuesClass ); + if ( $good ) { + $msg = loc("[_1] changed from '[_2]' to '[_3]'", + loc("Field values source"), $original, $ValuesClass ); + } + push @results, $msg; + } # Set the render type if we have it, but unset it if the new type doesn't # support render types @@ -250,7 +272,7 @@ if ( $ARGS{'Update'} && $id ne 'new' ) { my $paramtag = "CustomField-". $CustomFieldObj->Id ."-Value"; # Delete any fields that want to be deleted foreach my $key ( keys %ARGS ) { - next unless $key =~ /^Delete-$paramtag-(\d+)$/o; + next unless $key =~ /^Delete-$paramtag-(\d+)$/; my ($val, $msg) = $CustomFieldObj->DeleteValue( $1 ); push (@results, $msg); } @@ -290,6 +312,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); @@ -298,12 +321,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; @@ -313,6 +351,10 @@ $EnabledChecked = '' if $CustomFieldObj->Disabled; my $RequiredChecked = ''; $RequiredChecked = qq[checked="checked"] if $CustomFieldObj->Required; +my $YesCloneChecked = qq[checked="checked"]; +$YesCloneChecked = '' if $CustomFieldObj->NoClone; + + my @CFvalidations = ( '(?#Mandatory).', '(?#Digits)^[\d.]+$', @@ -325,7 +367,7 @@ $m->callback(CallbackName => 'ValidationPatterns', Values => \@CFvalidations); <%ARGS> $id => undef $TypeComposite => undef -$LookupType => undef +$LookupType => RT::Ticket->CustomFieldLookupType $MaxValues => undef $SortOrder => undef $Description => undef @@ -339,4 +381,5 @@ $LinkValueTo => undef $IncludeContentForValue => undef $BasedOn => undef $UILocation => undef +$YesClone => undef