| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Ressource = void 0;
- var Ressource = (function () {
- function Ressource(obj) {
- this.id = obj.id;
- this.title = obj.title || obj.id;
- if (obj.children) {
- this.children = obj.children.map(Ressource.toRessource);
- }
- else {
- this.children = [];
- }
- this.collapseChildren = (obj === null || obj === void 0 ? void 0 : obj.collapseChildren) === undefined ? false : obj.collapseChildren;
- this.parent = obj.parent ? Ressource.toRessource(obj.parent) : undefined;
- this.height = obj.height;
- this.eventEditable = (obj === null || obj === void 0 ? void 0 : obj.eventEditable) === undefined ? true : obj.eventEditable;
- this.eventRessourceEditable = (obj === null || obj === void 0 ? void 0 : obj.eventRessourceEditable) === undefined ? true : obj.eventRessourceEditable;
- this.eventBgColor = obj.eventBgColor;
- this.selected = false;
- }
- Object.defineProperty(Ressource.prototype, "parentId", {
- get: function () {
- var _a;
- return ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.id) || "";
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Ressource.prototype, "depth", {
- get: function () {
- return this.parent ? this.parent.depth + 1 : 0;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(Ressource.prototype, "show", {
- get: function () {
- return this.parent === undefined ? true : (this.parent.show && !this.parent.collapseChildren);
- },
- enumerable: false,
- configurable: true
- });
- Ressource.prototype.childOf = function (potentialParent) {
- return this.parent === undefined ? false : (this.parent.id === potentialParent.id || this.parent.childOf(potentialParent));
- };
- Ressource.prototype.toPlainObject = function (parent) {
- var _this = this;
- return {
- id: this.id,
- title: this.title,
- children: this.children.map(function (o) { return o.toPlainObject(_this); }),
- parent: parent
- };
- };
- Ressource.toRessource = function (obj) {
- if (obj instanceof Ressource) {
- return obj;
- }
- else {
- return new Ressource(obj);
- }
- };
- return Ressource;
- }());
- exports.Ressource = Ressource;
- exports.default = Ressource;
- //# sourceMappingURL=Ressource.js.map
|