Commit 86accd9d authored by Jim Brandt's avatar Jim Brandt
Browse files

Add MandatoryOnTransition checking on mobile updates

This update requires the included patch to add the needed
callbacks to the mobile reply page.
parent 88de111c
<%args>
$Ticket
</%args>
<%init>
my ($core, $cfs) = RT::Extension::MandatoryOnTransition->RequiredFields(
Ticket => $Ticket,
To => $ARGS{'Status'} || $ARGS{'DefaultStatus'},
);
return unless @$cfs;
</%init>
%# 'Named' is handled by this extension in the MassageCustomFields callback
<& /Ticket/Elements/EditCustomFields,
%ARGS,
TicketObj => $Ticket,
InTable => 0,
Named => $cfs,
&>
<%args>
$TicketObj
$ARGSRef
$skip_update
$results => []
</%args>
<%init>
my $errors_ref = RT::Extension::MandatoryOnTransition->CheckMandatoryFields(
ARGSRef => $ARGSRef,
Ticket => $TicketObj,
To => $ARGSRef->{'Status'},
);
if (@$errors_ref) {
RT->Logger->debug("Preventing update because of missing mandatory fields");
$$skip_update = 1;
push @$results, @$errors_ref;
}
</%init>
diff --git a/share/html/m/_elements/raw_style b/share/html/m/_elements/raw_style
index 02c95b5..e19e2a6 100644
--- a/share/html/m/_elements/raw_style
+++ b/share/html/m/_elements/raw_style
@@ -153,7 +153,7 @@ hr.clear {
}
-.label, .labeltop {
+.label, .labeltop, .cflabel {
font-weight: normal;
}
.value {
@@ -449,7 +449,7 @@ div.txn-content {
}
-.label {
+.label, .cflabel {
text-align: left;
width: 10em;
color: #666;
diff --git a/share/html/m/ticket/reply b/share/html/m/ticket/reply
index 00c8e2b..18587bc 100644
--- a/share/html/m/ticket/reply
+++ b/share/html/m/ticket/reply
@@ -81,6 +81,7 @@
InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
&>
</span></div>
+% $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $t );
<input type="hidden" class="hidden" name="id" value="<%$t->Id%>" /><br />
<div class="entry"><span class="label"><&|/l&>Update Type</&>:</span>
<div class="value"><select name="UpdateType">
@@ -240,12 +241,17 @@ $m->comp( '/Elements/GnuPG/SignEncryptWidget:Process',
TicketObj => $t,
);
-if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {
+my $skip_update = 0;
+$m->callback( CallbackName => 'BeforeUpdate', ARGSRef => \%ARGS, skip_update => \$skip_update,
+ checks_failure => $checks_failure, results => \@results, TicketObj => $t );
+
+if ( !$checks_failure && !$skip_update && exists $ARGS{SubmitTicket} ) {
my $status = $m->comp('/Elements/GnuPG/SignEncryptWidget:Check',
self => $gnupg_widget,
TicketObj => $t,
);
$checks_failure = 1 unless $status;
+ $m->callback( Ticket => $t, ARGSRef => \%ARGS, CallbackName => 'BeforeDisplay' );
return $m->comp('/m/ticket/show', TicketObj => $t, %ARGS);
}
</%INIT>
use strict;
use warnings;
use RT::Extension::MandatoryOnTransition::Test tests => 20;
use RT::Extension::MandatoryOnTransition::Test tests => 37;
use_ok('RT::Extension::MandatoryOnTransition');
......@@ -10,6 +10,22 @@ my ( $baseurl, $m ) = RT::Test->started_ok();
ok( $m->login( 'root', 'password' ), 'logged in' );
$m->get_ok($m->rt_base_url);
my $cf = RT::CustomField->new($RT::SystemUser);
my ( $id, $ret, $msg );
diag "Create custom field";
( $id, $msg ) = $cf->Create(
Name => 'Test Field',
Type => 'Select',
LookupType => 'RT::Queue-RT::Ticket',
MaxValues => '1',
Queue => 'General',
);
ok( $id, $msg );
$cf->AddValue( Name => 'foo' );
$cf->AddValue( Name => 'bar' );
diag "Try a resolve without TimeWorked";
{
my $t = RT::Test->create_ticket(
......@@ -27,12 +43,53 @@ diag "Try a resolve without TimeWorked";
button => 'SubmitTicket',},
'Submit resolve with no Time Worked');
$m->content_contains('Time Worked is required when changing Status to resolved');
$m->content_contains('Test Field is required when changing Status to resolved');
$m->submit_form_ok( { form_name => 'TicketUpdate',
fields => { UpdateTimeWorked => 10 },
fields => { UpdateTimeWorked => 10,
'Object-RT::Ticket-' . $t->id . '-CustomField-1-Values' => 'foo'},
button => 'SubmitTicket',
}, 'Submit resolve with Time Worked');
}, 'Submit resolve with Time Worked and Test Field');
$m->content_contains("TimeWorked changed from &#40;no value&#41; to &#39;10&#39;");
$m->content_contains("Status changed from &#39;open&#39; to &#39;resolved&#39;");
}
diag "Try a resolve without TimeWorked in mobile interface";
{
$m->get_ok($m->rt_base_url . "/m/");
$m->follow_link_ok( { text => 'New ticket' }, 'Click New ticket');
$m->title_is('Create a ticket');
$m->follow_link_ok( { text => 'General' }, 'Click General queue');
$m->title_is('Create a ticket');
$m->submit_form_ok( { form_name => 'TicketCreate',
}, 'Create new ticket');
my $title = $m->title();
my ($ticket_id) = $title =~ /^#(\d+)/;
like( $ticket_id, qr/\d+/, "Got number $ticket_id for ticket id");
$m->get_ok($m->rt_base_url . "/m/ticket/show/?id=$ticket_id");
$m->follow_link_ok( { text => 'Reply' }, 'Click Reply link');
$m->submit_form_ok( { form_number => 1,
fields => { Status => 'resolved' },
button => 'SubmitTicket',
}, 'Submit resolve with no Time Worked');
$m->content_contains('Time Worked is required when changing Status to resolved');
$m->content_contains('Test Field is required when changing Status to resolved');
$m->submit_form_ok( { form_number => 1,
fields => { UpdateTimeWorked => 10,
'Object-RT::Ticket-' . $ticket_id . '-CustomField-1-Values' => 'foo'},
button => 'SubmitTicket',
}, 'Submit resolve with Time Worked and Test Field');
# Try to confirm the page was updated.
$m->title_like(qr/^#$ticket_id:/, "Page title starts with ticket number $ticket_id");
like($m->uri->as_string, qr/show/, "On show page after ticket resolve");
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment