summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-01-03 20:41:44 +0100
committerDave Lawrence <dlawrence@mozilla.com>2013-01-03 20:41:44 +0100
commita29bc8846fac5d7bcbe37ed306eb612bfc74acee (patch)
tree20e0b5e7531797d891a912749d068b34903cd7d7 /extensions
parentf3975a11266aad202f31ce6fe8e86f321c68cd3e (diff)
downloadbugzilla-a29bc8846fac5d7bcbe37ed306eb612bfc74acee.tar.gz
bugzilla-a29bc8846fac5d7bcbe37ed306eb612bfc74acee.tar.xz
More MyDashboard work
Diffstat (limited to 'extensions')
-rw-r--r--extensions/MyDashboard/lib/Queries.pm4
-rw-r--r--extensions/MyDashboard/lib/WebService.pm27
-rw-r--r--extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl43
-rw-r--r--extensions/MyDashboard/web/js/mydashboard_yui2.js159
-rw-r--r--extensions/MyDashboard/web/js/query.js43
-rw-r--r--extensions/MyDashboard/web/styles/mydashboard.css11
6 files changed, 119 insertions, 168 deletions
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm
index 79247bf73..e81e7f73f 100644
--- a/extensions/MyDashboard/lib/Queries.pm
+++ b/extensions/MyDashboard/lib/Queries.pm
@@ -10,6 +10,7 @@ package Bugzilla::Extension::MyDashboard::Queries;
use strict;
use Bugzilla;
+use Bugzilla::Bug;
use Bugzilla::CGI;
use Bugzilla::Search;
use Bugzilla::Util qw(format_time);
@@ -17,6 +18,8 @@ use Bugzilla::Util qw(format_time);
use Bugzilla::Extension::MyDashboard::Util qw(open_states quoted_open_states);
use Bugzilla::Extension::MyDashboard::TimeAgo qw(time_ago);
+use Data::Dumper;
+
use base qw(Exporter);
our @EXPORT = qw(
QUERY_ORDER
@@ -242,5 +245,4 @@ sub query_flags {
return undef;
}
-
1;
diff --git a/extensions/MyDashboard/lib/WebService.pm b/extensions/MyDashboard/lib/WebService.pm
index 853ef2baf..07619e705 100644
--- a/extensions/MyDashboard/lib/WebService.pm
+++ b/extensions/MyDashboard/lib/WebService.pm
@@ -9,7 +9,7 @@ package Bugzilla::Extension::MyDashboard::WebService;
use strict;
use warnings;
-use base qw(Bugzilla::WebService);
+use base qw(Bugzilla::WebService Bugzilla::WebService::Bug);
use Bugzilla::Constants;
use Bugzilla::Error;
@@ -92,6 +92,7 @@ sub prod_comp_search {
sub run_bug_query {
my($self, $params) = @_;
+ my $dbh = Bugzilla->dbh;
my $user = Bugzilla->login(LOGIN_REQUIRED);
defined $params->{query}
@@ -103,6 +104,30 @@ sub run_bug_query {
foreach my $qdef (QUERY_DEFS) {
next if $qdef->{name} ne $params->{query};
my ($bugs, $query_string) = query_bugs($qdef);
+
+ # Add last changes to each bug
+ foreach my $b (@$bugs) {
+ my $last_changes = {};
+ my $activity = $self->history({ ids => [ $b->{bug_id} ],
+ start_time => $b->{changeddate} });
+ if (@{$activity->{bugs}[0]{history}}) {
+ $last_changes->{activity} = $activity->{bugs}[0]{history}[0]{changes};
+ $last_changes->{email} = $activity->{bugs}[0]{history}[0]{who};
+ $last_changes->{when} = $activity->{bugs}[0]{history}[0]{when};
+ }
+ my $last_comment_id = $dbh->selectrow_array("
+ SELECT comment_id FROM longdescs
+ WHERE bug_id = ? AND bug_when >= ?",
+ undef, $b->{bug_id}, $b->{changeddate});
+ if ($last_comment_id) {
+ my $comments = $self->comments({ comment_ids => [ $last_comment_id ] });
+ $last_changes->{comment} = $comments->{comments}{$last_comment_id}{text};
+ $last_changes->{email} = $comments->{comments}{$last_comment_id}{creator} if !$last_changes->{email};
+ $last_changes->{when} = $comments->{comments}{$last_comment_id}{creation_time} if !$last_changes->{when};
+ }
+ $b->{last_changes} = $last_changes;
+ }
+
$query_string =~ s/^POSTDATA=&//;
$qdef->{bugs} = $bugs;
$qdef->{buffer} = $query_string;
diff --git a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
index dcaad0441..e5cd64399 100644
--- a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
+++ b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
@@ -24,6 +24,49 @@
[% saved_queries.push(q) IF q.saved %]
[% END %]
+<script id="last-changes-template" type="text/x-handlebars-template">
+ {{#if email}}
+ <div id="last_changes">
+ <div id="last_changes_header">
+ Last Changes :: {{email}} :: {{when}}
+ </div>
+ {{#if activity}}
+ <table id="activity">
+ {{#each activity}}
+ <tr>
+ <td class="field_label">{{field_name}}:</td>
+ <td class="field_data">
+ {{#if removed}}
+ {{#unless added}}
+ Removed:
+ {{/unless}}
+ {{removed}}
+ {{/if}}
+ {{#if added}}
+ {{#if removed}}
+ &rarr;
+ {{/if}}
+ {{/if}}
+ {{#if added}}
+ {{#unless removed}}
+ Added:
+ {{/unless}}
+ {{added}}
+ {{/if}}
+ </td>
+ </tr>
+ {{/each}}
+ </table>
+ {{/if}}
+ {{#if comment}}
+ <pre class='bz_comment_text'>{{comment}}</pre>
+ {{/if}}
+ {{else}}
+ This is a new [% terms.bug %] and no changes have been made yet.
+ {{/if}}
+ </div>
+</script>
+
<div id="mydashboard">
<div class="yui3-skin-sam">
<div id="left">
diff --git a/extensions/MyDashboard/web/js/mydashboard_yui2.js b/extensions/MyDashboard/web/js/mydashboard_yui2.js
deleted file mode 100644
index 25529d8c8..000000000
--- a/extensions/MyDashboard/web/js/mydashboard_yui2.js
+++ /dev/null
@@ -1,159 +0,0 @@
-/* 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.
- */
-
-YAHOO.namespace('MyDashboard');
-
-var MD = YAHOO.MyDashboard;
-
-MD.showQuerySection = function () {
- var query_select = YAHOO.util.Dom.get('query');
- var selected_value = '';
- for (var i = 0, l = query_select.options.length; i < l; i++) {
- if (query_select.options[i].selected) {
- selected_value = query_select.options[i].value;
- }
- }
- for (var i = 0, l = MD.full_query_list.length; i < l; i++) {
- var query = MD.full_query_list[i];
- if (selected_value == MD.full_query_list[i]) {
- YAHOO.util.Dom.removeClass(query + '_container', 'bz_default_hidden');
- }
- else {
- YAHOO.util.Dom.addClass(query + '_container', 'bz_default_hidden');
- }
- }
-}
-
-MD.query_column_defs = [
- { key:"id", label:"ID", sortable:true, sortOptions:{ sortFunction: MD.sortBugIdLinks } },
- { key:"updated", label:"Updated", sortable:true },
- { key:"bug_status", label:"Status", sortable:true },
- { key:"summary", label:"Summary", sortable:true },
-];
-
-MD.query_fields = [
- { key:"id" },
- { key:"updated" },
- { key:"bug_status" },
- { key:"summary" }
-];
-
-MD.requestee_column_defs = [
- { key:"requester", label:"Requester", sortable:true },
- { key:"flag", label:"Flag", sortable:true },
- { key:"bug", label:"Bug", sortable:true },
- { key:"created", label:"Created", sortable:true }
-];
-
-MD.requestee_fields = [
- { key:"requester" },
- { key:"flag" },
- { key:"bug" },
- { key:"created" }
-];
-
-MD.requester_column_defs = [
- { key:"requestee", label:"Requestee", sortable:true },
- { key:"flag", label:"Flag", sortable:true },
- { key:"bug", label:"Bug", sortable:true },
- { key:"created", label:"Created", sortable:true }
-];
-
-MD.requester_fields = [
- { key:"requestee" },
- { key:"flag" },
- { key:"bug" },
- { key:"created" }
-];
-
-MD.addStatListener = function (div_name, table_name, column_defs, fields, options) {
- YAHOO.util.Event.addListener(window, "load", function() {
- YAHOO.example.StatsFromMarkup = new function() {
- this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get(table_name));
- this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
- this.myDataSource.responseSchema = { fields:fields };
- this.myDataTable = new YAHOO.widget.DataTable(div_name, column_defs, this.myDataSource, options);
- this.myDataTable.subscribe("rowMouseoverEvent", this.myDataTable.onEventHighlightRow);
- this.myDataTable.subscribe("rowMouseoutEvent", this.myDataTable.onEventUnhighlightRow);
- };
- });
-}
-
-// Custom sort handler to sort by bug id inside an anchor tag
-MD.sortBugIdLinks = function (a, b, desc) {
- // Deal with empty values
- if (!YAHOO.lang.isValue(a)) {
- return (!YAHOO.lang.isValue(b)) ? 0 : 1;
- }
- else if(!YAHOO.lang.isValue(b)) {
- return -1;
- }
- // Now we need to pull out the ID text and convert to Numbers
- // First we do 'a'
- var container = document.createElement("bug_id_link");
- container.innerHTML = a.getData("id");
- var anchors = container.getElementsByTagName("a");
- var text = anchors[0].textContent;
- if (text === undefined) text = anchors[0].innerText;
- var new_a = new Number(text);
- // Then we do 'b'
- container.innerHTML = b.getData("id");
- anchors = container.getElementsByTagName("a");
- text = anchors[0].textContent;
- if (text == undefined) text = anchors[0].innerText;
- var new_b = new Number(text);
-
- if (!desc) {
- return YAHOO.util.Sort.compare(new_a, new_b);
- }
- else {
- return YAHOO.util.Sort.compare(new_b, new_a);
- }
-}
-
-// Custom sort handler for bug severities
-MD.sortBugSeverity = function (a, b, desc) {
- // Deal with empty values
- if (!YAHOO.lang.isValue(a)) {
- return (!YAHOO.lang.isValue(b)) ? 0 : 1;
- }
- else if(!YAHOO.lang.isValue(b)) {
- return -1;
- }
-
- var new_a = new Number(MD.severities[YAHOO.lang.trim(a.getData('bug_severity'))]);
- var new_b = new Number(MD.severities[YAHOO.lang.trim(b.getData('bug_severity'))]);
-
- if (!desc) {
- return YAHOO.util.Sort.compare(new_a, new_b);
- }
- else {
- return YAHOO.util.Sort.compare(new_b, new_a);
- }
-}
-
-// Custom sort handler for bug priorities
-MD.sortBugPriority = function (a, b, desc) {
- // Deal with empty values
- if (!YAHOO.lang.isValue(a)) {
- return (!YAHOO.lang.isValue(b)) ? 0 : 1;
- }
- else if(!YAHOO.lang.isValue(b)) {
- return -1;
- }
-
- var new_a = new Number(MD.priorities[YAHOO.lang.trim(a.getData('priority'))]);
- var new_b = new Number(MD.priorities[YAHOO.lang.trim(b.getData('priority'))]);
-
- if (!desc) {
- return YAHOO.util.Sort.compare(new_a, new_b);
- }
- else {
- return YAHOO.util.Sort.compare(new_b, new_a);
- }
-}
diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js
index 746717e75..865d255a6 100644
--- a/extensions/MyDashboard/web/js/query.js
+++ b/extensions/MyDashboard/web/js/query.js
@@ -9,9 +9,17 @@
// Main query code
YUI({
base: 'js/yui3/',
- combine: false
+ combine: false,
+ groups: {
+ gallery: {
+ combine: false,
+ base: 'js/yui3/',
+ patterns: { 'gallery-': {} }
+ }
+ }
}).use("node", "datatable", "datatable-sort", "datatable-message", "json-stringify",
- "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie", function (Y) {
+ "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie",
+ "gallery-datatable-row-expansion-bmo", "handlebars", function (Y) {
var counter = 0,
dataSource = null,
dataTable = null,
@@ -83,7 +91,8 @@ YUI({
dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
schema: {
resultListLocator: "result.result.bugs",
- resultFields: ["bug_id", "changeddate", "bug_status", "short_desc"],
+ resultFields: ["bug_id", "changeddate", "bug_status",
+ "short_desc", "last_changes"],
metaFields: {
description: "result.result.description",
heading: "result.result.heading",
@@ -94,14 +103,34 @@ YUI({
dataTable = new Y.DataTable({
columns: [
- { key:"bug_id", label:"Bug", sortable:true,
+ { key: Y.Plugin.DataTableRowExpansion.column_key, label: ' ' },
+ { key: "bug_id", label: "Bug", sortable: true,
formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
- { key:"changeddate", label:"Updated", sortable:true },
- { key:"bug_status", label:"Status", sortable:true },
- { key:"short_desc", label:"Summary", sortable:true },
+ { key: "changeddate", label: "Updated", sortable: true },
+ { key: "bug_status", label: "Status", sortable: true },
+ { key: "short_desc", label: "Summary", sortable: true },
],
});
+ var last_changes_source = Y.one('#last-changes-template').getHTML(),
+ last_changes_template = Y.Handlebars.compile(last_changes_source);
+
+ dataTable.plug(Y.Plugin.DataTableRowExpansion, {
+ uniqueIdKey: 'bug_id',
+ template: function(data) {
+ var last_changes = {};
+ if (data.last_changes.email) {
+ last_changes = {
+ activity: data.last_changes.activity,
+ email: data.last_changes.email,
+ when: data.last_changes.when,
+ comment: data.last_changes.comment,
+ };
+ }
+ return last_changes_template(last_changes);
+ }
+ });
+
dataTable.plug(Y.Plugin.DataTableSort);
dataTable.plug(Y.Plugin.DataTableDataSource, {
diff --git a/extensions/MyDashboard/web/styles/mydashboard.css b/extensions/MyDashboard/web/styles/mydashboard.css
index dc253c0d1..253e60d42 100644
--- a/extensions/MyDashboard/web/styles/mydashboard.css
+++ b/extensions/MyDashboard/web/styles/mydashboard.css
@@ -51,3 +51,14 @@
padding: 20px !important;
height: 40px;
}
+
+#last_changes_header {
+ font-size: 12px;
+ font-weight: bold;
+ padding-bottom: 5px;
+ border-bottom: 1px solid rgb(200, 200, 186);
+}
+
+#last_changes .field_label {
+ text-align: left;
+}