summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fearn <jfearn@redhat.com>2022-07-29 13:43:34 +1000
committerJeff Fearn <jfearn@redhat.com>2022-07-29 13:43:34 +1000
commit0a8dcee0847b172a5210143f4214094ae728993a (patch)
tree42a1d1f4dabfd2fdc3451dc987927a6cadffb45a
parentBug 1865757 - Enable DataTables searchPanes extension on bug lists (diff)
downloadbugzilla-0a8dcee0847b172a5210143f4214094ae728993a.tar.gz
bugzilla-0a8dcee0847b172a5210143f4214094ae728993a.tar.bz2
bugzilla-0a8dcee0847b172a5210143f4214094ae728993a.zip
Bug 1865757 - Enable DataTables searchPanes extension on bug lists
Fix button display. Fix Collapse Most. Add parameter to toggle Bug.search returning searchPanes data. Change-Id: I528578cfcd22142c3420eea9902d5929cf138b36
-rw-r--r--Bugzilla/WebService/Bug.pm116
-rw-r--r--docs/en/rst/api/core/v1/bug.rst2
-rw-r--r--extensions/RedHat/web/js/redhat.js5
-rw-r--r--template/en/default/list/list.html.tmpl62
4 files changed, 97 insertions, 88 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 4630c1508..956988995 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -783,7 +783,6 @@ sub search {
my @bugs;
my @bug_ids = map { $_->[0] } @$data;
my $bug_groups = natatime(200, @bug_ids);
- my %searchPanes;
while (my @bug_batch = $bug_groups->()) {
my %bug_objects
@@ -816,72 +815,78 @@ sub search {
## REDHAT EXTENSION END 1347097
## REDHAT EXTENSION START 1865757
- ## BUGBUG make this optional?
- if (filter_wants $params, 'status') {
- my %status_counts;
- map { $status_counts{$_->{status}}++ } @bugs;
+ my $results = {
+ bugs => \@bugs,
+ total_matches => (0 + @{$search->bug_ids}),
+ limit => $match_params->{limit},
+ offset => $match_params->{offset} ? $match_params->{offset} : 0,
+ };
- my @stcs = map { {
- "label" => $_,
- "total" => $status_counts{$_},
- "value" => $_,
- "count" => $status_counts{$_}
- } } keys %status_counts;
+ if (defined $params->{'include_search_panes'}
+ && $params->{'include_search_panes'})
+ {
+ my %searchPanes;
- $searchPanes{options}{status} = \@stcs;
- }
+ if (filter_wants $params, 'status') {
+ my %status_counts;
+ map { $status_counts{$_->{status}}++ } @bugs;
- if (filter_wants $params, 'product') {
- my %prod_counts;
- map { $prod_counts{$_->{product}}++ } @bugs;
+ my @stcs = map { {
+ "label" => $_,
+ "total" => $status_counts{$_},
+ "value" => $_,
+ "count" => $status_counts{$_}
+ } } keys %status_counts;
- my @pcs = map { {
- "label" => $_,
- "total" => $prod_counts{$_},
- "value" => $_,
- "count" => $prod_counts{$_}
- } } keys %prod_counts;
+ $searchPanes{options}{status} = \@stcs;
+ }
- $searchPanes{options}{product} = \@pcs;
- }
+ if (filter_wants $params, 'product') {
+ my %prod_counts;
+ map { $prod_counts{$_->{product}}++ } @bugs;
- if (filter_wants $params, 'assigned_to') {
- my %assignee_counts;
- map { $assignee_counts{$_->{assigned_to}}++ } @bugs;
+ my @pcs = map { {
+ "label" => $_,
+ "total" => $prod_counts{$_},
+ "value" => $_,
+ "count" => $prod_counts{$_}
+ } } keys %prod_counts;
- my @assigned_to = map { {
- "label" => $_,
- "total" => $assignee_counts{$_},
- "value" => $_,
- "count" => $assignee_counts{$_}
- } } keys %assignee_counts;
+ $searchPanes{options}{product} = \@pcs;
+ }
- $searchPanes{options}{assigned_to} = \@assigned_to;
- }
+ if (filter_wants $params, 'assigned_to') {
+ my %assignee_counts;
+ map { $assignee_counts{$_->{assigned_to}}++ } @bugs;
- if (filter_wants $params, 'component') {
- my %comp_counts;
- map { $comp_counts{join(',', @{$_->{component}})}++ } @bugs;
+ my @assigned_to = map { {
+ "label" => $_,
+ "total" => $assignee_counts{$_},
+ "value" => $_,
+ "count" => $assignee_counts{$_}
+ } } keys %assignee_counts;
+
+ $searchPanes{options}{assigned_to} = \@assigned_to;
+ }
+
+ if (filter_wants $params, 'component') {
+ my %comp_counts;
+ map { $comp_counts{join(',', @{$_->{component}})}++ } @bugs;
- my @comps = map { {
- "label" => $_,
- "total" => $comp_counts{$_},
- "value" => $_,
- "count" => $comp_counts{$_}
- } } keys %comp_counts;
+ my @comps = map { {
+ "label" => $_,
+ "total" => $comp_counts{$_},
+ "value" => $_,
+ "count" => $comp_counts{$_}
+ } } keys %comp_counts;
- $searchPanes{options}{component} = \@comps;
+ $searchPanes{options}{component} = \@comps;
+ }
+ $results->{searchPanes} = \%searchPanes;
}
## REDHAT EXTENSION END 1865757
-
- return {
- bugs => \@bugs,
- total_matches => (0 + @{$search->bug_ids}),
- limit => $match_params->{limit},
- offset => $match_params->{offset} ? $match_params->{offset} : 0,
- searchPanes => \%searchPanes,
- };
+ return $results;
}
## REDHAT EXTENSION BEGIN 812855 1001350 1018020
@@ -4065,6 +4070,11 @@ include bugs where it is and isn't set this will mean that different bugs will
have different field sets. If this parameter is set then custom fields will be
present in all records. This is a Red Hat Extension.
+=item C<include_search_panes>
+
+C<bool> Include the DataTables searchPane information in the response. This is a
+Red Hat Extension.
+
=item C<assigned_to>
C<string> The login name of a user that a bug is assigned to.
diff --git a/docs/en/rst/api/core/v1/bug.rst b/docs/en/rst/api/core/v1/bug.rst
index daebd96e9..08091fe4f 100644
--- a/docs/en/rst/api/core/v1/bug.rst
+++ b/docs/en/rst/api/core/v1/bug.rst
@@ -521,6 +521,8 @@ always_set_cfs bool Normally when a custom field isn't visible on a bug
different bugs will have different field sets. If this
parameter is set then custom fields will be present in
all records. This is a Red Hat Extension.
+include_search_panes bool Include the DataTables searchPane information in the
+ response. This is a Red Hat Extension.
================ ======== =====================================================
**Response**
diff --git a/extensions/RedHat/web/js/redhat.js b/extensions/RedHat/web/js/redhat.js
index ffcc14a07..ddb8b836a 100644
--- a/extensions/RedHat/web/js/redhat.js
+++ b/extensions/RedHat/web/js/redhat.js
@@ -1369,7 +1369,7 @@ function update_bug_list_fixed(table, level) {
function toggle_row_groups(collapse, most) {
if (collapse) {
$('.dtrg-level-1').addClass('group_collapsed');
- if (most) {
+ if (most && $('.dtrg-level-1').length >= 1) {
$('.dtrg-level-0').removeClass('group_collapsed');
$('#bz_buglist tr').not('.dtrg-level-0, .dtrg-level-1').addClass('dtrg-level-1-hide');
@@ -1398,9 +1398,6 @@ function filter_rows(json) {
if (selected.length === 0) return;
- //var col = $(this).attr('id');
- //col = col.replace('DataTables_Table_', '');
- //col = filterMap[col];
var col = filterMap[this.s.index - 1];
const field = the_search.include_fields[col];
diff --git a/template/en/default/list/list.html.tmpl b/template/en/default/list/list.html.tmpl
index fb3e67f67..5ecf6f21e 100644
--- a/template/en/default/list/list.html.tmpl
+++ b/template/en/default/list/list.html.tmpl
@@ -493,8 +493,6 @@ $.fn.dataTable.pipeline = function ( opts ) {
"success": function ( json ) {
cacheLastJson = $.extend(true, {}, json);
data_cache[drawStart] = { ...json};
- //$('#bz_buglist').DataTable().searchPanes.rebuildPane();
- //$('#bz_buglist').DataTable().searchPanes.clearSelections();
filter_rows(json);
drawCallback( json );
filter_rows(json);
@@ -502,7 +500,6 @@ $.fn.dataTable.pipeline = function ( opts ) {
mark_cached(requestLength);
},
dataFilter: function(data){
-
var json = jQuery.parseJSON( data );
if(json.error) {
alertify.error(json.error.message);
@@ -661,6 +658,7 @@ $(document).ready(function() {
the_search.offset = d.start;
d.params = [the_search];
d.params[0].always_set_cfs = 1;
+ d.params[0].include_search_panes = 1;
var str = '';
// catch users reversing fixed column
@@ -714,34 +712,6 @@ $(document).ready(function() {
[%- END %]
dom: '<"top"ilB>rtip',
buttons: [
- [% IF user.id %]
- {
- extend: 'selected',
- text: 'Edit',
- action: function ( e, dt, button, config ) {
- bulk_edit_bugs(selected_cache.length, selected_cache);
- }
- },
- [% END %]
- {
- extend: 'collection',
- text: 'Export',
- buttons: [
- 'copy',
- 'csv',
- 'excel',
- 'pdf',
- {
- extend: 'print',
- text: 'Print all (not just selected)',
- exportOptions: {
- modifier: {
- selected: null
- }
- }
- }
- ]
- },
{
extend: 'colvis',
columns: 'th:nth-child(n+2)'
@@ -863,6 +833,7 @@ $(document).ready(function() {
{
extend: 'savedStates',
text: 'Load State',
+ className: 'noexport',
config: {
splitSecondaries: [
'updateState',
@@ -913,6 +884,35 @@ $(document).ready(function() {
}
]
},
+ [% IF user.id %]
+ {
+ extend: 'selected',
+ text: 'Edit',
+ action: function ( e, dt, button, config ) {
+ bulk_edit_bugs(selected_cache.length, selected_cache);
+ }
+ },
+ [% END %]
+ // BUGBUG if this is before savedStates the buttons are duplicated in it ...
+ {
+ extend: 'collection',
+ text: 'Export',
+ buttons: [
+ 'copy',
+ 'csv',
+ 'excel',
+ 'pdf',
+ {
+ extend: 'print',
+ text: 'Print all (not just selected)',
+ exportOptions: {
+ modifier: {
+ selected: null
+ }
+ }
+ }
+ ]
+ },
],
language: {
searchPanes: {