summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fearn <jfearn@redhat.com>2022-08-11 10:27:34 +1000
committerJeff Fearn <jfearn@redhat.com>2022-08-11 10:27:34 +1000
commitd0c3a7c9b0f28a4b00027990f0c85092e229e4ab (patch)
tree194eeeba781546ad6a7ea0a20e2c45757ba650ca
parentRelease Version 5.0.4-rh73 (diff)
downloadbugzilla-d0c3a7c9b0f28a4b00027990f0c85092e229e4ab.tar.gz
bugzilla-d0c3a7c9b0f28a4b00027990f0c85092e229e4ab.tar.bz2
bugzilla-d0c3a7c9b0f28a4b00027990f0c85092e229e4ab.zip
Bug 1865757 - Enable DataTables searchPanes extension on bug lists
Add text to display how many rows are filtered. Fix pagination. Fix text overrides. Change-Id: I54206f2bb38c3dfa37bd9f5f26d7bf93868afa70
-rw-r--r--extensions/RedHat/web/js/redhat.js10
-rw-r--r--template/en/default/list/list.html.tmpl41
2 files changed, 33 insertions, 18 deletions
diff --git a/extensions/RedHat/web/js/redhat.js b/extensions/RedHat/web/js/redhat.js
index 9b7554e04..df1e69943 100644
--- a/extensions/RedHat/web/js/redhat.js
+++ b/extensions/RedHat/web/js/redhat.js
@@ -1431,13 +1431,17 @@ function filter_rows(json) {
if (selected.length === 0) return;
- var col = filterMap[this.s.index - 1];
- const field = the_search.include_fields[col];
+ const field = the_search.include_fields[this.s.index];
fdata = fdata.filter(function (row) {
return selected.filter(sp => sp.display == row[field]).length > 0;
});
});
- json['data'] = fdata;
+ if(fdata.length != json['data'].length){
+ json['numRecordsFiltered'] = json['data'].length - fdata.length;
+ json['data'] = fdata;
+ } else {
+ json['numRecordsFiltered'] = 0;
+ }
}
diff --git a/template/en/default/list/list.html.tmpl b/template/en/default/list/list.html.tmpl
index 5ecf6f21e..cbadaaf63 100644
--- a/template/en/default/list/list.html.tmpl
+++ b/template/en/default/list/list.html.tmpl
@@ -297,8 +297,14 @@ function update_table_info() {
if(selected_cache.length == 0){
output = $('<span class="select-info"><span class="select-item">No rows selected</span></span>');
}
-
$('.select-info').remove();
+
+ if( json['numRecordsFiltered'] > 0) {
+ var filter_text = $('<span>(' + json['numRecordsFiltered'] +
+ ' filtered)</span>');
+ output.prepend(filter_text);
+ }
+
$('.dataTables_info').append(output);
}
@@ -495,22 +501,26 @@ $.fn.dataTable.pipeline = function ( opts ) {
data_cache[drawStart] = { ...json};
filter_rows(json);
drawCallback( json );
- filter_rows(json);
- drawCallback( json );
mark_cached(requestLength);
},
+ "complete": function () {
+ json = { ...data_cache[drawStart]};
+ filter_rows(json);
+ update_table_info();
+ },
dataFilter: function(data){
var json = jQuery.parseJSON( data );
if(json.error) {
alertify.error(json.error.message);
return;
}
- //real_count += json.result.bugs.length;
+
json.recordsTotal = real_count;
json.recordsFiltered = real_count;
json.draw = test;
json.data = json.result.bugs;
json.searchPanes = json.result.searchPanes
+ json.numRecordsFiltered = 0;
return JSON.stringify( json ); // return JSON string
}
} );
@@ -632,9 +642,6 @@ $(document).ready(function() {
processing: true,
scroller: false,
//deferLoading: [%- num_matches FILTER none -%],
- "language": {
- "emptyTable": "[% terms.zeroSearchResults FILTER js FILTER html %]"
- },
"createdRow": function (row, data, dataIndex, cells) {
$(row).addClass(data.bug_classes)
},
@@ -914,12 +921,6 @@ $(document).ready(function() {
]
},
],
- language: {
- searchPanes: {
- //clearMessage: 'Obliterate Selections',
- collapse: {0: 'Filters', _: 'Filters Applied (%d)'}
- }
- },
select: {
info: false
},
@@ -961,7 +962,16 @@ $(document).ready(function() {
],
fixedHeader: true,
fnInitComplete: function (oSettings, json) {
- }
+ },
+ // have language near the end as plugins can override it
+ language: {
+ emptyTable: "[% terms.zeroSearchResults FILTER js FILTER html %]",
+ infoFiltered: "",
+ searchPanes: {
+ // clearMessage: 'Obliterate Selections',
+ collapse: {0: 'Filters', _: 'Filters Applied (%d)'}
+ },
+ },
});
// Update hidden field so it gets processed
table.on( 'select', function ( e, dt, type, indexes ) {
@@ -997,7 +1007,8 @@ $(document).ready(function() {
} );
table.on( 'page.dt', function () {
- var info = table.page.info();
+ var info = $('#bz_buglist').DataTable().page.info();
+// filter_rows(json);
update_table_info();
} );