[Rt-commit] rt branch, 4.0/preserve-time-units, updated. rt-4.0.1-218-gf8c79b9

Jason May jasonmay at bestpractical.com
Wed Nov 2 16:04:27 EDT 2011


The branch, 4.0/preserve-time-units has been updated
       via  f8c79b93207c932040882e53adc0db1e6874a9a4 (commit)
      from  31b9d7b154968efbbee0864b3ff0523dafb2b608 (commit)

Summary of changes:
 share/html/Elements/EditTimeValue   |   18 ++++++++++--------
 share/html/Elements/SelectTimeUnits |    8 +++-----
 share/html/Ticket/Create.html       |    6 +++---
 share/html/Ticket/Update.html       |    1 -
 share/html/m/ticket/create          |    3 ---
 share/html/m/ticket/reply           |    1 -
 t/web/ticket_modify_all.t           |    1 +
 7 files changed, 17 insertions(+), 21 deletions(-)

- Log -----------------------------------------------------------------
commit f8c79b93207c932040882e53adc0db1e6874a9a4
Author: Jason May <jasonmay at bestpractical.com>
Date:   Wed Nov 2 16:02:13 2011 -0400

    Instead of InputUnits, use the request arg with the config fallback
    
    InputUnits never worked correctly when it comes to context preservation.
    This approach also keeps be time unit fields from being unwillfully
    canonicalized in situations like when a CF validation fails or an
    attachment is added.

diff --git a/share/html/Elements/EditTimeValue b/share/html/Elements/EditTimeValue
index 54a0b50..a07a133 100644
--- a/share/html/Elements/EditTimeValue
+++ b/share/html/Elements/EditTimeValue
@@ -46,20 +46,22 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <input name="<% $ValueName %>" value="<% $Default || '' %>" size="5" />
-<& /Elements/SelectTimeUnits, Name => $UnitName, InputUnits => $InputUnits &>
+<& /Elements/SelectTimeUnits, Name => $UnitName, Default => $show_units &>
 <%ARGS>
 $Default    => ''
 $Name       => ''
 $ValueName  => ''
-$UnitName   => ''
-$InputUnits => 'minutes'
 </%ARGS>
 <%INIT>
-$ValueName ||= $Name;
-$UnitName  ||= ($Name||$ValueName) . '-TimeUnits';
+$ValueName  ||= $Name;
+my $UnitName  = $ValueName . '-TimeUnits';
 
