diff options
author | mkanat%bugzilla.org <> | 2007-11-29 09:20:05 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-11-29 09:20:05 +0100 |
commit | 9dfa47cccbf6cf4f98d807c1c61400fc138e18ff (patch) | |
tree | 14f2bcdec784bc9ad056894af2d85e92acd5f295 /Bugzilla | |
parent | ab73b625a7fb071794cd1152de3c8486d91788f6 (diff) | |
download | bugzilla-9dfa47cccbf6cf4f98d807c1c61400fc138e18ff.tar.gz bugzilla-9dfa47cccbf6cf4f98d807c1c61400fc138e18ff.tar.xz |
Bug 397099: Date/Time Fields should have a JavaScript widget for picking a date
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, r=glob, a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 6 | ||||
-rw-r--r-- | Bugzilla/Install/Filesystem.pm | 29 | ||||
-rw-r--r-- | Bugzilla/Object.pm | 14 | ||||
-rw-r--r-- | Bugzilla/Util.pm | 6 |
4 files changed, 41 insertions, 14 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index eaf6a9a83..a8f1ede5d 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -201,6 +201,12 @@ use constant NUMERIC_COLUMNS => qw( remaining_time ); +sub DATE_COLUMNS { + my @fields = Bugzilla->get_fields( + { custom => 1, type => FIELD_TYPE_DATETIME }); + return map { $_->name } @fields; +} + # This is used by add_comment to know what we validate before putting in # the DB. use constant UPDATE_COMMENT_COLUMNS => qw( diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index c96e8d12f..a24dc28ca 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -211,16 +211,13 @@ sub FILESYSTEM { foreach my $skin_dir ("$skinsdir/custom", <$skinsdir/contrib/*>) { next unless -d $skin_dir; next if basename($skin_dir) =~ /^cvs$/i; - foreach (<$skinsdir/standard/*.css>) { - my $standard_css_file = basename($_); - my $custom_css_file = "$skin_dir/$standard_css_file"; - $create_files{$custom_css_file} = { perms => $ws_readable, contents => <<EOT -/* - * Custom rules for $standard_css_file. - * The rules you put here override rules in that stylesheet. - */ -EOT - } + $create_dirs{"$skin_dir/yui"} = $ws_dir_readable; + foreach my $base_css (<$skinsdir/standard/*.css>) { + _add_custom_css($skin_dir, basename($base_css), \%create_files, $ws_readable); + } + foreach my $dir_css (<$skinsdir/standard/*/*.css>) { + $dir_css =~ s{.+?([^/]+/[^/]+)$}{$1}; + _add_custom_css($skin_dir, $dir_css, \%create_files, $ws_readable); } } @@ -378,6 +375,18 @@ EOT } +# A simple helper for creating "empty" CSS files. +sub _add_custom_css { + my ($skin_dir, $path, $create_files, $perms) = @_; + $create_files->{"$skin_dir/$path"} = { perms => $perms, contents => <<EOT +/* + * Custom rules for $path. + * The rules you put here override rules in that stylesheet. + */ +EOT + }; +} + sub create_htaccess { _create_files(%{FILESYSTEM()->{htaccess}}); diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 9e155bc10..2cf671bc2 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -27,12 +27,15 @@ use Bugzilla::Constants; use Bugzilla::Util; use Bugzilla::Error; +use Date::Parse; + use constant NAME_FIELD => 'name'; use constant ID_FIELD => 'id'; use constant LIST_ORDER => NAME_FIELD; use constant UPDATE_VALIDATORS => {}; use constant NUMERIC_COLUMNS => (); +use constant DATE_COLUMNS => (); ############################### #### Initialization #### @@ -237,6 +240,7 @@ sub update { my $old_self = $self->new($self->id); my %numeric = map { $_ => 1 } $self->NUMERIC_COLUMNS; + my %date = map { $_ => 1 } $self->DATE_COLUMNS; my (@update_columns, @values, %changes); foreach my $column ($self->UPDATE_COLUMNS) { my ($old, $new) = ($old_self->{$column}, $self->{$column}); @@ -246,7 +250,9 @@ sub update { if (!defined $new || !defined $old) { next if !defined $new && !defined $old; } - elsif ( ($numeric{$column} && $old == $new) || $old eq $new ) { + elsif ( ($numeric{$column} && $old == $new) + || ($date{$column} && str2time($old) == str2time($new)) + || $old eq $new ) { next; } @@ -474,6 +480,12 @@ current value in the database. It only updates columns that have changed. Any column listed in NUMERIC_COLUMNS is treated as a number, not as a string, during these comparisons. +=item C<DATE_COLUMNS> + +This is much like L</NUMERIC_COLUMNS>, except that it treats strings as +dates when being compared. So, for example, C<2007-01-01> would be +equal to C<2007-01-01 00:00:00>. + =back =head1 METHODS diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 40065c5c9..aad2c5672 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -465,9 +465,9 @@ sub validate_time { my $ts = str2time($time); if ($ts) { $time2 = time2str("%H:%M:%S", $ts); - - $time =~ s/(\d+):(\d+?):(\d+?)/$1:$2:$3/; - $time2 =~ s/(\d+):(\d+?):(\d+?)/$1:$2:$3/; + if (trim($time) =~ /^\d\d:\d\d$/) { + $time .= ':00'; + } } my $ret = ($ts && $time eq $time2); return $ret ? 1 : 0; |