From 1cfa8033a559209753ab565dcf4524d9b50f5b6e Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sun, 7 Jun 2026 09:14:20 +0200 Subject: [PATCH] GRID --- dist/tryton-sao.js | 50 +++++++++++++++++++++++++++++++++++++++------- tryton-sao.js | 50 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 86 insertions(+), 14 deletions(-) diff --git a/dist/tryton-sao.js b/dist/tryton-sao.js index 67c9131..9c2a25f 100644 --- a/dist/tryton-sao.js +++ b/dist/tryton-sao.js @@ -22212,9 +22212,14 @@ function eval_pyson(value){ this.clearButton.type = 'button'; this.clearButton.className = 'btn btn-default btn-xs'; this.clearButton.textContent = 'Clear'; + this.applySearchButton = document.createElement('button'); + this.applySearchButton.type = 'button'; + this.applySearchButton.className = 'btn btn-primary btn-xs'; + this.applySearchButton.textContent = 'OK'; actions.appendChild(this.allButton); actions.appendChild(this.noneButton); actions.appendChild(this.clearButton); + actions.appendChild(this.applySearchButton); this.gui.appendChild(actions); this.list = document.createElement('div'); @@ -22224,6 +22229,15 @@ function eval_pyson(value){ this._renderOptions(); this.search.addEventListener('input', () => this._applySearch()); + this.search.addEventListener('keydown', event => { + if (event.key != 'Enter') { + return; + } + event.preventDefault(); + this._selectSearchMatches('search-enter'); + params.filterChangedCallback(); + this._closePopup(); + }); this.noneButton.addEventListener('pointerdown', event => { if (event.isTrusted) { this._noneButtonUserIntent = true; @@ -22304,11 +22318,17 @@ function eval_pyson(value){ this._notifySelectionChanged('clear-button'); params.filterChangedCallback(); }); + this.applySearchButton.addEventListener('click', () => { + this._selectSearchMatches('search-ok-button'); + params.filterChangedCallback(); + this._closePopup(); + }); }; Sao.View.AGGridValueSetFilter.prototype.getGui = function() { return this.gui; }; - Sao.View.AGGridValueSetFilter.prototype.afterGuiAttached = function() { + Sao.View.AGGridValueSetFilter.prototype.afterGuiAttached = function(params) { + this.hidePopup = params && params.hidePopup || null; this._refreshValuesFromGrid(); this._trace('after-gui-attached', { selected: Array.from(this.selected).sort(), @@ -22366,6 +22386,28 @@ function eval_pyson(value){ '' : 'none'; }); }; + Sao.View.AGGridValueSetFilter.prototype._getSearchMatchingValues = function() { + var query = (this.search.value || '').toLowerCase(); + if (!query) { + return this.values.slice(); + } + return this.values.filter(value => + String(value).toLowerCase().indexOf(query) >= 0); + }; + Sao.View.AGGridValueSetFilter.prototype._selectSearchMatches = function(source) { + this.selected = new Set(this._getSearchMatchingValues()); + this._syncCheckboxes(); + this._trace(source || 'search-apply', { + query: this.search && this.search.value || '', + selected: Array.from(this.selected).sort(), + }); + this._notifySelectionChanged(source || 'search-apply'); + }; + Sao.View.AGGridValueSetFilter.prototype._closePopup = function() { + if (this.hidePopup) { + this.hidePopup(); + } + }; Sao.View.AGGridValueSetFilter.prototype.destroy = function() {}; Sao.View.AGGridValueSetFilter.prototype._notifySelectionChanged = function(source) { if (!this.onSelectionChanged || !this.colId) { @@ -26494,12 +26536,6 @@ function eval_pyson(value){ changed = true; return; } - var has_selected_value = Array.from(filters[col_id].selected || []) - .some(value => all.has(value)); - if (!has_selected_value) { - delete filters[col_id]; - changed = true; - } }); return changed; }, diff --git a/tryton-sao.js b/tryton-sao.js index 67c9131..9c2a25f 100644 --- a/tryton-sao.js +++ b/tryton-sao.js @@ -22212,9 +22212,14 @@ function eval_pyson(value){ this.clearButton.type = 'button'; this.clearButton.className = 'btn btn-default btn-xs'; this.clearButton.textContent = 'Clear'; + this.applySearchButton = document.createElement('button'); + this.applySearchButton.type = 'button'; + this.applySearchButton.className = 'btn btn-primary btn-xs'; + this.applySearchButton.textContent = 'OK'; actions.appendChild(this.allButton); actions.appendChild(this.noneButton); actions.appendChild(this.clearButton); + actions.appendChild(this.applySearchButton); this.gui.appendChild(actions); this.list = document.createElement('div'); @@ -22224,6 +22229,15 @@ function eval_pyson(value){ this._renderOptions(); this.search.addEventListener('input', () => this._applySearch()); + this.search.addEventListener('keydown', event => { + if (event.key != 'Enter') { + return; + } + event.preventDefault(); + this._selectSearchMatches('search-enter'); + params.filterChangedCallback(); + this._closePopup(); + }); this.noneButton.addEventListener('pointerdown', event => { if (event.isTrusted) { this._noneButtonUserIntent = true; @@ -22304,11 +22318,17 @@ function eval_pyson(value){ this._notifySelectionChanged('clear-button'); params.filterChangedCallback(); }); + this.applySearchButton.addEventListener('click', () => { + this._selectSearchMatches('search-ok-button'); + params.filterChangedCallback(); + this._closePopup(); + }); }; Sao.View.AGGridValueSetFilter.prototype.getGui = function() { return this.gui; }; - Sao.View.AGGridValueSetFilter.prototype.afterGuiAttached = function() { + Sao.View.AGGridValueSetFilter.prototype.afterGuiAttached = function(params) { + this.hidePopup = params && params.hidePopup || null; this._refreshValuesFromGrid(); this._trace('after-gui-attached', { selected: Array.from(this.selected).sort(), @@ -22366,6 +22386,28 @@ function eval_pyson(value){ '' : 'none'; }); }; + Sao.View.AGGridValueSetFilter.prototype._getSearchMatchingValues = function() { + var query = (this.search.value || '').toLowerCase(); + if (!query) { + return this.values.slice(); + } + return this.values.filter(value => + String(value).toLowerCase().indexOf(query) >= 0); + }; + Sao.View.AGGridValueSetFilter.prototype._selectSearchMatches = function(source) { + this.selected = new Set(this._getSearchMatchingValues()); + this._syncCheckboxes(); + this._trace(source || 'search-apply', { + query: this.search && this.search.value || '', + selected: Array.from(this.selected).sort(), + }); + this._notifySelectionChanged(source || 'search-apply'); + }; + Sao.View.AGGridValueSetFilter.prototype._closePopup = function() { + if (this.hidePopup) { + this.hidePopup(); + } + }; Sao.View.AGGridValueSetFilter.prototype.destroy = function() {}; Sao.View.AGGridValueSetFilter.prototype._notifySelectionChanged = function(source) { if (!this.onSelectionChanged || !this.colId) { @@ -26494,12 +26536,6 @@ function eval_pyson(value){ changed = true; return; } - var has_selected_value = Array.from(filters[col_id].selected || []) - .some(value => all.has(value)); - if (!has_selected_value) { - delete filters[col_id]; - changed = true; - } }); return changed; },