[Rt-commit] r18602 - in rt/3.8/trunk: . share/html/Ticket share/html/Ticket/Elements

sartak at bestpractical.com sartak at bestpractical.com
Thu Feb 26 17:43:20 EST 2009


Author: sartak
Date: Thu Feb 26 17:43:19 2009
New Revision: 18602

Added:
   rt/3.8/trunk/share/html/Elements/EditTimeValue
Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/share/html/Ticket/Create.html
   rt/3.8/trunk/share/html/Ticket/Elements/EditBasics
   rt/3.8/trunk/share/html/Ticket/Update.html

Log:
 r80661 at onn:  sartak | 2009-02-26 17:43:01 -0500
 Refactor time-input + select-time-units into a new template, EditTimeValue


Added: rt/3.8/trunk/share/html/Elements/EditTimeValue
==============================================================================
--- (empty file)
+++ rt/3.8/trunk/share/html/Elements/EditTimeValue	Thu Feb 26 17:43:19 2009
@@ -0,0 +1,65 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%# 
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%#                                          <jesse at bestpractical.com>
+%# 
+%# (Except where explicitly superseded by other copyright notices)
+%# 
+%# 
+%# LICENSE:
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%# 
+%# 
+%# CONTRIBUTION SUBMISSION POLICY:
+%# 
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%# 
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%# 
+%# END BPS TAGGED BLOCK }}}
+<input name="<% $ValueName %>" value="<% $Default %>" size="5" />
+<& /Elements/SelectTimeUnits, Name => $UnitName &>
+<%ARGS>
+$Default    => ''
+$Name       => ''
+$ValueName  => ''
+$UnitName   => ''
+$InputUnits => 'minutes'
+</%ARGS>
+<%INIT>
+$ValueName ||= $Name;
+$UnitName  ||= ($Name||$ValueName) . '-TimeUnits';
+
+if ($InputUnits eq 'minutes' && RT->Config->Get('DefaultTimeUnitsToHours')) {
+    $Default = sprintf '%.3g', $Default / 60
+        unless $Default eq '';
+}
+</%INIT>

Modified: rt/3.8/trunk/share/html/Ticket/Create.html
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Create.html	(original)
+++ rt/3.8/trunk/share/html/Ticket/Create.html	Thu Feb 26 17:43:19 2009
@@ -188,20 +188,17 @@
 &></td></tr>
 <tr><td class="label"><&|/l&>Time Estimated</&>:</td>
 <td>
-<input size="3" name="TimeEstimated" value="<%$ARGS{TimeEstimated} || ''%>" />
-<& /Elements/SelectTimeUnits, Name =>'TimeEstimated' &>
+<& /Elements/EditTimeValue, Name => 'TimeEstimated', Default => $ARGS{TimeEstimated} || '', InUnits => $ARGS{'TimeEstimated-TimeUnits'} &>
 
 </td></tr>
 <tr><td class="label"><&|/l&>Time Worked</&>:</td>
 <td>
-<input size="3" name="TimeWorked" value="<%$ARGS{TimeWorked} || ''%>" />
-<& /Elements/SelectTimeUnits, Name =>'TimeWorked' &>
-
+<& /Elements/EditTimeValue, Name => 'TimeWorked', Default => $ARGS{TimeWorked} || '', InUnits => $ARGS{'TimeWorked-TimeUnits'} &>
 </td></tr>
 <tr>
 <td class="label"><&|/l&>Time Left</&>:</td>
-<td><input size="3" name="TimeLeft" value="<%$ARGS{TimeLeft} || ''%>" />
-<& /Elements/SelectTimeUnits, Name =>'TimeLeft' &>
+<td>
+<& /Elements/EditTimeValue, Name => 'TimeLeft', Default => $ARGS{TimeLeft} || '', InUnits => $ARGS{'TimeLeft-TimeUnits'} &>
 </td></tr>
 </table>
 </&>

