[Rt-commit] rt branch, 4.0/keep-date-cf-value-on-create, created. rt-4.0.21-8-g19f278c
? sunnavy
sunnavy at bestpractical.com
Sun Jul 27 08:22:49 EDT 2014
The branch, 4.0/keep-date-cf-value-on-create has been created
at 19f278c1d520f5028621f9a15930dfd5ef687267 (commit)
- Log -----------------------------------------------------------------
commit ca05c379c878df6e576c59e63a59699015071b2c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jul 27 18:54:13 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 f62f047..c430b0b 100644
--- a/share/html/Elements/EditCustomFieldDate
+++ b/share/html/Elements/EditCustomFieldDate
@@ -46,7 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
% my $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'} );
@@ -59,4 +59,5 @@ $NamePrefix => undef
$Default => undef
$Values => undef
$MaxValues => 1
+$KeepValue => undef
</%ARGS>
diff --git a/share/html/Elements/EditCustomFieldDateTime b/share/html/Elements/EditCustomFieldDateTime
index edf125e..b50ea43 100644
--- a/share/html/Elements/EditCustomFieldDateTime
+++ b/share/html/Elements/EditCustomFieldDateTime
@@ -46,7 +46,7 @@
%#
%# END BPS TAGGED BLOCK }}}
% my $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'} );
@@ -60,4 +60,5 @@ $Default => undef
$Values => undef
$MaxValues => 1
$Format => 'ISO'
+$KeepValue => undef
</%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index a33757f..69f3036 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -101,8 +101,8 @@
% $m->callback( CallbackName => 'AfterOwner', ARGSRef => \%ARGS );
- <& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
- <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1 &>
+ <& /Ticket/Elements/EditCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1, KeepValue => 1 &>
+ <& /Ticket/Elements/EditTransactionCustomFields, %ARGS, QueueObj => $QueueObj, InTable => 1, KeepValue => 1 &>
</table>
</&>
% $m->callback( CallbackName => 'AfterBasics', QueueObj => $QueueObj, ARGSRef => \%ARGS );
diff --git a/share/html/Ticket/Elements/EditTransactionCustomFields b/share/html/Ticket/Elements/EditTransactionCustomFields
index ffd78cf..c33f47c 100644
--- a/share/html/Ticket/Elements/EditTransactionCustomFields
+++ b/share/html/Ticket/Elements/EditTransactionCustomFields
@@ -60,7 +60,8 @@
<<% $CELL %>>
<& /Elements/EditCustomField,
CustomField => $CF,
- NamePrefix => $NamePrefix
+ NamePrefix => $NamePrefix,
+ %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 21f0d1c..e890c80 100644
--- a/share/html/Ticket/ModifyAll.html
+++ b/share/html/Ticket/ModifyAll.html
@@ -105,7 +105,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 8fad1fd..9501b5c 100644
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -136,7 +136,7 @@
% $m->callback( %ARGS, CallbackName => 'AfterWorked', Ticket => $TicketObj );
-<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, AsTable => 1 &>
+<& /Ticket/Elements/EditTransactionCustomFields, %ARGS, TicketObj => $TicketObj, AsTable => 1, KeepValue => 1 &>
</table>
</&>
commit 19f278c1d520f5028621f9a15930dfd5ef687267
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 e69833c..2180e14 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 4580c4a..72a8b3f 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;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list