[Rt-commit] rt branch, 4.0/add-date-datetime-to-bulk-update, created. rt-4.0.18-127-ga5da163
Jim Brandt
jbrandt at bestpractical.com
Fri Jan 17 10:32:34 EST 2014
The branch, 4.0/add-date-datetime-to-bulk-update has been created
at a5da1630751326fcad4d9bc06c63a5aa9404ef6a (commit)
- Log -----------------------------------------------------------------
commit a5da1630751326fcad4d9bc06c63a5aa9404ef6a
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Thu Aug 22 18:55:30 2013 -0400
Add Date and DateTime CFs to bulk update
Date conversion is needed only for delete because AddValueForObject
in RT::CustomField calls CanonicalizeValue methods to handle
conversion on add.
For Date and DateTime, pass undef for Default to assure that we
don't incorrectly imply that there will be a default value set
if the box is left empty. This inconsistency has been resolved in
4.4 via 4.4/date-input-keep-value
@values is checked for length, otherwise empty string values
are submitted for empty fields resulting in update messages
noting "Not set changed to Not set".
diff --git a/share/html/Elements/EditCustomFieldDateTime b/share/html/Elements/EditCustomFieldDateTime
index 3d94855..761d8fc 100644
--- a/share/html/Elements/EditCustomFieldDateTime
+++ b/share/html/Elements/EditCustomFieldDateTime
@@ -50,7 +50,7 @@
<%INIT>
my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
-$DateObj->Set( Format => 'ISO', Value => $Default );
+$DateObj->Set( Format => $Format, Value => $Default );
</%INIT>
<%ARGS>
$Object => undef
@@ -59,4 +59,5 @@ $NamePrefix => undef
$Default => undef
$Values => undef
$MaxValues => 1
+$Format => 'ISO'
</%ARGS>
diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html
index 5cc4000..056a761 100644
--- a/share/html/Search/Bulk.html
+++ b/share/html/Search/Bulk.html
@@ -196,6 +196,13 @@ $cfs->LimitToQueue($_) for keys %$seen_queues;
% } elsif ($cf->Type eq 'Text') {
<td><& /Elements/EditCustomFieldText, @add &></td>
<td> </td>
+% } elsif ($cf->Type eq 'Date') {
+<td><& /Elements/EditCustomFieldDate, @add, Default => undef &></td>
+<td><& /Elements/EditCustomFieldDate, @del, Default => undef &></td>
+% } elsif ($cf->Type eq 'DateTime') {
+% # Pass datemanip format to prevent another tz date conversion
+<td><& /Elements/EditCustomFieldDateTime, @add, Default => undef, Format => 'datemanip' &></td>
+<td><& /Elements/EditCustomFieldDateTime, @del, Default => undef, Format => 'datemanip' &></td>
% } else {
% $RT::Logger->crit("Unknown CustomField type: " . $cf->Type);
% }
@@ -359,7 +366,27 @@ unless ( $ARGS{'AddMoreAttach'} ) {
unless ( $cf->SingleValue );
my $current_values = $Ticket->CustomFieldValues($cfid);
+
+ if ( $cf->Type eq 'DateTime' || $cf->Type eq 'Date' ){
+ # Clear out empty string submissions to avoid
+ # Not set changed to Not set
+ @values = grep length, @values;
+ }
+
foreach my $value (@values) {
+
+ # Convert for timezone. Without converstion,
+ # HasEntry and DeleteCustomFieldValue fail because
+ # the value in the DB is converted.
+ if ( $op eq 'del'
+ && ($cf->Type eq 'DateTime' || $cf->Type eq 'Date') ){
+ my $DateObj = RT::Date->new( $session{'CurrentUser'} );
+ $DateObj->Set( Format => 'unknown',
+ Value => $value );
+ $value = $cf->Type eq 'DateTime' ? $DateObj->ISO
+ : $DateObj->ISO(Time => 0, Seconds => 0);
+ }
+
if ( $op eq 'del' && $current_values->HasEntry($value) ) {
my ( $id, $msg ) = $Ticket->DeleteCustomFieldValue(
Field => $cfid,
-----------------------------------------------------------------------
More information about the rt-commit
mailing list