JS - Add support for display property

- in annotation_layer, move common properties treatment in a common method instead having duplicated code in each widget.
This commit is contained in:
Calixte Denizet 2021-05-03 18:03:16 +02:00
parent afb8c4fd25
commit af125cd299
6 changed files with 197 additions and 141 deletions

View file

@ -14,6 +14,13 @@
*/
class ProxyHandler {
constructor() {
// Don't dispatch an event for those properties.
// - delay: allow to delay field redraw until delay is set to false.
// Likely it's useless to implement that stuff.
this.nosend = new Set(["delay"]);
}
get(obj, prop) {
// script may add some properties to the object
if (prop in obj._expandos) {
@ -49,7 +56,12 @@ class ProxyHandler {
if (typeof prop === "string" && !prop.startsWith("_") && prop in obj) {
const old = obj[prop];
obj[prop] = value;
if (obj._send && obj._id !== null && typeof old !== "function") {
if (
!this.nosend.has(prop) &&
obj._send &&
obj._id !== null &&
typeof old !== "function"
) {
const data = { id: obj._id };
data[prop] = obj[prop];