| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Ressource = void 0;
- class Ressource {
- constructor(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.collapseChildren ? obj.collapseChildren : false;
- 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;
- this.children.forEach((o) => (o.parent = this));
- }
- get parentId() {
- var _a;
- return ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.id) || "";
- }
- get depth() {
- return this.parent ? this.parent.depth + 1 : 0;
- }
- get show() {
- return this.parent === undefined ? true : this.parent.show && !this.parent.collapseChildren;
- }
- descendantOf(potentialParent) {
- return this.parent === undefined
- ? false
- : this.parent.id === potentialParent.id || this.parent.descendantOf(potentialParent);
- }
- toPlainObject(parent) {
- return {
- id: this.id,
- title: this.title,
- children: this.children.map((o) => o.toPlainObject(this)),
- parent: parent,
- };
- }
- toJSON() {
- return {
- id: this.id,
- title: this.title,
- collapseChildren: this.collapseChildren,
- parentId: this.parentId,
- height: this.height,
- eventEditable: this.eventEditable,
- eventRessourceEditable: this.eventRessourceEditable,
- eventBgColor: this.eventBgColor,
- };
- }
- static toRessource(obj) {
- if (obj instanceof Ressource) {
- return obj;
- }
- else {
- return new Ressource(obj);
- }
- }
- }
- exports.Ressource = Ressource;
- exports.default = Ressource;
- //# sourceMappingURL=Ressource.js.map
|