summaryrefslogtreecommitdiffstats
path: root/extensions/UserStory
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2014-04-28 16:30:33 +0200
committerDavid Lawrence <dkl@mozilla.com>2014-04-28 16:30:33 +0200
commitc4da32d7639e12f7c9e07f95f093cadca8b23b42 (patch)
tree72d3e827c58ab5236680aebb84938ada06c0fd43 /extensions/UserStory
parent96ff287433595d8fed8791af1ed0f6e382b3f4a9 (diff)
downloadbugzilla-c4da32d7639e12f7c9e07f95f093cadca8b23b42.tar.gz
bugzilla-c4da32d7639e12f7c9e07f95f093cadca8b23b42.tar.xz
Bug 963793 - fix to have user story field available on bug creation
r=glob
Diffstat (limited to 'extensions/UserStory')
-rw-r--r--extensions/UserStory/Extension.pm18
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/create/create-after_custom_fields.html.tmpl76
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/create/create-custom_field.html.tmpl12
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl4
4 files changed, 103 insertions, 7 deletions
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 %]