Fix select all did not respect some filters

Certain sequence of applying filters could trigger long task & get all IDs, which failed.
This commit is contained in:
nathan 2023-03-16 11:20:45 -06:00
parent de9c1f5c48
commit 7c3aaba861
2 changed files with 69 additions and 61 deletions

View File

@ -668,15 +668,17 @@ export class et2_dataview_selectionManager
_query_ranges(queryRanges)
{
var that = this;
var record_count = 0;
var range_index = 0;
var range_count = queryRanges.length;
var cont = true;
var fetchPromise = new Promise(function(resolve)
let that = this;
let record_count = 0;
let range_index = 0;
let range_count = queryRanges.length;
let cont = true;
let fetchResolver;
let fetchPromise = new Promise(function(resolve)
{
resolve();
fetchResolver = resolve;
});
let fetchList = [fetchPromise];
// Found after dialog loads
var progressbar;
@ -696,27 +698,27 @@ export class et2_dataview_selectionManager
}],
width: 300
});
(this._context._widget.getDOMNode() || document.body).appendChild(dialog);
(this._context._widget.getDOMNode() || document.body).append(dialog);
dialog.updateComplete.then(() =>
{
dialog.template.DOMContainer.addEventListener('load', function()
dialog.template.DOMContainer.addEventListener('load', () =>
{
// Get access to template widgets
progressbar = dialog.template.widgetContainer.getWidgetById('progressbar');
});
});
let rangePromise = fetchPromise;
for(var i = 0; i < queryRanges.length; i++)
{
if(record_count + (queryRanges[i].bottom - queryRanges[i].top + 1) > that.MAX_SELECTION)
if(record_count + (queryRanges[i].bottom - queryRanges[i].top + 1) > et2_dataview_selectionManager.MAX_SELECTION)
{
egw.message(egw.lang('Too many rows selected.<br />Select all, or less than %1 rows', that.MAX_SELECTION));
egw.message(egw.lang('Too many rows selected.<br />Select all, or less than %1 rows', et2_dataview_selectionManager.MAX_SELECTION));
break;
}
else
{
record_count += (queryRanges[i].bottom - queryRanges[i].top + 1);
fetchPromise = fetchPromise.then((function()
// We want to chain these one after the other, not fire them all right away
rangePromise = rangePromise.then((function()
{
// Check for abort
if(!cont)
@ -745,12 +747,18 @@ export class et2_dataview_selectionManager
}, that);
}.bind(this));
}).bind(queryRanges[i]));
fetchList.push(rangePromise);
}
}
fetchPromise.finally(function() {
// Start the first fetch
fetchResolver();
Promise.all(fetchList).finally(function()
{
dialog.close();
});
}
})
});
}
}

View File

@ -12,8 +12,8 @@
</et2-vbox>
</et2-hbox>
<styles>
.long_task .ui-dialog-content {
width: 90%;
#long_task > div {
width: 100%;
}
.long_task .log {
max-height: 10em;