Skip to content

Commit

Permalink
wip: allow to deactivate a conditional rule from list
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Apr 26, 2024
1 parent 976685a commit fc38119
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions umap/static/umap/js/modules/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
}

Expand Down Expand Up @@ -84,6 +85,7 @@ class Rule {
}

renderToolbox(row) {
row.classList.toggle('off', !this.active)
const toggle = DomUtil.createButtonIcon(
row,
'icon-eye',
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit fc38119

Please sign in to comment.