-if ($InputUnits eq 'minutes' && RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'})) {
-    $Default = sprintf '%.3f', $Default / 60
-        unless $Default eq '';
+my $show_units = $m->request_args->{ $UnitName };
+$show_units ||= RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'});
+$show_units ||= 'minutes';
+
+if ( $Default && $show_units eq 'hours' ) {
+    $Default = sprintf '%.3f', $Default / 60;
+    $Default =~ s/\.000$//;
 }
 </%INIT>
diff --git a/share/html/Elements/SelectTimeUnits b/share/html/Elements/SelectTimeUnits
index 69ff4a2..dd1f907 100755
--- a/share/html/Elements/SelectTimeUnits
+++ b/share/html/Elements/SelectTimeUnits
@@ -45,20 +45,18 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% my $unit_selected = $HoursDefault ? 'hours' : $InputUnits;
 <select class="TimeUnits" id="<% $Name %>" name="<% $Name %>">
-<option value="minutes" <% $unit_selected eq 'hours' ? '' : 'selected="selected"' |n%>>
+<option value="minutes" <% $Default eq 'minutes' ? '' : 'selected="selected"' |n%>>
     <% loc('Minutes') %>
 </option>
-<option value="hours"   <% $unit_selected eq 'hours' ? 'selected="selected"' : '' |n%>>
+<option value="hours"   <% $Default eq 'hours'   ? 'selected="selected"' : '' |n%>>
     <% loc('Hours') %>
 </option>
 </select>
 <%INIT>
 $Name .= '-TimeUnits' unless $Name =~ /-TimeUnits$/io;
-my $HoursDefault = RT->Config->Get('DefaultTimeUnitsToHours', $session{'CurrentUser'});
 </%INIT>
 <%ARGS>
 $Name => ''
-$InputUnits => 'minutes'
+$Default => 'minutes'
 </%ARGS>
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 870eaee..2271cf2 100755
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -215,17 +215,17 @@
 &></td></tr>
 <tr><td class="label"><&|/l&>Time Estimated</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InputUnits => $ARGS{'TimeEstimated-TimeUnits'}||'minutes' &>
+<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '' &>
 
 </td></tr>
 <tr><td class="label"><&|/l&>Time Worked</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InputUnits => $ARGS{'TimeWorked-TimeUnits'}||'minutes' &>
+<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '' &>
 </td></tr>
 <tr>
 <td class="label"><&|/l&>Time Left</&>:</td>
 <td>
-<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InputUnits => $ARGS{'TimeLeft-TimeUnits'}||'minutes' &>
+<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '' &>
 </td></tr>
 </table>
 </&>
diff --git a/share/html/Ticket/Update.html b/share/html/Ticket/Update.html
index 08edc4b..7e43e91 100755
--- a/share/html/Ticket/Update.html
+++ b/share/html/Ticket/Update.html
@@ -128,7 +128,6 @@
             args => {
                 Name => 'UpdateTimeWorked',
                 Default => $ARGS{UpdateTimeWorked}||'',
-                InputUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
             }
         },
     ]
diff --git a/share/html/m/ticket/create b/share/html/m/ticket/create
index bd65af8..19e954b 100644
--- a/share/html/m/ticket/create
+++ b/share/html/m/ticket/create
@@ -388,21 +388,18 @@ $showrows->(
         "/Elements/EditTimeValue",
         Name    => 'TimeEstimated',
         Default => $ARGS{TimeEstimated} || '',
-        InputUnits => $ARGS{'TimeEstimated-TimeUnits'}
         ).'</span>',
 
     loc("Time Worked") => '<span class="timefield">'.$m->scomp(
         "/Elements/EditTimeValue",
         Name    => 'TimeWorked',
         Default => $ARGS{TimeWorked} || '',
-        InputUnits => $ARGS{'TimeWorked-TimeUnits'}
     ). '</span>',
 
     loc("Time Left") => '<span class="timefield">'.$m->scomp(
         "/Elements/EditTimeValue",
         Name    => 'TimeLeft',
         Default => $ARGS{TimeLeft} || '',
-        InputUnits => $ARGS{'TimeLeft-TimeUnits'}
     ).'</span>',
 );
 
diff --git a/share/html/m/ticket/reply b/share/html/m/ticket/reply
index 9c4a50d..557b326 100644
--- a/share/html/m/ticket/reply
+++ b/share/html/m/ticket/reply
@@ -74,7 +74,6 @@
 <& /Elements/EditTimeValue,
     Name => 'UpdateTimeWorked',
     Default => $ARGS{UpdateTimeWorked}||'',
-    InputUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
 &>
 </span></div>
 <input type="hidden" class="hidden" name="id" value="<%$t->Id%>" /><br />
diff --git a/t/web/ticket_modify_all.t b/t/web/ticket_modify_all.t
index 2bbcb4f..41030b1 100644
--- a/t/web/ticket_modify_all.t
+++ b/t/web/ticket_modify_all.t
@@ -30,6 +30,7 @@ $m->content_contains("this is update content", 'updated content in display page'
 for (qw/Estimated Worked Left/) {
     $m->goto_create_ticket(1);
     $m->form_name('TicketCreate');
+    $m->field("Time${_}" => "1");
     $m->select("Time${_}-TimeUnits" => 'hours');
     $m->click('AddMoreAttach');
     $m->form_name('TicketCreate');

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


More information about the Rt-commit mailing list