diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-01 00:31:52 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-01 00:31:52 +0100 |
commit | fe4460ca51a5e4f94b700ab959065feedac3012a (patch) | |
tree | 0d455a2e405d55a0b20111988c19dbdd9219a5ce /extensions/MyDashboard | |
parent | 3e98571c51990961c17debbfb38ffcc208905e8e (diff) | |
download | bugzilla-fe4460ca51a5e4f94b700ab959065feedac3012a.tar.gz bugzilla-fe4460ca51a5e4f94b700ab959065feedac3012a.tar.xz |
MyDashboard improvements
Diffstat (limited to 'extensions/MyDashboard')
-rw-r--r-- | extensions/MyDashboard/lib/Queries.pm | 46 | ||||
-rw-r--r-- | extensions/MyDashboard/web/js/flags.js | 23 | ||||
-rw-r--r-- | extensions/MyDashboard/web/js/query.js | 24 |
3 files changed, 59 insertions, 34 deletions
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm index 984002461..2b9d11737 100644 --- a/extensions/MyDashboard/lib/Queries.pm +++ b/extensions/MyDashboard/lib/Queries.pm @@ -13,12 +13,12 @@ use Bugzilla; use Bugzilla::Bug; use Bugzilla::CGI; use Bugzilla::Search; -use Bugzilla::Util qw(format_time); +use Bugzilla::Util qw(format_time datetime_from); use Bugzilla::Extension::MyDashboard::Util qw(open_states quoted_open_states); use Bugzilla::Extension::MyDashboard::TimeAgo qw(time_ago); -use Data::Dumper; +use DateTime; use base qw(Exporter); our @EXPORT = qw( @@ -129,8 +129,9 @@ sub QUERY_DEFS { } sub query_bugs { - my $qdef = shift; - my $dbh = Bugzilla->dbh; + my $qdef = shift; + my $dbh = Bugzilla->dbh; + my $date_now = DateTime->now; ## HACK to remove POST delete $ENV{REQUEST_METHOD}; @@ -140,7 +141,6 @@ sub query_bugs { my $search = new Bugzilla::Search( fields => [ SELECT_COLUMNS ], params => scalar $params->Vars, order => [ QUERY_ORDER ]); - my $data = $search->data; my @bugs; @@ -150,8 +150,8 @@ sub query_bugs { $bug->{$column} = shift @$row; if ($column eq 'changeddate') { $bug->{$column} = format_time($bug->{$column}, '%Y-%m-%d %H:%M'); - # my $date_then = datetime_from($bug->{$column}); - # $bug->{'updated'} = time_ago($date_then, $date_now); + my $date_then = datetime_from($bug->{$column}); + $bug->{'changeddate_fancy'} = time_ago($date_then, $date_now); } } push(@bugs, $bug); @@ -161,9 +161,10 @@ sub query_bugs { } sub query_flags { - my $type = shift; - my $user = Bugzilla->user; - my $dbh = Bugzilla->dbh; + my $type = shift; + my $user = Bugzilla->user; + my $dbh = Bugzilla->dbh; + my $date_now = DateTime->now; ($type ne 'requestee' || $type ne 'requester') || ThrowCodeError('param_required', { param => 'type' }); @@ -222,21 +223,28 @@ sub query_flags { # Order the records (within each group). my $group_order_by = " GROUP BY flags.bug_id ORDER BY flags.creation_date, flagtypes.name"; + my $flags = []; if ($type eq 'requestee') { - return $dbh->selectall_arrayref($query . - " AND requestees.login_name = ? " . - $group_order_by, - { Slice => {} }, $user->login); + $flags = $dbh->selectall_arrayref($query . + " AND requestees.login_name = ? " . + $group_order_by, + { Slice => {} }, $user->login); } if ($type eq 'requester') { - return $dbh->selectall_arrayref($query . - " AND requesters.login_name = ? " . - $group_order_by, - { Slice => {} }, $user->login); + $flags = $dbh->selectall_arrayref($query . + " AND requesters.login_name = ? " . + $group_order_by, + { Slice => {} }, $user->login); + } + + # Add the fancy date + foreach my $flag (@$flags) { + my $date_then = datetime_from($flag->{'created'}); + $flag->{'created_fancy'} = time_ago($date_then, $date_now); } - return undef; + return $flags; } 1; diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js index e212466e8..6820ec289 100644 --- a/extensions/MyDashboard/web/js/flags.js +++ b/extensions/MyDashboard/web/js/flags.js @@ -71,14 +71,21 @@ YUI({ Y.Escape.html(o.data.bug_summary) + '">' + o.value + '</a>'; }; + var createdFormatter = function (o) { + return '<span title="' + Y.Escape.html(o.value) + '">' + + Y.Escape.html(o.data.created_fancy) + '</span>'; + }; + // Requestee dataSource.requestee = new Y.DataSource.IO({ source: 'jsonrpc.cgi' }); dataTable.requestee = new Y.DataTable({ columns: [ { key: "requester", label: "Requester", sortable: true }, { key: "type", label: "Flag", sortable: true }, - { key: "bug_id", label: "Bug", sortable: true, formatter: bugLinkFormatter, allowHTML: true }, - { key: "created", label: "Created", sortable: true } + { key: "bug_id", label: "Bug", sortable: true, + formatter: bugLinkFormatter, allowHTML: true }, + { key: "created", label: "Created", sortable: true, + formatter: createdFormatter, allowHTML: true } ], strings: { emptyMessage: 'No flag data found.', @@ -95,7 +102,8 @@ YUI({ dataSource.requestee.plug(Y.Plugin.DataSourceJSONSchema, { schema: { resultListLocator: "result.result.requestee", - resultFields: ["requester", "type", "bug_id", "bug_status", "bug_summary", "created"] + resultFields: ["requester", "type", "bug_id", "bug_status", + "bug_summary", "created", "created_fancy"] } }); @@ -111,8 +119,10 @@ YUI({ columns: [ { key:"requestee", label:"Requestee", sortable:true }, { key:"type", label:"Flag", sortable:true }, - { key:"bug_id", label:"Bug", sortable:true, formatter: bugLinkFormatter, allowHTML: true }, - { key:"created", label:"Created", sortable:true } + { key:"bug_id", label:"Bug", sortable:true, + formatter: bugLinkFormatter, allowHTML: true }, + { key: "created", label: "Created", sortable: true, + formatter: createdFormatter, allowHTML: true } ], strings: { emptyMessage: 'No flag data found.', @@ -129,7 +139,8 @@ YUI({ dataSource.requester.plug(Y.Plugin.DataSourceJSONSchema, { schema: { resultListLocator: "result.result.requester", - resultFields: ["requestee", "type", "bug_id", "bug_status", "bug_summary", "created"] + resultFields: ["requestee", "type", "bug_id", "bug_status", + "bug_summary", "created", "created_fancy"] } }); diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js index 865d255a6..2ce438509 100644 --- a/extensions/MyDashboard/web/js/query.js +++ b/extensions/MyDashboard/web/js/query.js @@ -19,7 +19,7 @@ YUI({ } }).use("node", "datatable", "datatable-sort", "datatable-message", "json-stringify", "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie", - "gallery-datatable-row-expansion-bmo", "handlebars", function (Y) { + "gallery-datatable-row-expansion-bmo", "handlebars", "escape", function (Y) { var counter = 0, dataSource = null, dataTable = null, @@ -86,13 +86,18 @@ YUI({ }); }; + var updatedFormatter = function (o) { + return '<span title="' + Y.Escape.html(o.value) + '">' + + Y.Escape.html(o.data.changeddate_fancy) + '</span>'; + }; + dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi' }); dataSource.plug(Y.Plugin.DataSourceJSONSchema, { schema: { resultListLocator: "result.result.bugs", - resultFields: ["bug_id", "changeddate", "bug_status", - "short_desc", "last_changes"], + resultFields: ["bug_id", "changeddate", "changeddate_fancy", + "bug_status", "short_desc", "last_changes"], metaFields: { description: "result.result.description", heading: "result.result.heading", @@ -103,13 +108,14 @@ YUI({ dataTable = new Y.DataTable({ columns: [ - { 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: Y.Plugin.DataTableRowExpansion.column_key, label: ' ', sortable: false }, + { key: "bug_id", label: "Bug", allowHTML: true, + formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>' }, + { key: "changeddate", label: "Updated", formatter: updatedFormatter, allowHTML: true }, + { key: "bug_status", label: "Status" }, + { key: "short_desc", label: "Summary" }, ], + sortable: true }); var last_changes_source = Y.one('#last-changes-template').getHTML(), |