summaryrefslogtreecommitdiffstats
path: root/extensions/UserStory
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-10-23 09:25:27 +0200
committerByron Jones <bjones@mozilla.com>2013-10-23 09:25:27 +0200
commit4f6724b0f86ccffa091ca33c04e237b9dd5d4c4a (patch)
tree01bc416498ea53d03d569a3b85bb762bbe1c4e3c /extensions/UserStory
parentf427f277bf5d4e5f54948ef9a89634961d74298c (diff)
downloadbugzilla-4f6724b0f86ccffa091ca33c04e237b9dd5d4c4a.tar.gz
bugzilla-4f6724b0f86ccffa091ca33c04e237b9dd5d4c4a.tar.xz
Bug 895687: add UserStory extension
Diffstat (limited to 'extensions/UserStory')
-rw-r--r--extensions/UserStory/Config.pm21
-rw-r--r--extensions/UserStory/Extension.pm88
-rw-r--r--extensions/UserStory/lib/Constants.pm22
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl51
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl9
-rw-r--r--extensions/UserStory/template/en/default/hook/bug/show-header-end.html.tmpl9
-rw-r--r--extensions/UserStory/web/style/user_story.css26
7 files changed, 226 insertions, 0 deletions
diff --git a/extensions/UserStory/Config.pm b/extensions/UserStory/Config.pm
new file mode 100644
index 000000000..8649c71cf
--- /dev/null
+++ b/extensions/UserStory/Config.pm
@@ -0,0 +1,21 @@
+# 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.
+
+package Bugzilla::Extension::UserStory;
+use strict;
+
+use constant NAME => 'UserStory';
+use constant REQUIRED_MODULES => [
+ {
+ package => 'Text-Diff',
+ module => 'Text::Diff',
+ version => 0,
+ },
+];
+use constant OPTIONAL_MODULES => [];
+
+__PACKAGE__->NAME;
diff --git a/extensions/UserStory/Extension.pm b/extensions/UserStory/Extension.pm
new file mode 100644
index 000000000..26f2c6bab
--- /dev/null
+++ b/extensions/UserStory/Extension.pm
@@ -0,0 +1,88 @@
+# 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.
+
+package Bugzilla::Extension::UserStory;
+use strict;
+use warnings;
+
+use base qw(Bugzilla::Extension);
+our $VERSION = '1';
+
+use Bugzilla;
+use Bugzilla::Constants;
+use Bugzilla::Error;
+use Bugzilla::Extension::UserStory::Constants;
+use Text::Diff;
+
+BEGIN {
+ *Bugzilla::Product::user_story_group = \&_product_user_story_group;
+}
+
+sub _product_user_story_group {
+ my ($self) = @_;
+ return USER_STORY_PRODUCTS->{$self->name};
+}
+
+# ensure user is allowed to edit the story
+sub bug_check_can_change_field {
+ my ($self, $args) = @_;
+ my ($bug, $field, $priv_results) = @$args{qw(bug field priv_results)};
+ return unless $field eq 'cf_user_story';
+
+ my $user = Bugzilla->user;
+ my $group = $bug->product_obj->user_story_group()
+ || return;
+ if (!$user->in_group($group)) {
+ push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED);
+ }
+}
+
+# store just a diff of the changes in the bugs_activity table
+sub bug_update_before_logging {
+ my ($self, $args) = @_;
+ my $changes = $args->{changes};
+ return unless exists $changes->{cf_user_story};
+ my $diff = diff(
+ \$changes->{cf_user_story}->[0],
+ \$changes->{cf_user_story}->[1],
+ {
+ CONTEXT => 0,
+ },
+ );
+ $changes->{cf_user_story} = [ '', $diff ];
+}
+
+# stop inline-history from displaying changes to the user story
+sub inline_history_activtiy {
+ my ($self, $args) = @_;
+ foreach my $activity (@{ $args->{activity} }) {
+ foreach my $change (@{ $activity->{changes} }) {
+ if ($change->{fieldname} eq 'cf_user_story') {
+ $change->{removed} = '';
+ $change->{added} = '(updated)';
+ }
+ }
+ }
+}
+
+# create cf_user_story field
+sub install_update_db {
+ my ($self, $args) = @_;
+ return if Bugzilla::Field->new({ name => 'cf_user_story'});
+ Bugzilla::Field->create({
+ name => 'cf_user_story',
+ description => 'User Story',
+ type => FIELD_TYPE_TEXTAREA,
+ mailhead => 0,
+ enter_bug => 0,
+ obsolete => 0,
+ custom => 1,
+ buglist => 0,
+ });
+}
+
+__PACKAGE__->NAME;
diff --git a/extensions/UserStory/lib/Constants.pm b/extensions/UserStory/lib/Constants.pm
new file mode 100644
index 000000000..dca38154c
--- /dev/null
+++ b/extensions/UserStory/lib/Constants.pm
@@ -0,0 +1,22 @@
+# 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.
+
+package Bugzilla::Extension::UserStory::Constants;
+
+use strict;
+use warnings;
+
+use base qw(Exporter);
+
+our @EXPORT = qw( USER_STORY_PRODUCTS );
+
+use constant USER_STORY_PRODUCTS => {
+ # product group required to edit
+ Tracking => 'editbugs',
+};
+
+1;
diff --git a/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl
new file mode 100644
index 000000000..f58c2fb8b
--- /dev/null
+++ b/extensions/UserStory/template/en/default/hook/bug/comments-comment_banner.html.tmpl
@@ -0,0 +1,51 @@
+[%# 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 bug.product_obj.user_story_group %]
+[% can_edit_story = bug.check_can_change_field('cf_user_story', 0, 1) %]
+
+<div class="user_story">
+ <div id="user_story_header">
+ <b>User Story</b>
+ [% IF can_edit_story %]
+ <span id="user_story_edit">
+ (<a href="javascript:void(0)" id="user_story_edit_action" >edit</a>)
+ </span>
+ [% END %]
+ </div>
+
+ [% IF bug.cf_user_story != "" %]
+ <div id="user_story_readonly" class="bz_comment">
+ <pre class="bz_comment_text">
+ [%- bug.cf_user_story FILTER quoteUrls(bug) -%]
+ </pre>
+ </div>
+ [% ELSE %]
+ <br id="user_story_readonly">
+ [% END %]
+
+ [% IF can_edit_story %]
+ <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
+ defaultcontent = bug.cf_user_story %]
+ </div>
+ <script type="text/javascript">
+ 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();
+ });
+ </script>
+ [% END %]
+</div>
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
new file mode 100644
index 000000000..2f0f758a4
--- /dev/null
+++ b/extensions/UserStory/template/en/default/hook/bug/edit-custom_field.html.tmpl
@@ -0,0 +1,9 @@
+[%# 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.
+ #%]
+
+[% field.hidden = field.name == 'cf_user_story' %]
diff --git a/extensions/UserStory/template/en/default/hook/bug/show-header-end.html.tmpl b/extensions/UserStory/template/en/default/hook/bug/show-header-end.html.tmpl
new file mode 100644
index 000000000..abdbe865e
--- /dev/null
+++ b/extensions/UserStory/template/en/default/hook/bug/show-header-end.html.tmpl
@@ -0,0 +1,9 @@
+[%# 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.
+ #%]
+
+[% style_urls.push("extensions/UserStory/web/style/user_story.css") %]
diff --git a/extensions/UserStory/web/style/user_story.css b/extensions/UserStory/web/style/user_story.css
new file mode 100644
index 000000000..51affd359
--- /dev/null
+++ b/extensions/UserStory/web/style/user_story.css
@@ -0,0 +1,26 @@
+/* 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_readonly {
+ border: 1px solid black;
+ border-radius: 4px;
+}
+
+.skin-standard #user_story_readonly {
+ padding: 2px;
+}
+
+.skin-Mozilla #user_story_readonly {
+ border: none;
+ border-radius: 0px;
+}
+
+.skin-Mozilla #user_story_readonly .bz_comment_text {
+ border: 1px solid darkgrey;
+ border-radius: 4px;
+}