UNPKG

@aurigma/design-atoms-model

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

83 lines 3.42 kB
import { EventObject } from "../../EventObject"; import { ItemToolbarPermissions } from "./ItemToolbarPermissions"; import { equals } from "../../Utils/Utils"; export class ItemPermissions { get allowZOrderChange() { return this._allowZOrderChange; } set allowZOrderChange(value) { if (this._allowZOrderChange === value) return; this._allowZOrderChange = value; this.propertyChanged.notify(); } get allowOpacityChange() { return this._allowOpacityChange; } set allowOpacityChange(value) { if (this._allowOpacityChange === value) return; this._allowOpacityChange = value; this.propertyChanged.notify(); } get allowRemoveOnLayoutChange() { return this._allowRemoveOnLayoutChange; } set allowRemoveOnLayoutChange(value) { if (this._allowRemoveOnLayoutChange === value) return; this._allowRemoveOnLayoutChange = value; this.propertyChanged.notify(); } get itemToolbarPermissions() { return this._itemToolbarPermissions; } set itemToolbarPermissions(value) { if (equals(this, value)) return; if (this.itemToolbarPermissions != null && this.itemToolbarPermissions.propertyChanged != null) { this.itemToolbarPermissions.propertyChanged.remove(this._firePropertyChanged); } this._itemToolbarPermissions = value; if (this.itemToolbarPermissions.propertyChanged != null) { this.itemToolbarPermissions.propertyChanged.add(this._firePropertyChanged); } this.propertyChanged.fire(); } constructor(defaultValue) { this._allowZOrderChange = true; this._allowOpacityChange = true; this._allowRemoveOnLayoutChange = true; this._firePropertyChanged = () => this.propertyChanged.fire(); this.propertyChanged = new EventObject(); if (defaultValue == null) defaultValue = true; this.allowZOrderChange = defaultValue; this.allowOpacityChange = defaultValue; this.allowRemoveOnLayoutChange = defaultValue; this.itemToolbarPermissions = new ItemToolbarPermissions(defaultValue); } getSimplifiedObject() { const result = {}; result["allowZOrderChange"] = this.allowZOrderChange; result["allowOpacityChange"] = this.allowOpacityChange; result["allowRemoveOnLayoutChange"] = this.allowRemoveOnLayoutChange; result["itemToolbarPermissions"] = this.itemToolbarPermissions.getSimplifiedObject(); return result; } clone() { const clone = new ItemPermissions(); clone.allowZOrderChange = this.allowZOrderChange; clone.allowOpacityChange = this.allowOpacityChange; clone.allowRemoveOnLayoutChange = this.allowRemoveOnLayoutChange; clone.itemToolbarPermissions = this.itemToolbarPermissions.clone(); return clone; } equals(p) { return this.allowZOrderChange === p.allowZOrderChange && this.allowOpacityChange === p.allowOpacityChange && this.allowRemoveOnLayoutChange === p.allowRemoveOnLayoutChange && equals(this.itemToolbarPermissions, p.itemToolbarPermissions); } } //# sourceMappingURL=ItemPermissions.js.map