From c4da32d7639e12f7c9e07f95f093cadca8b23b42 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 28 Apr 2014 14:30:33 +0000 Subject: Bug 963793 - fix to have user story field available on bug creation r=glob --- extensions/UserStory/Extension.pm | 18 +++-- .../create/create-after_custom_fields.html.tmpl | 76 ++++++++++++++++++++++ .../hook/bug/create/create-custom_field.html.tmpl | 12 ++++ .../default/hook/bug/edit-custom_field.html.tmpl | 4 +- 4 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl create mode 100644 extensions/UserStory/template/en/default/hook/bug/create/create-custom_field.html.tmpl (limited to 'extensions/UserStory') diff --git a/extensions/UserStory/Extension.pm b/extensions/UserStory/Extension.pm index a60b86e0c..e70b86f5a 100644 --- a/extensions/UserStory/Extension.pm +++ b/extensions/UserStory/Extension.pm @@ -16,10 +16,13 @@ use Bugzilla; use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Extension::UserStory::Constants; +use Bugzilla::Extension::BMO::FakeBug; + use Text::Diff; BEGIN { *Bugzilla::Bug::user_story_group = \&_bug_user_story_group; + *Bugzilla::Extension::BMO::FakeBug::user_story_group = \&_bug_user_story_group; } sub _bug_user_story_group { @@ -27,17 +30,20 @@ sub _bug_user_story_group { if (!exists $self->{user_story_group}) { my ($product, $component) = ($self->product, $self->component); my $edit_group = ''; + my $components = []; if (exists USER_STORY->{$product}) { - my $components = USER_STORY->{$product}->{components}; - if (scalar(@$components) == 0 + $components = USER_STORY->{$product}->{components}; + if (!$component + || scalar(@$components) == 0 || grep { $_ eq $component } @$components) { $edit_group = USER_STORY->{$product}->{group}; } } - $self->{user_story_group} = $edit_group; + $self->{user_story_group} = $edit_group; + $self->{user_story_components} = $components; } - return $self->{user_story_group}; + return ($self->{user_story_group}, $self->{user_story_components}); } # ensure user is allowed to edit the story @@ -47,8 +53,8 @@ sub bug_check_can_change_field { return unless $field eq 'cf_user_story'; my $user = Bugzilla->user; - my $group = $bug->user_story_group() - || return; + my ($group) = $bug->user_story_group(); + $group || return; if (!$user->in_group($group)) { push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); } diff --git a/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl new file mode 100644 index 000000000..cd05d84de --- /dev/null +++ b/extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl @@ -0,0 +1,76 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% RETURN UNLESS default.user_story_group.0 && default.check_can_change_field('cf_user_story', 0, 1) %] + + + + + + + +
+ + (edit) + +
+
+ [% INCLUDE global/textarea.html.tmpl + name = 'cf_user_story' + id = 'user_story' + minrows = 10 + maxrows = 10 + cols = constants.COMMENT_COLS + disabled = 1 + %] +
+ + + + diff --git a/extensions/UserStory/template/en/default/hook/bug/create/create-custom_field.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/create/create-custom_field.html.tmpl new file mode 100644 index 000000000..4d809e4a2 --- /dev/null +++ b/extensions/UserStory/template/en/default/hook/bug/create/create-custom_field.html.tmpl @@ -0,0 +1,12 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[%# user story gets custom handling %] +[% IF field.name == 'cf_user_story' %] + [% field.hidden = 1 %] +[% END %] diff --git a/extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl index 2f0f758a4..2e8762dbe 100644 --- a/extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl +++ b/extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl @@ -6,4 +6,6 @@ # defined by the Mozilla Public License, v. 2.0. #%] -[% field.hidden = field.name == 'cf_user_story' %] +[% IF field.name == 'cf_user_story' %] + [% field.hidden = 1 %] +[% END %] -- cgit v1.2.3-24-g4f1b