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.

67 lines 2.99 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { ModelComponent } from "../ModelComponent"; import * as _ from "underscore"; import { NotImplementedException } from "../../Exception"; var BaseItem = /** @class */ (function (_super) { __extends(BaseItem, _super); function BaseItem() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.type = BaseItem.type; return _this; } Object.defineProperty(BaseItem.prototype, "parentContainer", { get: function () { return this._parentContainer; }, set: function (value) { this._parentContainer = value; this._onContainerChanged(); }, enumerable: true, configurable: true }); BaseItem.prototype._onContainerChanged = function () { }; BaseItem.prototype._copy = function (source, destination, generateNewIds, appropriateParentContainer) { _super.prototype._copy.call(this, source, destination, generateNewIds); if (appropriateParentContainer) destination.parentContainer = source.parentContainer; }; BaseItem.prototype.clone = function (generateNewIds, appropriateParentContainer) { if (generateNewIds === void 0) { generateNewIds = false; } if (appropriateParentContainer === void 0) { appropriateParentContainer = false; } if (this.type !== BaseItem.type) throw new NotImplementedException(".clone() method must be overridden in " + this.type + " class"); var item = new BaseItem(); this._copy(this, item, generateNewIds, appropriateParentContainer); return item; }; BaseItem.prototype.copyTo = function (destination) { this._copy(this, destination, true, true); }; BaseItem.prototype.update = function (item) { this._copy(item, this, true, false); }; BaseItem.prototype.getSimplifiedObject = function (omitProperties) { if (!_.isArray(omitProperties) && !_.isString(omitProperties)) omitProperties = []; var simplified = _super.prototype.getSimplifiedObject.call(this, ["parentContainer"].concat(omitProperties)); simplified["$type"] = this.type; return simplified; }; BaseItem.type = "base"; return BaseItem; }(ModelComponent)); export { BaseItem }; //# sourceMappingURL=BaseItem.js.map