Modified: rt/3.8/trunk/share/html/Ticket/Elements/EditBasics
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Elements/EditBasics	(original)
+++ rt/3.8/trunk/share/html/Ticket/Elements/EditBasics	Thu Feb 26 17:43:19 2009
@@ -73,23 +73,28 @@
   <tr>
       <td class="label"><&|/l&>Time Estimated</&>:</td>
       <td class="value">
-        <input name="TimeEstimated" 
-            value="<% $TimeEstimated || '' |h%>" size="5" />
-        <& /Elements/SelectTimeUnits, Name =>'TimeEstimated' &>
+        <& /Elements/EditTimeValue,
+            Name => 'TimeEstimated',
+            Default => $TicketObj->TimeEstimated,
+        &>
       </td>
     </tr>
   <tr>
     <td class="label"><&|/l&>Time Worked</&>:</td>
     <td class="value">
-      <input name="TimeWorked" value="<% $TimeWorked || '' |h%>" size="5" />
-      <& /Elements/SelectTimeUnits, Name =>'TimeWorked' &>
+        <& /Elements/EditTimeValue,
+            Name => 'TimeWorked',
+            Default => $TicketObj->TimeWorked,
+        &>
     </td>
   </tr>
   <tr>
     <td class="label"><&|/l&>Time Left</&>:</td>
     <td class="value">
-        <input name="TimeLeft" value="<%$TimeLeft || ''|h%>" size="5" />
-        <& /Elements/SelectTimeUnits, Name =>'TimeLeft' &>
+        <& /Elements/EditTimeValue,
+            Name => 'TimeLeft',
+            Default => $TicketObj->TimeLeft,
+        &>
       </td>
     </tr>
 
@@ -118,18 +123,6 @@
 my $SelectStatus = $m->scomp("/Elements/SelectStatus", Name => 'Status', DefaultLabel => loc("[_1] (Unchanged)",loc($TicketObj->Status)));
 my $SelectQueue = $m->scomp("/Elements/SelectQueue", Name => 'Queue', Default =>$TicketObj->QueueObj->Id);
 
-my $TimeEstimated = $TicketObj->TimeEstimated;
-my $TimeWorked = $TicketObj->TimeWorked;
-my $TimeLeft = $TicketObj->TimeLeft;
-
-# Convert these values from minutes to hours
-if (RT->Config->Get('DefaultTimeUnitsToHours')) {
-    for ($TimeEstimated, $TimeWorked, $TimeLeft) {
-        # Do some rounding since 0.166666666666667 is pretty unhelpful
-        $_ = sprintf '%.3g', $_ / 60;
-    }
-}
-
 </%INIT>
 <%ARGS>
 

Modified: rt/3.8/trunk/share/html/Ticket/Update.html
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Update.html	(original)
+++ rt/3.8/trunk/share/html/Ticket/Update.html	Thu Feb 26 17:43:19 2009
@@ -75,8 +75,12 @@
     DefaultLabel => loc("[_1] (Unchanged)", $TicketObj->OwnerObj->Name),
     Default      => $ARGS{'Owner'}
 &>
-<span class="label"><&|/l&>Worked</&>:</span><input size="4" name="UpdateTimeWorked" value="<% $ARGS{UpdateTimeWorked}||'' %>" /> 
-<& /Elements/SelectTimeUnits, Name => 'UpdateTimeWorked'&>
+<span class="label"><&|/l&>Worked</&>:</span>
+<& /Elements/EditTimeValue,
+    Name => 'UpdateTimeWorkd',
+    Default => $ARGS{UpdateTimeWorked}||'',
+    InUnits => $ARGS{'UpdateTimeWorked-TimeUnits'}||'minutes',
+&>
 </td></tr>
 % my $skip;
 % $m->callback( %ARGS, CallbackName => 'BeforeUpdateType', skip => \$skip );


More information about the Rt-commit mailing list