diff options
Diffstat (limited to 'rt')
7 files changed, 75 insertions, 2 deletions
| diff --git a/rt/etc/schema.Pg b/rt/etc/schema.Pg index 48525c8d7..e3006d073 100755 --- a/rt/etc/schema.Pg +++ b/rt/etc/schema.Pg @@ -539,6 +539,7 @@ CREATE TABLE CustomFields (    LastUpdatedBy integer NOT NULL DEFAULT 0  ,    LastUpdated TIMESTAMP NULL  ,    Disabled integer NOT NULL DEFAULT 0 , +  Required integer NOT NULL DEFAULT 0 ,    PRIMARY KEY (id)  ); diff --git a/rt/lib/RT/CustomField.pm b/rt/lib/RT/CustomField.pm index 995728f67..dc4108044 100644 --- a/rt/lib/RT/CustomField.pm +++ b/rt/lib/RT/CustomField.pm @@ -122,6 +122,7 @@ sub Create {                  Disabled => '0',                  LinkToValue => '',                  IncludeContentForValue => '', +                Required => '0',                    @_);      $self->SUPER::Create( @@ -381,6 +382,8 @@ sub _CoreAccessible {  		{read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},          Disabled =>   		{read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'}, +        Required => +                {read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'},   }  }; diff --git a/rt/share/html/Admin/CustomFields/Modify.html b/rt/share/html/Admin/CustomFields/Modify.html index f75607a8d..d2932d2d9 100644 --- a/rt/share/html/Admin/CustomFields/Modify.html +++ b/rt/share/html/Admin/CustomFields/Modify.html @@ -119,6 +119,11 @@  % }  <tr><td class="label"> </td><td> +<input type="checkbox" class="checkbox" name="Required" value="1" <% $RequiredChecked |n%> /> +<&|/l&>Required for ticket resolution</&> +</td></tr> + +<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)</&> @@ -171,11 +176,12 @@ else {  }  if ( $ARGS{'Update'} && $id ne 'new' ) { -      #we're asking about enabled on the web page but really care about disabled.      $ARGS{'Disabled'} = $Disabled = $Enabled? 0 : 1; +    +    $ARGS{'Required'} ||= 0; -    my @attribs = qw(Disabled Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue); +    my @attribs = qw(Disabled Required Pattern Name TypeComposite LookupType Description LinkValueTo IncludeContentForValue);      push @results, UpdateRecordObject(          AttributesRef => \@attribs,          Object        => $CustomFieldObj, @@ -222,6 +228,9 @@ $id = $CustomFieldObj->id if $CustomFieldObj->id;  my $EnabledChecked = qq[checked="checked"];  $EnabledChecked = '' if $CustomFieldObj->Disabled; +my $RequiredChecked = ''; +$RequiredChecked = qq[checked="checked"] if $CustomFieldObj->Required; +  my @CFvalidations = (      '(?#Mandatory).',      '(?#Digits)^[\d.]+$', diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default new file mode 100644 index 000000000..2c0698ec2 --- /dev/null +++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default @@ -0,0 +1,12 @@ +<%doc> +If mandatory fields aren't set yet, point the "Resolve" link back +to "Ticket Basics". +</%doc> +<%init> +my $TicketObj = delete($ARGS{'Ticket'}); +my $actions = $ARGS{'actions'}; +if( $m->comp('/Ticket/Elements/CheckMandatoryFields', Ticket => $TicketObj)  +  ) { +  $actions->{'G'}->{'path'} = 'Ticket/Modify.html?id='.$TicketObj->Id.'&resolve=1'; +} +</%init> diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList new file mode 100644 index 000000000..4779411ce --- /dev/null +++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList @@ -0,0 +1,15 @@ +<%init> +use Data::Dumper; +my $ARGSRef = $ARGS{'ARGSRef'}; +my $TicketObj = $ARGS{'Ticket'}; +my $results = $ARGS{'Actions'}; +if(defined($ARGSRef->{'resolve'})) { +  my @errors =   +    $m->comp('/Ticket/Elements/CheckMandatoryFields', Ticket => $TicketObj); +  return if !@errors; +  my $msg = 'Missing required field'.(@errors > 1 ? 's' : '').': ' . +            join(', ', map { $_->Name } @errors); +  $m->notes( ('InvalidField-' . $_->Id) => 'Required' ) foreach @errors; +  push @$results, $msg; +} +</%init> diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay new file mode 100644 index 000000000..0d69bc27b --- /dev/null +++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay @@ -0,0 +1,24 @@ +<%doc> +When the user tries to change a ticket's status to "resolved" through  +the Update interface, check mandatory fields.  If they aren't all set,  +redirect to Ticket Basics instead of updating.  Note that this will  +lose any comments/time/other information the user has entered. +</%doc> + +<%init> +my $TicketObj = $ARGS{'Ticket'}; +my $ARGSRef = $ARGS{'ARGSRef'}; +my $oldStatus = $TicketObj->Status(); +my $newStatus = $ARGSRef->{'Status'} || $ARGSRef->{'DefaultStatus'}; +if( $oldStatus ne 'resolved' and  +    $newStatus eq 'resolved' and +    $m->comp('/Ticket/Elements/CheckMandatoryFields',  +              Ticket => $TicketObj +              ) ) { +    $m->clear_buffer; +    RT::Interface::Web::Redirect(  +      RT->Config->Get('WebURL')."Ticket/Modify.html?id=".$TicketObj->Id."&resolve=1" +    ); +    $m->abort; +} +</%init> diff --git a/rt/share/html/Ticket/Elements/CheckMandatoryFields b/rt/share/html/Ticket/Elements/CheckMandatoryFields new file mode 100644 index 000000000..3d0324f98 --- /dev/null +++ b/rt/share/html/Ticket/Elements/CheckMandatoryFields @@ -0,0 +1,9 @@ +<%init> + +my $TicketObj = $ARGS{'Ticket'} or return (); +my $ARGSRef = $ARGS{'ARGSRef'}; +my @fields = grep { $_->Required }  +             @{ $TicketObj->CustomFields->ItemsArrayRef }; +return grep { !defined($TicketObj->FirstCustomFieldValue($_->id)) } @fields; + +</%init> | 
