From a50fa41f3089481e26599f8feb7218fb72efc9d2 Mon Sep 17 00:00:00 2001 From: vfilippov Date: Thu, 21 Jul 2011 13:44:45 +0000 Subject: [PATCH] Bug 81185, Bug 70605 - Fix chfield git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1300 6955db30-a419-402b-8a0d-67ecbb4d7f56 --- Bugzilla/Search.pm | 10 ++-- Bugzilla/Template.pm | 49 ++++++++++++++----- query.cgi | 6 ++- .../default/search/boolean-charts.html.tmpl | 6 +-- template/en/default/search/form.html.tmpl | 45 +++++------------ template/en/default/search/knob.html.tmpl | 2 +- 6 files changed, 64 insertions(+), 54 deletions(-) diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 5f021fbb3..a3525d409 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -319,7 +319,7 @@ sub SPECIAL_ORDER return $cache->{special_order} = $special_order; } -# Backward-compatibility for old field names. Goes old_name => new_name. +# Backwards-compatibility for old field names. Goes old_name => new_name. sub COLUMN_ALIASES { my $cache = Bugzilla->cache_fields; @@ -460,7 +460,7 @@ sub STATIC_COLUMNS } # Do the actual column-getting from fielddefs, now. - my @bugsjoin; + my @bugid_fields; foreach my $field (Bugzilla->get_fields) { my $id = $field->name; @@ -470,19 +470,19 @@ sub STATIC_COLUMNS $columns->{$id}->{nocharts} = $field->obsolete; if ($field->type == FIELD_TYPE_BUG_ID) { - push @bugsjoin, $field; + push @bugid_fields, $field; } } # Fields of bugs related to selected by some BUG_ID type field - foreach my $field (@bugsjoin) + foreach my $field (@bugid_fields) { my $id = $field->name; my $join = [ "LEFT JOIN bugs bugs_$id ON bugs_$id.bug_id=bugs.$id" ]; foreach my $subfield (Bugzilla->get_fields({ obsolete => 0, buglist => 1 })) { my $subid = $subfield->name; - if ($columns->{$subid}->{name} eq "bugs.$subid") + if ($subid ne 'bug_id' && $columns->{$subid}->{name} eq "bugs.$subid") { $columns->{$id.'_'.$subid} = { name => "bugs_$id.".$subfield->name, diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 01adecf6c..d20fcc0ef 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -807,25 +807,50 @@ sub create { lc_messages => Bugzilla->messages, # HTML + # html_select(name, { => }, , ( + # [ { id => , name => }, ... ] + # OR + # { => , ... } # will be sorted on text + # OR + # [ , ... ], { => , ... } + # )) html_select => sub { - my ($name, $values, $valuenames, $selected, $args) = @_; + my ($name, $selected, $values, $valuenames, $attrs) = @_; + $selected = '' if !defined $selected; + $selected = { map { $_ => 1 } list $selected }; $name = html_quote($name); - my $html = ''; - if (ref $valuenames eq 'ARRAY') + my $html = '{name} } @$valuenames ]; - $valuenames = { map { $_->{name} => $_->{title} } @$valuenames }; + $html .= ' '.html_quote($_).'="'.html_quote($attrs->{$_}).'"' for keys %$attrs; + } + $html .= '>'; + if (ref $values eq 'HASH') + { + $valuenames = $values; + $values = [ sort { $values->{$a} cmp $values->{$b} } keys %$values ]; + } + if (!$values || !@$values) + { + } + elsif (!ref $values->[0]) + { + for (@$values) + { + $html .= '{$_}; + $html .= '>'.html_quote($valuenames->{$_}).''; + } } else { - $values ||= [ keys %$valuenames ]; - } - for (@$values) - { - $html .= '{$_}).''; + for (@$values) + { + $html .= '{$_->{id}}; + $html .= '>'.html_quote($_->{name}).''; + } } $html .= ''; return $html; diff --git a/query.cgi b/query.cgi index 9dec003cc..50b20d2ab 100755 --- a/query.cgi +++ b/query.cgi @@ -173,7 +173,11 @@ if (!@{$default->{chfieldto}} || $default->{chfieldto}->[0] eq '') } # "where one or more of the following changed:" -$vars->{chfield} = [ map { $_->name } @{ Bugzilla::Search->CHANGEDFROMTO_FIELDS } ]; +$vars->{chfield} = [ + sort { $a->{name} cmp $b->{name} } + map { { id => $_->{name}, name => $_->{description} } } + @{ Bugzilla::Search->CHANGEDFROMTO_FIELDS } +]; # Boolean charts diff --git a/template/en/default/search/boolean-charts.html.tmpl b/template/en/default/search/boolean-charts.html.tmpl index 855876cd1..d46a467e3 100644 --- a/template/en/default/search/boolean-charts.html.tmpl +++ b/template/en/default/search/boolean-charts.html.tmpl @@ -10,7 +10,7 @@ # | -------------------------- | # ------------------------------ # - # If there is single term inside some AND/OR, it is shown without fieldset. + # If there is just a single term inside some AND/OR, it is shown without fieldset. # So, if the whole chart consists of a single term, the form would look like: # # "field type value [OR] [AND] [NOT] [OR]" @@ -59,8 +59,8 @@ [% FOREACH col = row %] [% J = loop.count - 1 %] [% "" IF J %] - [% html_select("field$C-$I-$J", '', chart_fields, col.field) %] - [%- html_select("type$C-$I-$J", chart_types, lc_messages.operator_descs, col.type) + [% html_select("field$C-$I-$J", col.field, chart_fields) %] + [%- html_select("type$C-$I-$J", col.type, chart_types, lc_messages.operator_descs) %] [% END %] diff --git a/template/en/default/search/form.html.tmpl b/template/en/default/search/form.html.tmpl index 8ba30761a..412345d2d 100644 --- a/template/en/default/search/form.html.tmpl +++ b/template/en/default/search/form.html.tmpl @@ -67,7 +67,7 @@ addListener(window, 'load', function() { Summary: - [% html_select('short_desc_type', text_types, lc_messages.operator_descs, default.short_desc_type.0) %] + [% html_select('short_desc_type', default.short_desc_type.0, text_types, lc_messages.operator_descs) %] @@ -219,7 +219,7 @@ addListener(window, 'load', function() { [% t = field.name _ '_type' %] - [% html_select(t, text_types, lc_messages.operator_descs, default.$t.0) %] + [% html_select(t, default.$t.0, text_types, lc_messages.operator_descs) %] [% keywords_types = ['allwords', 'anywords', 'nowords', 'regexp', 'notregexp'] %] - [% html_select('keywords_type', keywords_types, lc_messages.operator_descs, default.keywords_type.0) %] + [% html_select('keywords_type', default.keywords_type.0, keywords_types, lc_messages.operator_descs) %] - - [% FOREACH qv = [ - { name => "exact", description => "is" }, - { name => "substring", description => "contains" }, - { name => "notequals", description => "is not" }, - { name => "regexp", description => "matches regexp" }, - { name => "notregexp", description => "doesn't match regexp" } ] %] - - [% qv.description %] - [% END %] - + [% html_select('emailtype' _ n, default.emailtype.$n, [ + { id => "exact", name => "is" }, + { id => "substring", name => "contains" }, + { id => "notequals", name => "is not" }, + { id => "regexp", name => "matches regexp" }, + { id => "notregexp", name => "doesn't match regexp" } + ]) %] @@ -492,8 +487,7 @@ addListener(window, 'load', function() { Only [% terms.bugs %] with at least: - + votes @@ -517,25 +511,12 @@ addListener(window, 'load', function() { and - (YYYY-MM-DD or relative dates) + (YYYY-MM-DD or relative dates) By user: (user login) where one or more of the following changed: - - [% chfields = [] %] - [% FOREACH field = chfield %] - [% chfields.push({value => field, desc => (field_descs.$field || field) }) %] - [% END %] - - - [% FOREACH field = chfields.sort('desc') %] - - [% field.desc FILTER html %] - [% END %] - - + [% html_select('chfield', default.chfield, chfield, '', { multiple => 'multiple' }) %] and the new value was: