From fc381193688ea594186d3ddef272fb3bbeb4fdf6 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 26 Apr 2024 10:57:42 +0200 Subject: [PATCH] wip: allow to deactivate a conditional rule from list --- umap/static/umap/js/modules/rules.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/modules/rules.js b/umap/static/umap/js/modules/rules.js index 59e579518..22467da7d 100644 --- a/umap/static/umap/js/modules/rules.js +++ b/umap/static/umap/js/modules/rules.js @@ -6,6 +6,7 @@ class Rule { constructor(map, condition = '', options = {}) { this.map = map this.condition = condition + this.active = true this.parse() this.options = options let isDirty = false @@ -41,7 +42,7 @@ class Rule { } match(props) { - if (!this.operator) return false + if (!this.operator || !this.active) return false return this.operator(this.expected, props[this.key]) } @@ -84,6 +85,7 @@ class Rule { } renderToolbox(row) { + row.classList.toggle('off', !this.active) const toggle = DomUtil.createButtonIcon( row, 'icon-eye', @@ -113,7 +115,10 @@ class Rule { DomUtil.add('span', '', row, this.condition || translate('empty rule')) DomUtil.createIcon(row, 'icon-drag', translate('Drag to reorder')) row.dataset.id = stamp(this) - //L.DomEvent.on(toggle, 'click', this.toggle, this) + DomEvent.on(toggle, 'click', () => { + this.active = !this.active + row.classList.toggle('off', !this.active) + }) } _delete() {