From 05ea45acd293ee98ea329d8c89192a7b28e20d55 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 29 Apr 2024 15:57:41 +0200 Subject: [PATCH] wip: use getter/setter for Rule dynamic properties --- umap/static/umap/js/modules/rules.js | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/umap/static/umap/js/modules/rules.js b/umap/static/umap/js/modules/rules.js index f1d5d349..96439622 100644 --- a/umap/static/umap/js/modules/rules.js +++ b/umap/static/umap/js/modules/rules.js @@ -3,32 +3,32 @@ import * as Utils from './utils.js' import { translate } from './i18n.js' class Rule { + #condition = null + + get condition() { + return this.#condition + } + + set condition(value) { + this.#condition = value + this.parse() + } + + #isDirty = false + + get isDirty() { + return this.#isDirty + } + + set isDirty(status) { + this.#isDirty = status + if (status) this.map.isDirty = status + } + constructor(map, condition = '', options = {}) { this.map = map this.active = true this.options = options - let isDirty = false - Object.defineProperty(this, 'isDirty', { - get: () => { - return isDirty - }, - set: (status) => { - isDirty = status - if (status) { - this.map.isDirty = status - } - }, - }) - let _condition - Object.defineProperty(this, 'condition', { - get: () => { - return _condition - }, - set: (value) => { - _condition = value - this.parse() - }, - }) this.condition = condition }