From c1351b0dcb5da51aba272567643060d5eab3a4be Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Thu, 4 Jul 2024 13:33:54 +0200 Subject: [PATCH] Introduce event `selection-start` and `selection-end` * `load-selection` is renamed to `selection-start` - `selection-start` is triggered only once, when a new selection starts - `selection-end` is triggered, when user stop selecting Remove superfluos params of trigger method --- asset/js/widget/ActionList.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/asset/js/widget/ActionList.js b/asset/js/widget/ActionList.js index 1ca1051d..c4ee952e 100644 --- a/asset/js/widget/ActionList.js +++ b/asset/js/widget/ActionList.js @@ -120,7 +120,7 @@ define(["../notjQuery"], function (notjQuery) { if (activeItems.length === 1 && toActiveItems.length === 0 ) { - notjQuery(this.list).trigger('all-deselected', {target: target, actionList: this}); + notjQuery(this.list).trigger('all-deselected'); this.clearSelection(toDeactivateItems); this.addSelectionCountToFooter(); @@ -443,16 +443,17 @@ define(["../notjQuery"], function (notjQuery) { return; } + if (this.lastTimeoutId === null) { // trigger once, when just started selecting list items + notjQuery(this.list).trigger('selection-start'); + } + clearTimeout(this.lastTimeoutId); this.lastTimeoutId = setTimeout(() => { this.lastTimeoutId = null; // TODO: maybe we need a property to know if a req is in process - notjQuery(this.list).trigger( - 'load-selection', - {url: url, firstActiveItem: activeItems[0]} - ); + notjQuery(this.list).trigger('selection-end', {url: url}); }, 250); }