From 681f39d6a59163e4f36dc5c64c3b528b41bb0639 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Fri, 10 Feb 2012 15:12:33 +0800 Subject: Bug 722335: add sort-by-bug to user activity report --- extensions/BMO/lib/Reports.pm | 61 +++++----- .../en/default/pages/user_activity.html.tmpl | 132 +++++++++++++-------- extensions/BMO/web/styles/reports.css | 18 ++- 3 files changed, 127 insertions(+), 84 deletions(-) diff --git a/extensions/BMO/lib/Reports.pm b/extensions/BMO/lib/Reports.pm index 3337963b9..8d8dc3c0e 100644 --- a/extensions/BMO/lib/Reports.pm +++ b/extensions/BMO/lib/Reports.pm @@ -1,21 +1,9 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- +# 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/. # -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -# the specific language governing rights and limitations under the License. -# -# The Original Code is the BMO Bugzilla Extension. -# -# The Initial Developer of the Original Code is Byron Jones. Portions created -# by the Initial Developer are Copyright (C) 2011 the Mozilla Foundation. All -# Rights Reserved. -# -# Contributor(s): -# Byron Jones +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::BMO::Reports; use strict; @@ -47,8 +35,13 @@ sub user_activity_report { my $input = Bugzilla->input_params; my @who = (); - my $from = trim($input->{'from'}); - my $to = trim($input->{'to'}); + my $from = trim($input->{'from'} || ''); + my $to = trim($input->{'to'} || ''); + my $action = $input->{'action'} || ''; + + # fix non-breaking hyphens + $from =~ s/\N{U+2011}/-/g; + $to =~ s/\N{U+2011}/-/g; if ($from eq '') { my $dt = DateTime->now()->subtract('weeks' => 8); @@ -59,7 +52,7 @@ sub user_activity_report { $to = $dt->ymd('-'); } - if ($input->{'action'} eq 'run') { + if ($action eq 'run') { if ($input->{'who'} eq '') { ThrowUserError('user_activity_missing_username'); } @@ -118,6 +111,8 @@ sub user_activity_report { push @params, ($from_dt, $to_dt); } + my $order = $input->{'sort'} eq 'bug' ? 'bug_id' : 'bug_when'; + my $comment_filter = ''; if (!Bugzilla->user->is_insider) { $comment_filter = 'AND longdescs.isprivate = 0'; @@ -200,7 +195,7 @@ sub user_activity_report { AND attachments.creation_ts >= ? AND attachments.creation_ts <= ? $attachments_where - ORDER BY bug_when "; + ORDER BY $order "; my $list = $dbh->selectall_arrayref($query, undef, @params); @@ -243,14 +238,18 @@ sub user_activity_report { $incomplete_data = 1; } - # An operation, done by 'who' at time 'when', has a number of - # 'changes' associated with it. - # If this is the start of a new operation, store the data from the - # previous one, and set up the new one. - if ($operation->{'who'} - && ($who ne $operation->{'who'} - || $when ne $operation->{'when'})) - { + # Start a new changeset if required (depends on the sort order) + my $is_new_changeset; + if ($order eq 'bug_when') { + $is_new_changeset = + $operation->{'who'} && + ($who ne $operation->{'who'} || $when ne $operation->{'when'}); + } else { + $is_new_changeset = + $operation->{'bug'} && + $bugid != $operation->{'bug'}; + } + if ($is_new_changeset) { $operation->{'changes'} = $changes; push (@operations, $operation); $operation = {}; @@ -267,6 +266,7 @@ sub user_activity_report { $change{'attachid'} = $attachid; $change{'removed'} = $removed; $change{'added'} = $added; + $change{'when'} = $when; if ($comment_id) { $change{'comment'} = Bugzilla::Comment->new($comment_id); @@ -293,11 +293,12 @@ sub user_activity_report { $vars->{'bug_ids'} = \@bug_ids; } - $vars->{'action'} = $input->{'action'}; + $vars->{'action'} = $action; $vars->{'who'} = join(',', @who); $vars->{'who_count'} = scalar @who; $vars->{'from'} = $from; $vars->{'to'} = $to; + $vars->{'sort'} = $input->{'sort'}; } sub _string_to_datetime { diff --git a/extensions/BMO/template/en/default/pages/user_activity.html.tmpl b/extensions/BMO/template/en/default/pages/user_activity.html.tmpl index 4a335eab0..6982148cd 100644 --- a/extensions/BMO/template/en/default/pages/user_activity.html.tmpl +++ b/extensions/BMO/template/en/default/pages/user_activity.html.tmpl @@ -1,21 +1,9 @@ -[%# The contents of this file are subject to the Mozilla Public - # License Version 1.1 (the "License"); you may not use this file - # except in compliance with the License. You may obtain a copy of - # the License at http://www.mozilla.org/MPL/ +[%# 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/. # - # Software distributed under the License is distributed on an "AS - # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - # implied. See the License for the specific language governing - # rights and limitations under the License. - # - # The Original Code is the BMO Extension - # - # The Initial Developer of the Original Code is the Mozilla Foundation - # Portions created by the Initial Developers are Copyright (C) 2011 the - # Initial Developer. All Rights Reserved. - # - # Contributor(s): - # Byron Jones + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. #%] [% IF who %] @@ -75,6 +63,15 @@
+ + Sort: + + + + @@ -107,49 +104,67 @@ [% IF who_count > 1 %] Who [% END %] - When - [% terms.Bug %] + [% IF sort == 'when' %] + [% INCLUDE sort_when_link %] + [% INCLUDE sort_bug_link %] + [% ELSE %] + [% INCLUDE sort_bug_link %] + [% INCLUDE sort_when_link %] + [% END %] What Removed Added [% FOREACH operation = operations %] - - [% IF who_count > 1 %] - - [% operation.who FILTER email FILTER html %] + [% tr_class = loop.count % 2 ? 'report_row_even' : 'report_row_odd' %] + [% FOREACH change = operation.changes %] + + [% IF loop.count == 1 %] + [% IF who_count > 1 %] + [% operation.who FILTER email FILTER html %] + [% END %] + [% IF sort == 'when' %] + [% change.when FILTER time FILTER no_break %] + [% operation.bug FILTER bug_link(operation.bug) FILTER none %] + [% ELSE %] + [% operation.bug FILTER bug_link(operation.bug) FILTER none %] + [% change.when FILTER time FILTER no_break %] + [% END %] + [% ELSE %] + [% IF who_count > 1 %] +   + [% END %] +   + [% IF sort == 'when' %] +   + [% ELSE %] + [% change.when FILTER time FILTER no_break %] + [% END %] + [% END %] + + [% IF change.attachid %] + Attachment #[% change.attachid FILTER html %] + [% END %] + [%IF change.comment.defined && change.fieldname == 'longdesc' %] + [% "Comment $change.comment.count" + FILTER bug_link(operation.bug, comment_num => change.comment.count) + FILTER none %] + [% ELSE %] + [%+ field_descs.${change.fieldname} FILTER html %] + [% END %] - [% END %] - - [% operation.when FILTER time FILTER no_break %] - - - [% operation.bug FILTER bug_link(operation.bug) FILTER none %] - - [% FOREACH change = operation.changes %] - [% "" IF loop.index > 0 %] - - [% IF change.attachid %] - Attachment #[% change.attachid FILTER html %] - [% END %] - [%IF change.comment.defined && change.fieldname == 'longdesc' %] - [% "Comment $change.comment.count" FILTER bug_link(operation.bug, comment_num => change.comment.count) FILTER none %] - [% ELSE %] - [%+ field_descs.${change.fieldname} FILTER html %] - [% END %] - - [% PROCESS change_column change_type = change.removed %] - [% PROCESS change_column change_type = change.added %] - [% END %] - + [% PROCESS change_column change_type = change.removed %] + [% PROCESS change_column change_type = change.added %] + + [% END %] [% END %]

- + Show as a [% terms.Bug %] List

@@ -185,5 +200,20 @@ [% END %] [% END %] - [% INCLUDE global/footer.html.tmpl %] + +[% BLOCK sort_when_link %] + When +[% END %] + +[% BLOCK sort_bug_link %] + [% terms.Bug %] +[% END %] diff --git a/extensions/BMO/web/styles/reports.css b/extensions/BMO/web/styles/reports.css index fa2acf8d3..2a6bc54fc 100644 --- a/extensions/BMO/web/styles/reports.css +++ b/extensions/BMO/web/styles/reports.css @@ -23,17 +23,21 @@ text-align: left; } +#report th.sorted { + text-decoration: underline; +} + #report-header { - background: #dddddd; + background: #cccccc; } .report_row_odd { - background-color: #F7F7F7; + background-color: #eeeeee; color: #000000; } .report_row_even { - background-color: #FFFFFF; + background-color: #ffffff; color: #000000; } @@ -41,6 +45,14 @@ background-color: #ccccff; } +#report { + border: 1px solid #888888; +} + +#report th, #report td { + border: 0px; +} + .disabled { color: #888888; } -- cgit v1.2.3-24-g4f1b