diff options
author | David Lawrence <dkl@mozilla.com> | 2014-04-28 16:30:33 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-04-28 16:30:33 +0200 |
commit | c4da32d7639e12f7c9e07f95f093cadca8b23b42 (patch) | |
tree | 72d3e827c58ab5236680aebb84938ada06c0fd43 | |
parent | 96ff287433595d8fed8791af1ed0f6e382b3f4a9 (diff) | |
download | bugzilla-c4da32d7639e12f7c9e07f95f093cadca8b23b42.tar.gz bugzilla-c4da32d7639e12f7c9e07f95f093cadca8b23b42.tar.xz |
Bug 963793 - fix to have user story field available on bug creation
r=glob
7 files changed, 149 insertions, 32 deletions
diff --git a/extensions/BMO/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl b/extensions/BMO/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl new file mode 100644 index 000000000..47d86bd58 --- /dev/null +++ b/extensions/BMO/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl @@ -0,0 +1,30 @@ +[%# 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. + #%] + +[%# crash-signature handling %] +[% IF show_crash_signature %] + <tbody class="expert_fields"> + <tr> + <th id="field_label_cf_crash_signature" class="field_label"> + <label for="cf_crash_signature"> Crash Signature: </label> + </th> + <td colspan="3"> + <span id="cf_crash_signature_container"> + <span id="cf_crash_signature_nonedit_display"><i>None</i></span> + (<a id="cf_crash_signature_action" href="#">edit</a>) + </span> + <span id="cf_crash_signature_input"> + <textarea id="cf_crash_signature" name="cf_crash_signature" rows="4" cols="60" + >[% cf_crash_signature FILTER html %]</textarea> + </span> + </td> + </tr> + </tbody> +[% END %] + + diff --git a/extensions/BMO/template/en/default/hook/bug/create/create-custom_field.html.tmpl b/extensions/BMO/template/en/default/hook/bug/create/create-custom_field.html.tmpl new file mode 100644 index 000000000..afbb2947c --- /dev/null +++ b/extensions/BMO/template/en/default/hook/bug/create/create-custom_field.html.tmpl @@ -0,0 +1,13 @@ +[%# 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. + #%] + +[%# crash-signature gets custom handling %] +[% IF field.name == 'cf_crash_signature' %] + [% field.hidden = 1 %] + [% show_crash_signature = 1 %] +[% END %] 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) %] + +<tbody id="cf_user_story_container" class="expert_fields bz_default_hidden"> + <tr> + <th class="field_label"> + <label for="cf_user_story">User Story:</label> + </th> + <td colspan="3"> + <div id="user_story_header"> + <span id="user_story_edit"> + (<a href="javascript:void(0)" id="user_story_edit_action" >edit</a>) + </span> + </div> + <div id="user_story_edit_container" class="bz_default_hidden"> + [% INCLUDE global/textarea.html.tmpl + name = 'cf_user_story' + id = 'user_story' + minrows = 10 + maxrows = 10 + cols = constants.COMMENT_COLS + disabled = 1 + %] + </div> + <script type="text/javascript"> + var user_story_components = []; + [% FOREACH c = default.user_story_group.1 %] + user_story_components.push('[% c FILTER js %]'); + [% END %] + function toggleUserStory() { + if (user_story_components.length == 0) { + YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden'); + YAHOO.util.Dom.get('user_story').disabled = false; + return; + } + var index = -1; + var form = document.Create; + if (form.component.type == 'select-one') { + index = form.component.selectedIndex; + } else if (form.component.type == 'hidden') { + // Assume there is only one component in the list + index = 0; + } + if (index != -1) { + for (var i = 0, l = user_story_components.length; i < l; i++) { + if (user_story_components[i] == components[index]) { + YAHOO.util.Dom.removeClass('cf_user_story_container', 'bz_default_hidden'); + YAHOO.util.Dom.get('user_story').disabled = false; + return; + } + else { + YAHOO.util.Dom.addClass('cf_user_story_container', 'bz_default_hidden'); + YAHOO.util.Dom.get('user_story').disabled = true; + } + } + } + } + YAHOO.util.Event.addListener('component', 'change', toggleUserStory); + YAHOO.util.Event.addListener('user_story_edit_action', 'click', function() { + YAHOO.util.Dom.addClass('user_story_edit', 'bz_default_hidden'); + YAHOO.util.Dom.addClass('user_story_readonly', 'bz_default_hidden'); + YAHOO.util.Dom.removeClass('user_story_edit_container', 'bz_default_hidden'); + YAHOO.util.Dom.get('user_story').focus(); + }); + toggleUserStory(); + </script> + </td> + </tr> +</tbody> 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 %] diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index d1de42eb9..d41dc9d35 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -647,11 +647,8 @@ TUI_hide_default('attachment_text_field'); [% FOREACH field = Bugzilla.active_custom_fields(product=>product) %] [% NEXT IF field.type == constants.FIELD_TYPE_EXTENSION %] [% NEXT UNLESS field.enter_bug %] - [%# crash-signature gets custom handling %] - [% IF field.name == 'cf_crash_signature' %] - [% show_crash_signature = 1 %] - [% NEXT %] - [% END %] + [% Hook.process('custom_field', 'bug/create/create.html.tmpl') %] + [% NEXT IF field.hidden %] [% SET value = ${field.name}.defined ? ${field.name} : "" %] <tr [% 'class="expert_fields"' IF !field.is_mandatory %]> [% INCLUDE bug/field.html.tmpl @@ -661,26 +658,7 @@ TUI_hide_default('attachment_text_field'); [% END %] </tbody> -[%# crash-signature handling %] -[% IF show_crash_signature %] -<tbody class="expert_fields"> - <tr> - <th id="field_label_cf_crash_signature" class="field_label"> - <label for="cf_crash_signature"> Crash Signature: </label> - </th> - <td colspan="3"> - <span id="cf_crash_signature_container"> - <span id="cf_crash_signature_nonedit_display"><i>None</i></span> - (<a id="cf_crash_signature_action" href="#">edit</a>) - </span> - <span id="cf_crash_signature_input"> - <textarea id="cf_crash_signature" name="cf_crash_signature" rows="4" cols="60" - >[% cf_crash_signature FILTER html %]</textarea> - </span> - </td> - </tr> -</tbody> -[% END %] +[% Hook.process('after_custom_fields') %] [% display_flags = 0 %] [% any_flags_requesteeble = 0 %] |