diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-21 20:57:53 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-03-21 20:57:53 +0100 |
commit | 897f58ced15e63ca63e870a40991eaf97de84f2f (patch) | |
tree | c82b8104c7f3f4e0860f98cc0381f7cd5db5f1d0 /extensions | |
parent | a64fdeb4ee2ce3d3757f9bdd87def70d1e82036e (diff) | |
download | bugzilla-897f58ced15e63ca63e870a40991eaf97de84f2f.tar.gz bugzilla-897f58ced15e63ca63e870a40991eaf97de84f2f.tar.xz |
Bug 853432 - "Flags requested of you" doesn't show flags that are requested on Resolved bugs
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/MyDashboard/lib/Queries.pm | 32 | ||||
-rw-r--r-- | extensions/MyDashboard/lib/WebService.pm | 12 | ||||
-rw-r--r-- | extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl | 4 | ||||
-rw-r--r-- | extensions/MyDashboard/web/js/flags.js | 39 |
4 files changed, 54 insertions, 33 deletions
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm index e8813989b..5a3bf0cc6 100644 --- a/extensions/MyDashboard/lib/Queries.pm +++ b/extensions/MyDashboard/lib/Queries.pm @@ -161,7 +161,7 @@ sub query_bugs { } sub query_flags { - my $type = shift; + my ($type, $include_resolved) = @_; my $user = Bugzilla->user; my $dbh = Bugzilla->dbh; my $date_now = DateTime->now; @@ -174,20 +174,20 @@ sub query_flags { $attach_join_clause .= " AND attachments.isprivate < 1"; } - my $query = + my $query = # Select columns describing each flag, the bug/attachment on which # it has been set, who set it, and of whom they are requesting it. - " SELECT flags.id AS id, + " SELECT flags.id AS id, flagtypes.name AS type, flags.status AS status, - flags.bug_id AS bug_id, + flags.bug_id AS bug_id, bugs.bug_status AS bug_status, bugs.short_desc AS bug_summary, - flags.attach_id AS attach_id, + flags.attach_id AS attach_id, attachments.description AS attach_summary, - requesters.login_name AS requester, + requesters.login_name AS requester, requestees.login_name AS requestee, - " . $dbh->sql_date_format('flags.creation_date', '%Y-%m-%d %H:%i') . " AS created + " . $dbh->sql_date_format('flags.modification_date', '%Y-%m-%d %H:%i') . " AS updated FROM flags LEFT JOIN attachments ON ($attach_join_clause) @@ -206,8 +206,12 @@ sub query_flags { AND ccmap.bug_id = bugs.bug_id "; # Limit query to pending requests and open bugs only - $query .= " WHERE bugs.bug_status IN (" . join(',', quoted_open_states()) . ") - AND flags.status = '?' "; + $query .= " WHERE flags.status = '?' "; + + # Limit to open bugs only unless want to include resolved + if (!$include_resolved) { + $query .= " AND bugs.bug_status IN (" . join(',', quoted_open_states()) . ") "; + } # Weed out bug the user does not have access to $query .= " AND ((bgmap.group_id IS NULL) @@ -221,7 +225,7 @@ sub query_flags { $query .= ") "; # Order the records (within each group). - my $group_order_by = " GROUP BY flags.bug_id ORDER BY flags.creation_date, flagtypes.name"; + my $group_order_by = " GROUP BY flags.bug_id ORDER BY flags.modification_date, flagtypes.name"; my $flags = []; if ($type eq 'requestee') { @@ -238,11 +242,11 @@ sub query_flags { { Slice => {} }, $user->login); } - # Format the created date specific to the user's timezone and add the fancy version + # Format the updated date specific to the user's timezone and add the fancy version foreach my $flag (@$flags) { - $flag->{'created'} = format_time($flag->{'created'}, '%Y-%m-%d %H:%M'); - my $date_then = datetime_from($flag->{'created'}); - $flag->{'created_fancy'} = time_ago($date_then, $date_now); + $flag->{'updated'} = format_time($flag->{'updated'}, '%Y-%m-%d %H:%M'); + my $date_then = datetime_from($flag->{'updated'}); + $flag->{'updated_fancy'} = time_ago($date_then, $date_now); } return $flags; diff --git a/extensions/MyDashboard/lib/WebService.pm b/extensions/MyDashboard/lib/WebService.pm index 1f3b7ce06..1a9c212f4 100644 --- a/extensions/MyDashboard/lib/WebService.pm +++ b/extensions/MyDashboard/lib/WebService.pm @@ -82,13 +82,13 @@ sub run_flag_query { my ($self, $params) =@_; my $user = Bugzilla->login(LOGIN_REQUIRED); - defined $params->{type} - || ThrowCodeError('param_required', - { function => 'MyDashboard.run_flag_query', - param => 'type' }); - my $type = $params->{type}; - my $results = query_flags($type); + $type || ThrowCodeError('param_required', + { function => 'MyDashboard.run_flag_query', + param => 'type' }); + + my $include_resolved = $params->{include_resolved} || 0; + my $results = query_flags($type, $include_resolved); return { result => { $type => $results }}; } diff --git a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl index 48ab15c9b..e96ee8cde 100644 --- a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl +++ b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl @@ -115,6 +115,8 @@ <span id="requestee_count_refresh" class="bz_default_hidden"> <span class="items_found" id="requestee_flags_found">0 flags found</span> | <a class="refresh" href="javascript:void(0);" id="requestee_refresh">Refresh</a> + | <input type="checkbox" id="requestee_resolved"> + <label for="requestee_resolved">Show resolved</label> </span> <div id="requestee_table"></div> </div> @@ -126,6 +128,8 @@ <span id="requester_count_refresh" class="bz_default_hidden"> <span class="items_found" id="requester_flags_found">0 flags found</span> | <a class="refresh" href="javascript:void(0);" id="requester_refresh">Refresh</a> + | <input type="checkbox" id="requester_resolved"> + <label for="requester_resolved">Show resolved</label> </span> <div id="requester_table"></div> </div> diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js index 8ea54539b..c0ebc63ec 100644 --- a/extensions/MyDashboard/web/js/flags.js +++ b/extensions/MyDashboard/web/js/flags.js @@ -26,6 +26,8 @@ YUI({ var updateFlagTable = function (type) { if (!type) return; + var include_resolved = Y.one('#' + type + '_resolved').get('checked') ? 1 : 0; + counter = counter + 1; var callback = { @@ -47,13 +49,13 @@ YUI({ version: "1.1", method: "MyDashboard.run_flag_query", id: counter, - params: { type : type } + params: { type : type, include_resolved: include_resolved } }; var stringified = Y.JSON.stringify(json_object); Y.one('#' + type + '_count_refresh').addClass('bz_default_hidden'); - + dataTable[type].set('data', []); dataTable[type].render("#" + type + "_table"); dataTable[type].showMessage('loadingMessage'); @@ -69,14 +71,19 @@ YUI({ }; var bugLinkFormatter = function (o) { + var bug_closed = ""; + if (o.data.bug_status == 'RESOLVED' || o.data.bug_status == 'VERIFIED') { + bug_closed = "bz_closed"; + } return '<a href="show_bug.cgi?id=' + encodeURIComponent(o.value) + - '" target="_blank" ' + 'title="' + Y.Escape.html(o.data.bug_status) + ' - ' + - Y.Escape.html(o.data.bug_summary) + '">' + o.value + '</a>'; + '" target="_blank" ' + 'title="' + Y.Escape.html(o.data.bug_status) + ' - ' + + Y.Escape.html(o.data.bug_summary) + '" class="' + Y.Escape.html(bug_closed) + + '">' + o.value + '</a>'; }; - var createdFormatter = function (o) { + var updatedFormatter = function (o) { return '<span title="' + Y.Escape.html(o.value) + '">' + - Y.Escape.html(o.data.created_fancy) + '</span>'; + Y.Escape.html(o.data.updated_fancy) + '</span>'; }; var requesteeFormatter = function (o) { @@ -91,10 +98,10 @@ YUI({ columns: [ { key: "requester", label: "Requester", sortable: true }, { key: "type", label: "Flag", sortable: true }, - { key: "bug_id", label: "Bug", sortable: true, + { key: "bug_id", label: "Bug", sortable: true, formatter: bugLinkFormatter, allowHTML: true }, - { key: "created", label: "Created", sortable: true, - formatter: createdFormatter, allowHTML: true } + { key: "updated", label: "Updated", sortable: true, + formatter: updatedFormatter, allowHTML: true } ], strings: { emptyMessage: 'No flag data found.', @@ -112,7 +119,7 @@ YUI({ schema: { resultListLocator: "result.result.requestee", resultFields: ["requester", "type", "bug_id", "bug_status", - "bug_summary", "created", "created_fancy"] + "bug_summary", "updated", "updated_fancy"] } }); @@ -121,6 +128,9 @@ YUI({ Y.one('#requestee_refresh').on('click', function(e) { updateFlagTable('requestee'); }); + Y.one('#requestee_resolved').on('change', function(e) { + updateFlagTable('requestee'); + }); // Requester dataSource.requester = new Y.DataSource.IO({ source: 'jsonrpc.cgi' }); @@ -131,8 +141,8 @@ YUI({ { key:"type", label:"Flag", sortable:true }, { key:"bug_id", label:"Bug", sortable:true, formatter: bugLinkFormatter, allowHTML: true }, - { key: "created", label: "Created", sortable: true, - formatter: createdFormatter, allowHTML: true } + { key: "updated", label: "Updated", sortable: true, + formatter: updatedFormatter, allowHTML: true } ], strings: { emptyMessage: 'No flag data found.', @@ -150,11 +160,14 @@ YUI({ schema: { resultListLocator: "result.result.requester", resultFields: ["requestee", "type", "bug_id", "bug_status", - "bug_summary", "created", "created_fancy"] + "bug_summary", "updated", "updated_fancy"] } }); Y.one('#requester_refresh').on('click', function(e) { updateFlagTable('requester'); }); + Y.one('#requester_resolved').on('change', function(e) { + updateFlagTable('requester'); + }); }); |