Commit 2c2ae8b5 authored by Alex Vandiver's avatar Alex Vandiver
Browse files

Merge branch '4.2/keep-date-cf-value-on-create' into 4.2-trunk

parents 501c6be3 0e46f07f
......@@ -46,7 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
% my $name = $Name || $NamePrefix.$CustomField->Id.'-Values';
<& /Elements/SelectDate, Name => "$name", current => 0, ShowTime => 0 &> (<%$DateObj->AsString(Time => 0, Timezone => 'utc')%>)
<& /Elements/SelectDate, Name => "$name", current => 0, ShowTime => 0, $KeepValue && $Default ? (Default => $Default) : () &> (<%$DateObj->AsString(Time => 0, Timezone => 'utc')%>)
<%INIT>
my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
......@@ -60,4 +60,5 @@ $Default => undef
$Values => undef
$MaxValues => 1
$Name => undef
$KeepValue => undef
</%ARGS>
......@@ -46,7 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
% my $name = $Name || $NamePrefix.$CustomField->Id.'-Values';
<& /Elements/SelectDate, Name => "$name", current => 0 &> (<%$DateObj->AsString%>)
<& /Elements/SelectDate, Name => "$name", current => 0, $KeepValue && $Default ? (Default => $Default) : () &> (<%$DateObj->AsString($KeepValue ? ( Timezone => 'utc' ) : () )%>)
<%INIT>
my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
......@@ -61,4 +61,5 @@ $Values => undef
$MaxValues => 1
$Name => undef
$Format => 'ISO'
$KeepValue => undef
</%ARGS>
......@@ -105,8 +105,9 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Basics',
InTable => 1,
KeepValue => 1,
&>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1, KeepValue => 1, &>
</table>
</&>
% $m->callback( CallbackName => 'AfterBasics', QueueObj => $QueueObj, ARGSRef => \%ARGS );
......@@ -115,6 +116,7 @@
%ARGS,
Object => $ticket,
CustomFieldGenerator => sub { $QueueObj->TicketCustomFields },
KeepValue => 1,
&>
</div>
......@@ -169,6 +171,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'People',
InTable => 1,
KeepValue => 1,
&>
<tr>
......@@ -263,6 +266,7 @@
CustomFields => $QueueObj->TicketCustomFields,
Grouping => 'Dates',
InTable => 1,
KeepValue => 1,
&>
</table>
</&>
......
......@@ -59,6 +59,7 @@
</<% $CELL %>>
<<% $CELL %>>
<& /Elements/EditCustomField,
%ARGS,
CustomField => $CF,
Object => RT::Transaction->new( $session{'CurrentUser'} ),
&>
......
......@@ -113,7 +113,7 @@
</td>
</tr>
<tr><td colspan="2"><& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $Ticket &></td></tr>
<tr><td colspan="2"><& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $Ticket, KeepValue => 1, &></td></tr>
<& /Ticket/Elements/AddAttachments, %ARGS, TicketObj => $Ticket &>
......
......@@ -134,7 +134,7 @@
% $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, InTable => 1 &>
<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, InTable => 1, KeepValue => 1, &>
</table>
</&>
......
......@@ -189,4 +189,85 @@ diag 'check invalid inputs';
is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} );
}
diag 'retain values when adding attachments';
{
my ( $ticket, $id );
my $txn_cf = RT::CustomField->new( RT->SystemUser );
my ( $ret, $msg ) = $txn_cf->Create(
Name => 'test txn cf date',
TypeComposite => 'Date-1',
LookupType => 'RT::Queue-RT::Ticket-RT::Transaction',
);
ok( $ret, "created 'txn datetime': $msg" );
$txn_cf->AddToObject(RT::Queue->new(RT->SystemUser));
my $txn_cfid = $txn_cf->id;
$m->submit_form(
form_name => "CreateTicketInQueue",
fields => { Queue => 'General' },
);
$m->content_contains('test cf date', 'has cf' );
$m->content_contains('test txn cf date', 'has txn cf' );
$m->submit_form_ok(
{
form_name => "TicketCreate",
fields => {
Subject => 'test 2015-06-04',
Content => 'test',
"Object-RT::Ticket--CustomField-$cfid-Values" => '2015-06-04',
"Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-08-15',
},
button => 'AddMoreAttach',
},
'create test ticket'
);
$m->form_name("TicketCreate");
is( $m->value( "Object-RT::Ticket--CustomField-$cfid-Values" ),
"2015-06-04", "ticket cf date value still on form" );
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-08-15", "txn cf date date value still on form" );
$m->submit_form();
ok( ($id) = $m->content =~ /Ticket (\d+) created/, "created ticket $id" );
$m->follow_link_ok( {text => 'Reply'} );
$m->title_like( qr/Update/ );
$m->content_contains('test txn cf date', 'has txn cf');
$m->submit_form_ok(
{
form_name => "TicketUpdate",
fields => {
Content => 'test',
"Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-09-16',
},
button => 'AddMoreAttach',
},
'Update test ticket'
);
$m->form_name("TicketUpdate");
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-09-16", "txn date value still on form" );
$m->follow_link_ok( {text => 'Jumbo'} );
$m->title_like( qr/Jumbo/ );
$m->submit_form_ok(
{
form_name => "TicketModifyAll",
fields => {
"Object-RT::Transaction--CustomField-$txn_cfid-Values" =>
'2015-12-16',
},
button => 'AddMoreAttach',
},
'jumbo form'
);
$m->form_name("TicketModifyAll");
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-12-16", "txn date value still on form" );
}
done_testing;
......@@ -215,6 +215,92 @@ diag 'check invalid inputs';
is_deeply( @warnings, q{Couldn't parse date 'foodate' by Time::ParseDate} );
}
diag 'retain values when adding attachments';
{
my ( $ticket, $id );
my $txn_cf = RT::CustomField->new( RT->SystemUser );
my ( $ret, $msg ) = $txn_cf->Create(
Name => 'test txn cf datetime',
TypeComposite => 'DateTime-1',
LookupType => 'RT::Queue-RT::Ticket-RT::Transaction',
);
ok( $ret, "created 'txn datetime': $msg" );
$txn_cf->AddToObject(RT::Queue->new(RT->SystemUser));
my $txn_cfid = $txn_cf->id;
$m->submit_form(
form_name => "CreateTicketInQueue",
fields => { Queue => 'General' },
);
$m->content_contains('test cf datetime', 'has cf' );
$m->content_contains('test txn cf datetime', 'has txn cf' );
$m->submit_form_ok(
{
form_name => "TicketCreate",
fields => {
Subject => 'test 2015-06-04',
Content => 'test',
"Object-RT::Ticket--CustomField-$cfid-Values" => '2015-06-04 08:30:00',
"Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-08-15 12:30:30',
},
button => 'AddMoreAttach',
},
'Create test ticket'
);
$m->form_name("TicketCreate");
is( $m->value( "Object-RT::Ticket--CustomField-$cfid-Values" ),
"2015-06-04 08:30:00", "ticket cf date value still on form" );
$m->content_contains( "Jun 04 08:30:00 2015", 'date in parens' );
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-08-15 12:30:30", "txn cf date date value still on form" );
$m->content_contains( "Aug 15 12:30:30 2015", 'date in parens' );
$m->submit_form();
ok( ($id) = $m->content =~ /Ticket (\d+) created/, "Created ticket $id" );
$m->follow_link_ok( {text => 'Reply'} );
$m->title_like( qr/Update/ );
$m->content_contains('test txn cf date', 'has txn cf');
$m->submit_form_ok(
{
form_name => "TicketUpdate",
fields => {
Content => 'test',
"Object-RT::Transaction--CustomField-$txn_cfid-Values" => '2015-09-16 09:30:40',
},
button => 'AddMoreAttach',
},
'Update test ticket'
);
$m->form_name("TicketUpdate");
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-09-16 09:30:40", "Date value still on form" );
$m->content_contains( "Sep 16 09:30:40 2015", 'date in parens' );
$m->follow_link_ok( {text => 'Jumbo'} );
$m->title_like( qr/Jumbo/ );
$m->submit_form_ok(
{
form_name => "TicketModifyAll",
fields => {
"Object-RT::Transaction--CustomField-$txn_cfid-Values" =>
'2015-12-16 03:00:00',
},
button => 'AddMoreAttach',
},
'jumbo form'
);
$m->save_content('/tmp/x.html');
$m->form_name("TicketModifyAll");
is( $m->value( "Object-RT::Transaction--CustomField-$txn_cfid-Values" ),
"2015-12-16 03:00:00", "txn date value still on form" );
$m->content_contains( "Dec 16 03:00:00 2015", 'date in parens' );
}
sub is_results_number {
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $fields = shift;
......
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