From 50a1473b3c89bf8fe153cfd9c4c29a0de104d36d Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 7 Apr 2015 13:10:42 +0800 Subject: Bug 1149879: bug-modal's editmode is broken for users without editbugs (Form field dup_id was not defined) --- extensions/BugModal/Extension.pm | 18 +++++++++++++++++- .../template/en/default/bug_modal/edit.html.tmpl | 18 ++++++++++++++---- .../template/en/default/bug_modal/field.html.tmpl | 15 +++++++++++++++ .../template/en/default/bug_modal/user.html.tmpl | 5 ++++- extensions/BugModal/web/bug_modal.js | 3 ++- 5 files changed, 52 insertions(+), 7 deletions(-) (limited to 'extensions/BugModal') diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm index 3c23d0b90..c07bb4cde 100644 --- a/extensions/BugModal/Extension.pm +++ b/extensions/BugModal/Extension.pm @@ -175,8 +175,20 @@ sub template_before_process { foreach my $r (@{ Bugzilla::Field->new({ name => 'resolution', cache => 1 })->legal_values }) { my $resolution = $r->name; next unless $resolution; - next unless $r->is_active || $resolution eq $bug->resolution; + # always allow the current value + if ($resolution eq $bug->resolution) { + push @resolutions, $r; + next; + } + + # never allow inactive values + next unless $r->is_active; + + # ensure the user has basic rights to change this field + next unless $bug->check_can_change_field('resolution', '---', $resolution); + + # canconfirm users can only set the resolution to WFM, INCOMPLETE or DUPE if ($perms->{canconfirm} && !($perms->{canedit} || $perms->{isreporter})) { @@ -185,11 +197,15 @@ sub template_before_process { && $resolution ne 'INCOMPLETE' && $resolution ne 'DUPLICATE'; } + + # reporters can set it to anything, except INCOMPELTE if ($perms->{isreporter} && !($perms->{canconfirm} || $perms->{canedit})) { next if $resolution eq 'INCOMPLETE'; } + + # expired has, uh, expired next if $resolution eq 'EXPIRED'; push @resolutions, $r; diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index 024f4f6a5..e198a8706 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -364,6 +364,7 @@ [% INCLUDE bug_modal/field.html.tmpl field = bug_fields.bug_status field_type = constants.FIELD_TYPE_SINGLE_SELECT + editable = bug.choices.bug_status.size > 1 values = bug.choices.bug_status inline = 1 no_indent = 1 @@ -372,6 +373,7 @@ [% INCLUDE bug_modal/field.html.tmpl field = bug_fields.resolution field_type = constants.FIELD_TYPE_SINGLE_SELECT + editable = bug.choices.resolution.size > (bug.resolution == "" ? 0 : 1) values = bug.choices.resolution inline = 1 edit_only = 1 @@ -432,8 +434,12 @@ hide_on_view = bug.mentors.size == 0 %] [% - FOREACH mentor IN bug.mentors; - INCLUDE bug_modal/user.html.tmpl u=mentor; + IF bug.mentors.size; + FOREACH mentor IN bug.mentors; + INCLUDE bug_modal/user.html.tmpl u=mentor; + END; + ELSE; + "---"; END; %] [% END %] @@ -573,7 +579,7 @@ field_type = constants.FIELD_TYPE_KEYWORDS hide_on_view = bug.keyword_objects.size == 0 %] - [% bug.keyword_objects.pluck("name").join(", ") FILTER html %] + [% bug.keyword_objects.pluck("name").join(", ") || "---" FILTER html %] [% END %] [% UNLESS cf_hidden_in_product('cf_fx_iteration', bug.product, bug.component, bug) %] @@ -828,7 +834,11 @@ [% END %] [% END %] -
[% bug.cf_user_story FILTER html %]
+ [% IF bug.cf_user_story == "" %] + --- + [% ELSE %] +
[% bug.cf_user_story FILTER html %]
+ [% END %] [% IF user.id %]