From 3e8a6b2bdcd591af4e67002489a71753c7920c7a Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 15 Jul 2014 13:25:05 +0800 Subject: Bug 1036303: add a list of tracking/project/etc tracking flags to the bugmail filtering prefs page --- extensions/BugmailFilter/Extension.pm | 27 ++- .../default/account/prefs/bugmail_filter.html.tmpl | 202 +++++++++++++-------- extensions/BugmailFilter/web/js/bugmail-filter.js | 5 + 3 files changed, 159 insertions(+), 75 deletions(-) (limited to 'extensions/BugmailFilter') diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm index 6bcfe70d6..60c180ca7 100644 --- a/extensions/BugmailFilter/Extension.pm +++ b/extensions/BugmailFilter/Extension.pm @@ -116,7 +116,7 @@ sub user_preferences { # remove all tracking flag fields. these change too frequently to be of # value, so they only add noise to the list. - foreach my $field (@{ Bugzilla->tracking_flag_names }) { + foreach my $field (Bugzilla->tracking_flag_names) { delete $fields{$field}; } @@ -159,6 +159,27 @@ sub user_preferences { }) } ]; + # build a list of tracking-flags, grouped by type + require Bugzilla::Extension::TrackingFlags::Constants; + require Bugzilla::Extension::TrackingFlags::Flag; + my %flag_types = + map { $_->{name} => $_->{description} } + @{ Bugzilla::Extension::TrackingFlags::Constants::FLAG_TYPES() }; + my %tracking_flags_by_type; + foreach my $flag (Bugzilla::Extension::TrackingFlags::Flag->get_all) { + my $type = $flag_types{$flag->flag_type}; + $tracking_flags_by_type{$type} //= []; + push @{ $tracking_flags_by_type{$type} }, $flag; + } + my @tracking_flags_by_type; + foreach my $type (sort keys %tracking_flags_by_type) { + push @tracking_flags_by_type, { + name => $type, + flags => $tracking_flags_by_type{$type}, + }; + } + $vars->{tracking_flags_by_type} = \@tracking_flags_by_type; + ${ $args->{handled} } = 1; } @@ -197,7 +218,7 @@ sub user_wants_mail { require Bugzilla::Extension::TrackingFlags::Flag; my %count; my @tracking_flags; - foreach my $field (@$fields, @{ Bugzilla->tracking_flag_names }) { + foreach my $field (@$fields, Bugzilla->tracking_flag_names) { $count{$field}++; } foreach my $field (keys %count) { @@ -212,7 +233,7 @@ sub user_wants_mail { foreach my $type (keys %tracking_types) { push @$fields, 'tracking.' . $type; } - foreach my $field (@{ Bugzilla->tracking_flag_names }) { + foreach my $field (Bugzilla->tracking_flag_names) { $fields = [ grep { $_ ne $field } @$fields ]; } diff --git a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl index 83c8d729a..1bcbd35ae 100644 --- a/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl +++ b/extensions/BugmailFilter/template/en/default/account/prefs/bugmail_filter.html.tmpl @@ -173,84 +173,142 @@ var cpts = new Array(); If multiple filters are applicable to the same [% terms.bug %] change, include filters override exclude filters.

+ +
+

Field Groups

+

- Examples: + Some fields are grouped into a single entry in the "field" list. + Following is a list of the groups and all the fields they contain:

+ +[% FOREACH type = tracking_flags_by_type %] + [% type.name FILTER html %]: +
+ [% flag_count = type.flags.size %] + [% FOREACH flag = type.flags %] + [% IF flag_count > 10 && loop.count == 10 %] + + … + (show all) + + + [% END %] + [% flag.description FILTER html FILTER no_break %] + [% ", " UNLESS loop.last %] + [% IF loop.last && flag_count > 10 %] + + [% END %] + [% END %] +
+[% END %] + +
+

Examples

To never receive changes made to the "QA Whiteboard" field for [% terms.bugs %] where you are not the assignee:
- - - - - - - - - - - - - - - - - - - - - -
Field:QA Whiteboard
Product:__Any__
Component:__Any__
Relationship:Not Assignee
Action:Exclude

+ + + + + + + + + + + + + + + + + + + + + +
Field:QA Whiteboard
Product:__Any__
Component:__Any__
Relationship:Not Assignee
Action:Exclude
+ +

+ To receive notifications of new [% terms.bugs %] in Firefox's "New Tab Page" + component, and no other changes, you require three filters. First an + exclude filter to drop all changes made to [% terms.bugs %] in that + component:
+

+ + + + + + + + + + + + + + + + + + + + + +
Field:__Any__
Product:Firefox
Component:New Tab Page
Relationship:__Any__
Action:Exclude

- To receive just comments made to Firefox [% terms.bugs %], and no other - changes, you require two filters. First an exclude filter to drop all - changes made to [% terms.bugs %] in that product:
- - - - - - - - - - - - - - - - - - - - - -
Field:__Any__
Product:Firefox
Component:__Any__
Relationship:__Any__
Action:Exclude
-
Then an include filter to indicate that you want to receive - comments:
- - - - - - - - - - - - - - - - - - - - - -
Field:Comment Created
Product:Firefox
Component:__Any__
Relationship:__Any__
Action:Include
+ notifications when a [% terms.bug %] is created: +

+ + + + + + + + + + + + + + + + + + + + + +
Field:[% terms.Bug %] Created
Product:Firefox
Component:New Tab Page
Relationship:__Any__
Action:Include
+

+ And finally another include filter to catch when a [% terms.bug %] is + moved into the "New Tab Page" component.

+ + + + + + + + + + + + + + + + + + + + + +
Field:Component
Product:Firefox
Component:New Tab Page
Relationship:__Any__
Action:Include
diff --git a/extensions/BugmailFilter/web/js/bugmail-filter.js b/extensions/BugmailFilter/web/js/bugmail-filter.js index e298a60f1..2b320bbbb 100644 --- a/extensions/BugmailFilter/web/js/bugmail-filter.js +++ b/extensions/BugmailFilter/web/js/bugmail-filter.js @@ -29,6 +29,11 @@ function onRemoveChange() { Dom.get('remove').disabled = true; } +function showAllFlags() { + Dom.addClass('show_all', 'bz_default_hidden'); + Dom.removeClass('all_flags', 'bz_default_hidden'); +} + Event.onDOMReady(function() { Event.on('action', 'change', onFilterActionChange); onFilterProductChange(); -- cgit v1.2.3-24-g4f1b