Merge pull request #4818 from G-Chubinidze/gc_SCI_7651

no results state updates [SCI-7651]
This commit is contained in:
artoscinote 2023-01-13 11:58:26 +01:00 committed by GitHub
commit aceedd0a14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -487,20 +487,11 @@ var ExperimnetTable = {
this.filterDropdown.on('filter:apply', () => {
$.each(this.filters, (_i, filter) => {
this.activeFilters[filter.name] = filter.apply($experimentFilter);
// Prompt empty state when theres no filtered results
let values = Object.values(this.activeFilters);
let anyFilter = values.every(value => /^\s+$/.test(value) || value === null || value === undefined || value?.length === 0);
setTimeout(() => {
var tableRowLength = document.getElementsByClassName('table-row').length;
var emptyState = document.getElementById('tasksNoResultsContainer');
if (tableRowLength === 0 && !anyFilter) {
emptyState.style.display = 'block';
} else {
emptyState.style.display = 'none';
}
}, 250)
});
// filters are active if they have any non-empty value
let filtersEmpty = Object.values(this.activeFilters).every(value => /^\s+$/.test(value) || value === null || value === undefined || value && value.length === 0);
this.filtersActive = !filtersEmpty;
filterDropdown.toggleFilterMark(
this.filterDropdown,
@ -542,6 +533,8 @@ var ExperimnetTable = {
$(this.table).find('.table-row-placeholder, .table-row-placeholder-divider').remove();
this.appendRows(result.data);
this.initDueDatePicker(result.data);
this.handleNoResults();
InfiniteScroll.init(this.table, {
url: dataUrl,
eventTarget: window,
@ -572,6 +565,15 @@ var ExperimnetTable = {
if (this.provisioningMyModulesCount > 0) this.pollProvisioningStatuses(provisioningStatusUrls);
},
handleNoResults: function() {
let tableRowLength = document.getElementsByClassName('table-row').length;
let noResultsContainer = document.getElementById('tasksNoResultsContainer');
if (this.filtersActive && tableRowLength === 0) {
noResultsContainer.style.display = 'block';
} else {
noResultsContainer.style.display = 'none';
}
},
pollProvisioningStatuses: function(provisioningStatusUrls) {
let remainingUrls = [];