[interchange-cvs] interchange - heins modified 2 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Sun Nov 11 02:16:01 2001
User: heins
Date: 2001-11-11 07:15:30 GMT
Modified: dist/lib/UI Primitive.pm
Modified: dist/lib/UI/pages/include item_option_modular
Log:
* Fix the datetime widget so that it rounds the current time
or passed time up to the next fifteen minute increment for
default selection.
Revision Changes Path
2.10 +43 -5 interchange/dist/lib/UI/Primitive.pm
rev 2.10, prev_rev 2.9
Index: Primitive.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/Primitive.pm,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -r2.9 -r2.10
--- Primitive.pm 2001/11/06 23:30:50 2.9
+++ Primitive.pm 2001/11/11 07:15:30 2.10
@@ -1,6 +1,6 @@
# UI::Primitive - Interchange configuration manager primitives
-# $Id: Primitive.pm,v 2.9 2001/11/06 23:30:50 mheins Exp $
+# $Id: Primitive.pm,v 2.10 2001/11/11 07:15:30 mheins Exp $
# Copyright (C) 1998-2001 Red Hat, Inc. <interchange@redhat.com>
@@ -25,7 +25,7 @@
package UI::Primitive;
-$VERSION = substr(q$Revision: 2.9 $, 10);
+$VERSION = substr(q$Revision: 2.10 $, 10);
$DEBUG = 0;
@@ -638,6 +638,42 @@
push @days, [sprintf("%02d", $_), $_];
}
+sub round_to_fifteen {
+ my $val = shift;
+#::logDebug("round_to_fifteen val in=$val");
+ $val = substr($val, 0, 4);
+ $val = "0$val" if length($val) == 3;
+ return '0000' if length($val) < 4;
+ if($val !~ /(00|15|30|45)$/) {
+ my $hr = substr($val, 0, 2);
+ $hr =~ s/^0//;
+ my $min = substr($val, 2, 2);
+ $min =~ s/^0//;
+ if($min > 45 and $hr < 23) {
+ $hr++;
+ $min = 0;
+ }
+ elsif($min > 30) {
+ $min = 45;
+ }
+ elsif($min > 15) {
+ $min = 30;
+ }
+ elsif($min > 0) {
+ $min = 15;
+ }
+ elsif ($hr == 23) {
+ $min = 45;
+ }
+ else {
+ $min = 0;
+ }
+ $val = sprintf('%02d%02d', $hr, $min);
+ }
+#::logDebug("round_to_fifteen val out=$val");
+ return $val;
+}
+
sub date_widget {
my($name, $val, $time) = @_;
if($val =~ /\D/) {
@@ -706,9 +742,10 @@
$val =~ s/^\d{8}//;
$val =~ s/\D+//g;
+ $val = round_to_fifteen($val);
$out .= qq{<INPUT TYPE=hidden NAME="$name" VALUE=":">};
$out .= qq{<SELECT NAME="$name">};
-
+
my $ampm = $time =~ /pm/ ? 1 : 0;
my $mod = '';
undef $sel;
@@ -739,10 +776,11 @@
$disp_hour = sprintf("%02d:%02d", $hr, $min);
}
my $time = sprintf "%02d%02d", $hr, $min;
- $o = sprintf qq{<OPTION VALUE="%s">%s</OPTION>\n}, $time, $disp_hour;
+ $o = sprintf qq{<OPTION VALUE="%s">%s}, $time, $disp_hour;
($out .= $o, next) unless ! $sel and $val;
+#::logDebug("prospect=$time actual=$val");
$o =~ s/>/ SELECTED>/ && $sel++
- if substr($val, 0, 4) eq $time;
+ if $val eq $time;
$out .= $o;
}
}
2.1 +1 -1 interchange/dist/lib/UI/pages/include/item_option_modular
rev 2.1, prev_rev 2.0
Index: item_option_modular
===================================================================
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/pages/include/item_option_modular,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- item_option_modular 2001/07/18 02:22:11 2.0
+++ item_option_modular 2001/11/11 07:15:30 2.1
@@ -70,7 +70,7 @@
ui_meta_view=modular
{phantom?}
ui_te_widget:o_default=text
- ui_te_widget_width:o_default=20
+ ui_te_width:o_default=20
ui_te_help:o_default=Override the option defaults, select SKU to use instead
{/phantom?}
ui_page_banner=[cgi ui_page_banner]