@nepwork/dashboards
Version:
Dashboards for emergencies and monitoring
48 lines • 1.49 kB
JavaScript
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { __decorate } from "tslib";
import { Injectable } from '@angular/core';
let NbTreeGridService = class NbTreeGridService {
expand(data, row, options = {}) {
const node = this.find(data, row);
node.expanded = true;
if (options.deep && node.hasChildren()) {
node.children.forEach((n) => this.expand(data, n.data, options));
}
}
collapse(data, row, options = {}) {
const node = this.find(data, row);
node.expanded = false;
if (options.deep && node.hasChildren()) {
node.children.forEach((n) => this.collapse(data, n.data, options));
}
}
toggle(data, row, options = {}) {
const node = this.find(data, row);
if (node.expanded) {
this.collapse(data, row, options);
}
else {
this.expand(data, row, options);
}
}
find(data, row) {
const toCheck = [...data];
for (const node of toCheck) {
if (node.data === row) {
return node;
}
if (node.hasChildren()) {
toCheck.push(...node.children);
}
}
}
};
NbTreeGridService = __decorate([
Injectable()
], NbTreeGridService);
export { NbTreeGridService };
//# sourceMappingURL=tree-grid.service.js.map