summaryrefslogtreecommitdiffstats
path: root/extensions/BMO
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/BMO')
-rw-r--r--extensions/BMO/lib/Reports.pm61
-rw-r--r--extensions/BMO/template/en/default/pages/user_activity.html.tmpl132
-rw-r--r--extensions/BMO/web/styles/reports.css18
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 <glob@mozilla.com>
+# 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 <bjones@mozilla.com>
+ # 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 @@
</button>
<div id="con_calendar_to"></div>
</td>
+ <th>
+ Sort:
+ </th>
+ <td>
+ <select name="sort">
+ <option value="when" [% 'selected' IF sort == 'when' %]>When</option>
+ <option value="bug" [% 'selected' IF sort == 'bug' %]>[% terms.Bug %]</option>
+ </select>
+ </td>
<td>
<input type="submit" id="run" value="Generate Report">
</td>
@@ -107,49 +104,67 @@
[% IF who_count > 1 %]
<th>Who</th>
[% END %]
- <th>When</th>
- <th>[% terms.Bug %]</th>
+ [% IF sort == 'when' %]
+ <th class="sorted">[% INCLUDE sort_when_link %]</th>
+ <th>[% INCLUDE sort_bug_link %]</th>
+ [% ELSE %]
+ <th class="sorted">[% INCLUDE sort_bug_link %]</th>
+ <th>[% INCLUDE sort_when_link %]</th>
+ [% END %]
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
[% FOREACH operation = operations %]
- <tr>
- [% IF who_count > 1 %]
- <td rowspan="[% operation.changes.size %]" valign="top">
- [% operation.who FILTER email FILTER html %]
+ [% tr_class = loop.count % 2 ? 'report_row_even' : 'report_row_odd' %]
+ [% FOREACH change = operation.changes %]
+ <tr class="[% tr_class FILTER none %]">
+ [% IF loop.count == 1 %]
+ [% IF who_count > 1 %]
+ <td>[% operation.who FILTER email FILTER html %]</td>
+ [% END %]
+ [% IF sort == 'when' %]
+ <td>[% change.when FILTER time FILTER no_break %]</td>
+ <td>[% operation.bug FILTER bug_link(operation.bug) FILTER none %]</td>
+ [% ELSE %]
+ <td>[% operation.bug FILTER bug_link(operation.bug) FILTER none %]</td>
+ <td>[% change.when FILTER time FILTER no_break %]</td>
+ [% END %]
+ [% ELSE %]
+ [% IF who_count > 1 %]
+ <td>&nbsp;</td>
+ [% END %]
+ <td>&nbsp;</td>
+ [% IF sort == 'when' %]
+ <td>&nbsp;</td>
+ [% ELSE %]
+ <td>[% change.when FILTER time FILTER no_break %]</td>
+ [% END %]
+ [% END %]
+ <td>
+ [% IF change.attachid %]
+ <a href="attachment.cgi?id=[% change.attachid FILTER url %]"
+ title="[% change.attach.description FILTER html %]
+ [%- %] - [% change.attach.filename FILTER html %]"
+ >Attachment #[% change.attachid FILTER html %]</a>
+ [% 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 %]
</td>
- [% END %]
- <td rowspan="[% operation.changes.size %]" valign="top">
- [% operation.when FILTER time FILTER no_break %]
- </td>
- <td rowspan="[% operation.changes.size %]" valign="top">
- [% operation.bug FILTER bug_link(operation.bug) FILTER none %]
- </td>
- [% FOREACH change = operation.changes %]
- [% "</tr><tr>" IF loop.index > 0 %]
- <td>
- [% IF change.attachid %]
- <a href="attachment.cgi?id=[% change.attachid FILTER uri %]"
- title="[% change.attach.description FILTER html %]
- [%- %] - [% change.attach.filename FILTER html %]"
- >Attachment #[% change.attachid FILTER html %]</a>
- [% 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 %]
- </td>
- [% PROCESS change_column change_type = change.removed %]
- [% PROCESS change_column change_type = change.added %]
- [% END %]
- </tr>
+ [% PROCESS change_column change_type = change.removed %]
+ [% PROCESS change_column change_type = change.added %]
+ </tr>
+ [% END %]
[% END %]
</table>
<p>
- <a href="buglist.cgi?bug_id=[% bug_ids.join(',') FILTER uri %]">
+ <a href="buglist.cgi?bug_id=[% bug_ids.join(',') FILTER url %]">
Show as a [% terms.Bug %] List</a>
</p>
@@ -185,5 +200,20 @@
[% END %]
[% END %]
-
[% INCLUDE global/footer.html.tmpl %]
+
+[% BLOCK sort_when_link %]
+ <a href="page.cgi?id=user_activity.html&amp;action=run&amp;
+ [%~%]who=[% who FILTER url %]&amp;
+ [%~%]from=[% from FILTER url %]&amp;
+ [%~%]to=[% to FILTER url %]&amp;
+ [%~%]sort=when">When</a>
+[% END %]
+
+[% BLOCK sort_bug_link %]
+ <a href="page.cgi?id=user_activity.html&amp;action=run&amp;
+ [%~%]who=[% who FILTER url %]&amp;
+ [%~%]from=[% from FILTER url %]&amp;
+ [%~%]to=[% to FILTER url %]&amp;
+ [%~%]sort=bug">[% terms.Bug %]</a>
+[% 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;
}