[Rt-commit] rt branch, 4.2/date-input-keep-value, created. rt-4.0.6-337-g1706c74

? sunnavy sunnavy at bestpractical.com
Fri Jun 22 11:31:10 EDT 2012


The branch, 4.2/date-input-keep-value has been created
        at  1706c741c58cd9770e3ddd580dec7c82d5cab0cc (commit)

- Log -----------------------------------------------------------------
commit 01f7895cd0ec84cd5e2ee238db110ac801ca81fb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 28 12:58:58 2012 +0800

    we should keep the input value for cf date/datetime
    
    without that, we may lose its value if first "submit" fails.
    see #19660

diff --git a/share/html/Elements/EditCustomFieldDate b/share/html/Elements/EditCustomFieldDate
index c66640f..a1f6679 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", Default => $Default, current => 0, 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..e64b612 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", Default => $Default, current => 0 &> (<%$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 100755
--- 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";

commit 6849fa18f205a53010c9bec7502a3139f42bc012
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Apr 3 12:38:05 2012 +0800

    allow to delete a cf date value
    
    as now empty cf date input means delete only

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 89142b2..b23da7c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2630,9 +2630,6 @@ sub _ProcessObjectCustomFieldUpdates {
                 $values_hash{$val} = 1 if $val;
             }
 
-            # For Date Cfs, @values is empty when there is no changes (no datas in form input)
-            return @results if ( $cf->Type =~ /^Date(?:Time)?$/ && ! @values );
-
             $cf_values->RedoSearch;
             while ( my $cf_value = $cf_values->Next ) {
                 next if $values_hash{ $cf_value->id };

commit 1706c741c58cd9770e3ddd580dec7c82d5cab0cc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 22 23:28:50 2012 +0800

    keep values of ticket core date fields too
    
    instead of putting current value at the right of the input field in a paren,
    now we put the value in the input box directly.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index b23da7c..69c815c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2789,23 +2789,29 @@ sub ProcessTicketDates {
     #Run through each field in this list. update the value if apropriate
     foreach my $field (@date_fields) {
         next unless exists $ARGSRef->{ $field . '_Date' };
-        next if $ARGSRef->{ $field . '_Date' } eq '';
+        my $obj = $field . "Obj";
+        my $method = "Set$field";
 
-        my ( $code, $msg );
+        if ( $ARGSRef->{ $field . '_Date' } eq '' ) {
+            if ( $Ticket->$obj->Unix ) {
+                my ( $code, $msg ) = $Ticket->$method( '1970-01-01 00:00:00' );
+                push @results, $msg;
+            }
+        }
+        else {
 
-        my $DateObj = RT::Date->new( $session{'CurrentUser'} );
-        $DateObj->Set(
-            Format => 'unknown',
-            Value  => $ARGSRef->{ $field . '_Date' }
-        );
+            my $DateObj = RT::Date->new( $session{'CurrentUser'} );
+            $DateObj->Set(
+                Format => 'unknown',
+                Value  => $ARGSRef->{ $field . '_Date' }
+            );
 
-        my $obj = $field . "Obj";
-        if (    ( defined $DateObj->Unix )
-            and ( $DateObj->Unix != $Ticket->$obj()->Unix() ) )
-        {
-            my $method = "Set$field";
-            my ( $code, $msg ) = $Ticket->$method( $DateObj->ISO );
-            push @results, "$msg";
+            if (    ( defined $DateObj->Unix )
+                and ( $DateObj->Unix != $Ticket->$obj()->Unix() ) )
+            {
+                my ( $code, $msg ) = $Ticket->$method( $DateObj->ISO );
+                push @results, $msg;
+            }
         }
     }
 
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 3a77e96..59b19f0 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1936,15 +1936,20 @@ sub SetStarted {
         $time_obj->SetToNow();
     }
 
-    # We need $TicketAsSystem, in case the current user doesn't have
-    # ShowTicket
-    my $TicketAsSystem = RT::Ticket->new(RT->SystemUser);
-    $TicketAsSystem->Load( $self->Id );
-    # Now that we're starting, open this ticket
-    # TODO: do we really want to force this as policy? it should be a scrip
-    my $next = $TicketAsSystem->FirstActiveStatus;
-
-    $self->SetStatus( $next ) if defined $next;
+    # since we allow to unset Started, we need to check if it's "unset"
+    if ( $time_obj->Unix ) {
+
+        # We need $TicketAsSystem, in case the current user doesn't have
+        # ShowTicket
+        my $TicketAsSystem = RT::Ticket->new( RT->SystemUser );
+        $TicketAsSystem->Load( $self->Id );
+
+        # Now that we're starting, open this ticket
+        # TODO: do we really want to force this as policy? it should be a scrip
+        my $next = $TicketAsSystem->FirstActiveStatus;
+
+        $self->SetStatus($next) if defined $next;
+    }
 
     return ( $self->_Set( Field => 'Started', Value => $time_obj->ISO ) );
 
diff --git a/share/html/Ticket/Elements/EditDates b/share/html/Ticket/Elements/EditDates
index fb23981..ae77680 100755
--- a/share/html/Ticket/Elements/EditDates
+++ b/share/html/Ticket/Elements/EditDates
@@ -48,12 +48,15 @@
 <table>
   <tr>
     <td class="label"><&|/l&>Starts</&>:</td>
-    <td class="entry"><& /Elements/SelectDate, menu_prefix => 'Starts', current => 0 &> 
-        (<% $TicketObj->StartsObj->AsString %>)</td>
+    <td class="entry">
+        <& /Elements/SelectDate, menu_prefix => 'Starts', current => 0, Default => $TicketObj->StartsObj->Unix ? $TicketObj->StartsObj->ISO( Timezone => 'user' ) : '' &>
+    </td>
   </tr>
   <tr>
     <td class="label"><&|/l&>Started</&>:</td>
-    <td class="entry"><& /Elements/SelectDate, menu_prefix => 'Started', current => 0 &> (<%$TicketObj->StartedObj->AsString %>)</td>
+    <td class="entry">
+        <& /Elements/SelectDate, menu_prefix => 'Started', current => 0, Default => $TicketObj->StartedObj->Unix ? $TicketObj->StartedObj->ISO( Timezone => 'user' )  : '' &>
+    </td>
   </tr>
 
   <tr>
@@ -61,13 +64,13 @@
       <&|/l&>Last Contact</&>:
     </td>
     <td class="entry">
-      <& /Elements/SelectDate, menu_prefix => 'Told', current => 0 &> (<% $TicketObj->ToldObj->AsString %>)
+        <& /Elements/SelectDate, menu_prefix => 'Told', current => 0, Default => $TicketObj->ToldObj->Unix ?  $TicketObj->ToldObj->ISO(Timezone => 'user') : '' &>
     </td>
   </tr>
   <tr>
     <td class="label"><&|/l&>Due</&>:</td>
     <td class="entry">
-      <& /Elements/SelectDate, menu_prefix => 'Due', current => 0 &> (<% $TicketObj->DueObj->AsString %>)
+      <& /Elements/SelectDate, menu_prefix => 'Due', current => 0, Default => $TicketObj->DueObj->Unix ? $TicketObj->DueObj->ISO(Timezone => 'user') : '' &>
     </td>
   </tr>
 % $m->callback( %ARGS, CallbackName => 'EndOfList', Ticket => $TicketObj );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list