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.

44 lines 1.69 kB
import { ModelComponent } from "../ModelComponent"; import { NotImplementedException } from "../../Exception"; import { isString } from "../../Utils/Utils"; export class BaseItem extends ModelComponent { constructor() { super(...arguments); this.type = BaseItem.type; } get parentContainer() { return this._parentContainer; } set parentContainer(value) { this._parentContainer = value; this._onContainerChanged(); } _onContainerChanged() { } _copy(source, destination, generateNewIds, appropriateParentContainer) { super._copy(source, destination, generateNewIds); if (appropriateParentContainer) destination.parentContainer = source.parentContainer; } clone(generateNewIds = false, appropriateParentContainer = false) { if (this.type !== BaseItem.type) throw new NotImplementedException(`.clone() method must be overridden in ${this.type} class`); const item = new BaseItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; } copyTo(destination) { this._copy(this, destination, true, true); } update(item) { this._copy(item, this, true, false); } getSimplifiedObject(omitProperties) { if (!Array.isArray(omitProperties) && !isString(omitProperties)) omitProperties = []; var simplified = super.getSimplifiedObject(["parentContainer"].concat(omitProperties)); simplified["$type"] = this.type; return simplified; } } BaseItem.type = "base"; //# sourceMappingURL=BaseItem.js.map