Etemplate: Fix flipping between 2 nextmatch filter values stopped updating results after 2 changes

This commit is contained in:
nathangray 2020-10-19 13:17:09 -06:00
parent ce05572461
commit d1955419ee
2 changed files with 30 additions and 15 deletions

View File

@ -2826,21 +2826,28 @@ var et2_nextmatch_header_bar = /** @class */ (function (_super) {
var change = function (_node) { var change = function (_node) {
// Call previously set change function // Call previously set change function
var result = widget_change.call(_widget, _node, header.nextmatch); var result = widget_change.call(_widget, _node, header.nextmatch);
// Update filters, if we're not already doing so // Find current value in activeFilters
if ((result || typeof result === 'undefined') && _widget.isDirty() && !header.update_in_progress) { var entry = header.nextmatch.activeFilters;
// Update dirty var path = _widget.getArrayMgr('content').explodeKey(_widget.id);
_widget._oldValue = _widget.getValue(); var i = 0;
if (path.length > 0) {
for (; i < path.length; i++) {
entry = entry[path[i]];
}
}
// Update filters, if the value is different and we're not already doing so
if ((result || typeof result === 'undefined') && entry != _widget.getValue() && !header.update_in_progress) {
// Widget will not have an entry in getValues() because nulls // Widget will not have an entry in getValues() because nulls
// are not returned, we remove it from activeFilters // are not returned, we remove it from activeFilters
if (_widget._oldValue == null) { if (_widget._oldValue == null) {
var path = _widget.getArrayMgr('content').explodeKey(_widget.id); var path_1 = _widget.getArrayMgr('content').explodeKey(_widget.id);
if (path.length > 0) { if (path_1.length > 0) {
var entry = header.nextmatch.activeFilters; var entry_1 = header.nextmatch.activeFilters;
var i = 0; var i_1 = 0;
for (; i < path.length - 1; i++) { for (; i_1 < path_1.length - 1; i_1++) {
entry = entry[path[i]]; entry_1 = entry_1[path_1[i_1]];
} }
delete entry[path[i]]; delete entry_1[path_1[i_1]];
} }
header.nextmatch.applyFilters(header.nextmatch.activeFilters); header.nextmatch.applyFilters(header.nextmatch.activeFilters);
} }

View File

@ -3610,11 +3610,19 @@ class et2_nextmatch_header_bar extends et2_DOMWidget implements et2_INextmatchHe
// Call previously set change function // Call previously set change function
const result = widget_change.call(_widget, _node, header.nextmatch); const result = widget_change.call(_widget, _node, header.nextmatch);
// Update filters, if we're not already doing so // Find current value in activeFilters
if ((result || typeof result === 'undefined') && _widget.isDirty() && !header.update_in_progress) { let entry = header.nextmatch.activeFilters;
// Update dirty const path = _widget.getArrayMgr('content').explodeKey(_widget.id);
_widget._oldValue = _widget.getValue(); let i = 0;
if (path.length > 0) {
for (; i < path.length; i++) {
entry = entry[path[i]];
}
}
// Update filters, if the value is different and we're not already doing so
if ((result || typeof result === 'undefined') && entry != _widget.getValue() && !header.update_in_progress)
{
// Widget will not have an entry in getValues() because nulls // Widget will not have an entry in getValues() because nulls
// are not returned, we remove it from activeFilters // are not returned, we remove it from activeFilters
if (_widget._oldValue == null) { if (_widget._oldValue == null) {