mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
wip: allow to deactivate a conditional rule from list
This commit is contained in:
parent
a2d04b9ad4
commit
805c09e34e
1 changed files with 8 additions and 2 deletions
|
@ -6,6 +6,7 @@ class Rule {
|
||||||
constructor(map, condition = '', options = {}) {
|
constructor(map, condition = '', options = {}) {
|
||||||
this.map = map
|
this.map = map
|
||||||
this.condition = condition
|
this.condition = condition
|
||||||
|
this.active = true
|
||||||
this.parse()
|
this.parse()
|
||||||
this.options = options
|
this.options = options
|
||||||
let isDirty = false
|
let isDirty = false
|
||||||
|
@ -41,7 +42,7 @@ class Rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
match(props) {
|
match(props) {
|
||||||
if (!this.operator) return false
|
if (!this.operator || !this.active) return false
|
||||||
return this.operator(this.expected, props[this.key])
|
return this.operator(this.expected, props[this.key])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ class Rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderToolbox(row) {
|
renderToolbox(row) {
|
||||||
|
row.classList.toggle('off', !this.active)
|
||||||
const toggle = DomUtil.createButtonIcon(
|
const toggle = DomUtil.createButtonIcon(
|
||||||
row,
|
row,
|
||||||
'icon-eye',
|
'icon-eye',
|
||||||
|
@ -113,7 +115,11 @@ class Rule {
|
||||||
DomUtil.add('span', '', row, this.condition || translate('empty rule'))
|
DomUtil.add('span', '', row, this.condition || translate('empty rule'))
|
||||||
DomUtil.createIcon(row, 'icon-drag', translate('Drag to reorder'))
|
DomUtil.createIcon(row, 'icon-drag', translate('Drag to reorder'))
|
||||||
row.dataset.id = stamp(this)
|
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)
|
||||||
|
this.map.render(['rules'])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_delete() {
|
_delete() {
|
||||||
|
|
Loading…
Reference in a new issue