[Rt-commit] rt branch, 4.0/pass-default-for-date-fields, created. rt-4.0.8-195-g78987a9
Jim Brandt
jbrandt at bestpractical.com
Thu Jan 3 10:35:39 EST 2013
The branch, 4.0/pass-default-for-date-fields has been created
at 78987a967d890780995c1c62e304a69f544d3cd7 (commit)
- Log -----------------------------------------------------------------
commit 80bdc4b41b82abd5f4538b30af9ee9f9de1df0c3
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 4ea93e4..87731f1 100644
--- a/t/web/cf_date.t
+++ b/t/web/cf_date.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 35;
+use RT::Test tests => 43;
my ( $baseurl, $m ) = RT::Test->started_ok;
ok $m->login, 'logged in as root';
@@ -184,3 +184,44 @@ diag 'check invalid inputs';
$m->content_contains('test cf date:', 'has no cf date field on the page' );
$m->content_lacks('foodate', 'invalid dates not set' );
}
+
+diag 'retain values when adding attachments';
+{
+ my ( $ticket, $id );
+
+ $m->submit_form(
+ form_name => "CreateTicketInQueue",
+ fields => { Queue => 'General' },
+ );
+ $m->content_contains('Select date', 'has cf field' );
+
+ $m->submit_form_ok(
+ { form_name => "TicketCreate",
+ fields => {
+ Subject => 'test 2015-06-04',
+ Content => 'test',
+ },},
+ 'Create test ticket'
+ );
+
+ ok( ($id) = $m->content =~ /Ticket (\d+) created/, "Created ticket $id" );
+ $m->follow_link_ok( {text => 'Jumbo'} );
+ $m->title_like( qr/Jumbo/ );
+
+ $m->submit_form_ok(
+ { form_name => "TicketModifyAll",
+ fields => {
+ "Object-RT::Ticket-$id-CustomField-$cfid-Values" => '2015-06-04',
+ },
+ button => 'AddMoreAttach',
+ },
+ 'Create test ticket'
+ );
+
+ $m->title_like( qr/Jumbo/ );
+
+ $m->form_name("TicketModifyAll");
+ is($m->value("Object-RT::Ticket-$id-CustomField-$cfid-Values"),
+ "2015-06-04",
+ "Date value still on form" );
+}
commit 78987a967d890780995c1c62e304a69f544d3cd7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Nov 29 11:02:33 2012 -0500
Pass Default value to SelectDate
The Default value is passed to EditCustomFieldDate and
EditCustomFieldDateTime, but they don't pass it along to
SelectDate. Without it, any value provided is lost when reloading
the page but not submitting, like after adding an attachment.
In SelectDate, Value was being defaulted with ||, but this
incorrectly set it to undef when Value was the empty string
and Default was undef.
diff --git a/share/html/Elements/EditCustomFieldDate b/share/html/Elements/EditCustomFieldDate
index c66640f..ceed2db 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)%>)
+<& /Elements/SelectDate, Name => "$name", current => 0, Default => $Default, ShowTime => 0 &> (<%$DateObj->AsString(Time => 0)%>)
<%INIT>
my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
diff --git a/share/html/Elements/EditCustomFieldDateTime b/share/html/Elements/EditCustomFieldDateTime
index a558884..0e5ad8d 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, Default => $Default &> (<%$DateObj->AsString%>)
<%INIT>
my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
diff --git a/share/html/Elements/SelectDate b/share/html/Elements/SelectDate
index 18b42ad..251f58f 100644
--- a/share/html/Elements/SelectDate
+++ b/share/html/Elements/SelectDate
@@ -57,7 +57,7 @@ unless ((defined $Default) or
$year+1900,$mon+1,$mday,
$hour,$min);
}
-$Value = $Value || $Default;
+$Value = $Value || $Default || '';
unless ($Name) {
$Name = $menu_prefix. "_Date";
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list