From: Kohei Yoshino Date: Fri, 1 Mar 2019 23:33:56 +0000 (-0500) Subject: Bug 1502500 - Adding the qe-verify flag as an editable field when using Bugzilla... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c481412ffc84ff278bfb7fc7b0b2f2f764fb8a8;p=thirdparty%2Fbugzilla.git Bug 1502500 - Adding the qe-verify flag as an editable field when using Bugzilla's "Change Several Bugs at Once" option --- diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 3ed055b3d..673f5ce01 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -872,7 +872,6 @@ sub extract_flags_from_cgi { # Extract a list of flag type IDs from field names. my @flagtype_ids = map(/^flag_type-(\d+)$/ ? $1 : (), $cgi->param()); - @flagtype_ids = grep($cgi->param("flag_type-$_") ne 'X', @flagtype_ids); # Extract a list of existing flag IDs. my @flag_ids = map(/^flag-(\d+)$/ ? $1 : (), $cgi->param()); @@ -957,18 +956,14 @@ sub extract_flags_from_cgi { # We are only interested in flags the user tries to create. next unless scalar(grep { $_ == $type_id } @flagtype_ids); - # Get the number of flags of this type already set for this target. - my $has_flags = $class->count({ + # Get the current flags of this type already set for this target. + my $current_flags = $class->match({ 'type_id' => $type_id, 'target_type' => $attachment ? 'attachment' : 'bug', 'bug_id' => $bug->bug_id, 'attach_id' => $attachment ? $attachment->id : undef }); - # Do not create a new flag of this type if this flag type is - # not multiplicable and already has a flag set. - next if (!$flag_type->is_multiplicable && $has_flags); - my $status = $cgi->param("flag_type-$type_id"); trick_taint($status); @@ -987,6 +982,10 @@ sub extract_flags_from_cgi { last unless $flag_type->is_multiplicable; } } + elsif (!$flag_type->is_multiplicable && scalar @$current_flags) { + # Update or delete the current flag if the type is not multiplicable. + push(@new_flags, {id => @$current_flags[0]->id, status => $status}); + } else { push(@new_flags, {type_id => $type_id, status => $status}); } diff --git a/buglist.cgi b/buglist.cgi index b3011c16e..660c238ed 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -1080,6 +1080,9 @@ if ($dotweak && scalar @bugs) { = [map($_->name, grep($_->is_active, @{$one_product->milestones}))]; } } + + # Allow to edit flags as well + $vars->{'flag_types'} = Bugzilla::FlagType::match({target_type => 'bug'}); } # If we're editing a stored query, use the existing query name as default for diff --git a/process_bug.cgi b/process_bug.cgi index 7e22a6ef1..062af5008 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -396,14 +396,13 @@ foreach my $b (@bug_objects) { } } -if (defined $cgi->param('id')) { - - # Flags should be set AFTER the bug has been moved into another - # product/component. The structure of flags code doesn't currently - # allow them to be set using set_all. +# Flags should be set AFTER the bug has been moved into another +# product/component. The structure of flags code doesn't currently +# allow them to be set using set_all. +foreach my $bug (@bug_objects) { my ($flags, $new_flags) - = Bugzilla::Flag->extract_flags_from_cgi($first_bug, undef, $vars); - $first_bug->set_flags($flags, $new_flags); + = Bugzilla::Flag->extract_flags_from_cgi($bug, undef, $vars); + $bug->set_flags($flags, $new_flags); } ############################## diff --git a/template/en/default/flag/list.html.tmpl b/template/en/default/flag/list.html.tmpl index bf1c8a6b3..f4aeb1e99 100644 --- a/template/en/default/flag/list.html.tmpl +++ b/template/en/default/flag/list.html.tmpl @@ -133,6 +133,9 @@ class="flag_select flag_type-[% type.id %]" data-id="[% type.id %]" data-name="[% type.name FILTER html FILTER no_break %]" [% IF !can_edit_flag %] disabled="disabled"[% END %]> + [% IF dontchange %] + + [% END %] [%# Only display statuses the user is allowed to set. %] [% IF !flag || (can_edit_flag && user.can_unset_flag(type, flag.status) && user.can_request_flag(type)) diff --git a/template/en/default/list/edit-multiple.html.tmpl b/template/en/default/list/edit-multiple.html.tmpl index 8224a3040..88525de12 100644 --- a/template/en/default/list/edit-multiple.html.tmpl +++ b/template/en/default/list/edit-multiple.html.tmpl @@ -290,6 +290,8 @@ +[% PROCESS "flag/list.html.tmpl" any_flags_requesteeble = 1 %] + [% IF user.is_insider %]