[Rt-commit] rt branch, 4.2/keep-date-cf-value-on-create, created. rt-4.2.6-34-g720a072
? sunnavy
sunnavy at bestpractical.com
Tue Aug 5 08:20:39 EDT 2014
The branch, 4.2/keep-date-cf-value-on-create has been created
at 720a072c103009484f1e26e53eb20f1591e91c0e (commit)
- Log -----------------------------------------------------------------
commit 3433e121d309dd04a2be09707572d77e6edab56c
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Nov 29 15:01:39 2012 -0500
Add tests showing date CF value is lost on add attachment submit
diff --git a/t/web/cf_date.t b/t/web/cf_date.t
index 5dff0a4..a06a428 100644
--- a/t/web/cf_date.t
+++ b/t/web/cf_date.t
@@ -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;
diff --git a/t/web/cf_datetime.t b/t/web/cf_datetime.t
index 07c6959..24c042e 100644
--- a/t/web/cf_datetime.t
+++ b/t/web/cf_datetime.t
@@ -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;
commit 720a072c103009484f1e26e53eb20f1591e91c0e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Aug 5 19:52:29 2014 +0800
fill the date cf inputs when creating tickets/txns
so they don't get missed when user clicks "add more files" or something like that.
diff --git a/share/html/Elements/EditCustomFieldDate b/share/html/Elements/EditCustomFieldDate
index c42c871..a0bbb60 100644
--- a/share/html/Elements/EditCustomFieldDate
+++ b/share/html/Elements/EditCustomFieldDate
@@ -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>
diff --git a/share/html/Elements/EditCustomFieldDateTime b/share/html/Elements/EditCustomFieldDateTime
index 4693e8e..368706d 100644
--- a/share/html/Elements/EditCustomFieldDateTime
+++ b/share/html/Elements/EditCustomFieldDateTime
@@ -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>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index e1a2ea3..ab5f271 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -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>
</&>
diff --git a/share/html/Ticket/Elements/EditTransactionCustomFields b/share/html/Ticket/Elements/EditTransactionCustomFields
index f64666a..4d0ba07 100644
--- a/share/html/Ticket/Elements/EditTransactionCustomFields
+++ b/share/html/Ticket/Elements/EditTransactionCustomFields
@@ -61,6 +61,7 @@
<& /Elements/EditCustomField,
CustomField => $CF,
Object => RT::Transaction->new( $session{'CurrentUser'} ),
+ %ARGS,
&>
% if (my $msg = $m->notes('InvalidField-' . $CF->Id)) {
<br />
diff --git a/share/html/Ticket/ModifyAll.html b/share/html/Ticket/ModifyAll.html
index f64613e..cbe24aa 100644
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -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 &>
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 3e610bc..6ccaddf 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -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>
</&>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list