no results state updates

This commit is contained in:
Giga Chubinidze 2023-01-13 14:49:58 +04:00
parent 5ed3a22539
commit f7fe30fdae

View file

@ -459,21 +459,12 @@ var ExperimnetTable = {
this.filterDropdown.on('filter:apply', () => { this.filterDropdown.on('filter:apply', () => {
$.each(this.filters, (_i, filter) => { $.each(this.filters, (_i, filter) => {
this.activeFilters[filter.name] = filter.apply($experimentFilter); 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( filterDropdown.toggleFilterMark(
this.filterDropdown, this.filterDropdown,
this.filters.some((filter) => { this.filters.some((filter) => {
@ -507,6 +498,8 @@ var ExperimnetTable = {
$(this.table).find('.table-row').remove(); $(this.table).find('.table-row').remove();
this.appendRows(result.data); this.appendRows(result.data);
this.initDueDatePicker(result.data); this.initDueDatePicker(result.data);
this.handleNoResults();
InfiniteScroll.init(this.table, { InfiniteScroll.init(this.table, {
url: dataUrl, url: dataUrl,
eventTarget: window, eventTarget: window,
@ -536,6 +529,15 @@ var ExperimnetTable = {
if (this.provisioningMyModulesCount > 0) this.pollProvisioningStatuses(provisioningStatusUrls); 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) { pollProvisioningStatuses: function(provisioningStatusUrls) {
let remainingUrls = []; let remainingUrls = [];