Commit 840eaae0 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 365300: [mod_perl] Editing a saved search does not re-populate the search…

Bug 365300: [mod_perl] Editing a saved search does not re-populate the search page - Patch by Fré©ric Buclin <LpSolit@gmail.com> r/a=justdave
parent 43b17e5f
...@@ -111,6 +111,7 @@ local our %default; ...@@ -111,6 +111,7 @@ local our %default;
# and ignore any multiple values. # and ignore any multiple values.
sub PrefillForm { sub PrefillForm {
my ($buf) = (@_); my ($buf) = (@_);
$buf = new Bugzilla::CGI($buf);
my $foundone = 0; my $foundone = 0;
# Nothing must be undef, otherwise the template complains. # Nothing must be undef, otherwise the template complains.
...@@ -132,25 +133,13 @@ sub PrefillForm { ...@@ -132,25 +133,13 @@ sub PrefillForm {
"category", "subcategory", "name", "newcategory", "category", "subcategory", "name", "newcategory",
"newsubcategory", "public", "frequency") "newsubcategory", "public", "frequency")
{ {
# This is a bit of a hack. The default, empty list has $default{$name} = [];
# three entries to accommodate the needs of the email fields -
# we use each position to denote the relevant field. Array
# position 0 is unused for email fields because the form
# parameters historically started at 1.
$default{$name} = ["", "", ""];
} }
# Iterate over the URL parameters # Iterate over the URL parameters
foreach my $item (split(/\&/, $buf)) { foreach my $name ($buf->param()) {
my @el = split(/=/, $item); my @values = $buf->param($name);
my $name = $el[0];
my $value;
if ($#el > 0) {
$value = Bugzilla::Util::url_decode($el[1]);
} else {
$value = "";
}
# If the name begins with field, type, or value, then it is part of # If the name begins with field, type, or value, then it is part of
# the boolean charts. Because these are built different than the rest # the boolean charts. Because these are built different than the rest
...@@ -165,22 +154,16 @@ sub PrefillForm { ...@@ -165,22 +154,16 @@ sub PrefillForm {
# positions to show the defaults for that number field. # positions to show the defaults for that number field.
elsif ($name =~ m/^(.+)(\d)$/ && defined($default{$1})) { elsif ($name =~ m/^(.+)(\d)$/ && defined($default{$1})) {
$foundone = 1; $foundone = 1;
$default{$1}->[$2] = $value; $default{$1}->[$2] = $values[0];
} }
# If there's no default yet, we replace the blank string. elsif (exists $default{$name}) {
elsif (defined($default{$name}) && $default{$name}->[0] eq "") {
$foundone = 1; $foundone = 1;
$default{$name} = [$value]; push (@{$default{$name}}, @values);
}
# If there's already a default, we push on the new value.
elsif (defined($default{$name})) {
push (@{$default{$name}}, $value);
} }
} }
return $foundone; return $foundone;
} }
if (!PrefillForm($buffer)) { if (!PrefillForm($buffer)) {
# Ah-hah, there was no form stuff specified. Do it again with the # Ah-hah, there was no form stuff specified. Do it again with the
# default query. # default query.
...@@ -335,7 +318,7 @@ if ($cgi->param('order')) { $deforder = $cgi->param('order') } ...@@ -335,7 +318,7 @@ if ($cgi->param('order')) { $deforder = $cgi->param('order') }
$vars->{'userdefaultquery'} = $userdefaultquery; $vars->{'userdefaultquery'} = $userdefaultquery;
$vars->{'orders'} = \@orders; $vars->{'orders'} = \@orders;
$default{'querytype'} = $deforder || 'Importance'; $default{'order'} = [$deforder || 'Importance'];
if (($cgi->param('query_format') || $cgi->param('format') || "") if (($cgi->param('query_format') || $cgi->param('format') || "")
eq "create-series") { eq "create-series") {
......
...@@ -57,8 +57,11 @@ ...@@ -57,8 +57,11 @@
<input type="submit" id="[% button_name FILTER html %]" <input type="submit" id="[% button_name FILTER html %]"
value="[% button_name FILTER html %]"> value="[% button_name FILTER html %]">
[% IF known_name %] [% IF known_name %]
<input type="hidden" name="query_based_on" [%# We store known_name in case the user add a boolean chart. %]
value="[% known_name FILTER html %]"> <input type="hidden" name="known_name" value="[% known_name FILTER html %]">
[%# The name of the existing query will be passed to buglist.cgi. %]
<input type="hidden" name="query_based_on" value="[% known_name FILTER html %]">
[% END %] [% END %]
</p> </p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment