From b285b2b00c5b42c779d5111860435aba7f37e55f Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Fri, 11 Dec 2020 10:58:36 +0200 Subject: [PATCH] Fix for edge rulechains --- .../rulechains-table-config.resolver.ts | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts index b9a41d65fc..300a0372dc 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts @@ -20,7 +20,7 @@ import {ActivatedRouteSnapshot, Resolve, Route, Router} from '@angular/router'; import { CellActionDescriptor, checkBoxCell, - DateEntityTableColumn, + DateEntityTableColumn, EntityColumn, EntityTableColumn, EntityTableConfig, GroupActionDescriptor, HeaderActionDescriptor @@ -86,10 +86,44 @@ export class RuleChainsTableConfigResolver implements Resolve this.config.componentsData.rootRuleChainId !== ruleChain.id.id; + this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => { + this.config.componentsData.rootRuleChainId = edge.rootRuleChainId.id; + this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains'); + }); + this.config.entitiesDeleteEnabled = false; + } else { + this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root; + this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; + this.config.entitiesDeleteEnabled = true; + } + return this.config; + } - if (this.config.componentsData.ruleChainScope === 'edges') { - this.config.columns = []; - this.config.columns.push( + configuteEntityTableColumns(ruleChainScope: string): Array> { + const columns: Array> = []; + if (ruleChainScope === 'tenant' || ruleChainScope === 'edge') { + columns.push( + new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), + new EntityTableColumn('name', 'rulechain.name', '100%'), + new EntityTableColumn('root', 'rulechain.root', '60px', + entity => { + if (ruleChainScope === 'edge') { + return checkBoxCell((this.config.componentsData.rootRuleChainId == entity.id.id)); + } else { + return checkBoxCell(entity.root); + } + }) + ); + } + if (ruleChainScope === 'edges') { + columns.push( new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'rulechain.name', '100%'), new EntityTableColumn('root', 'rulechain.default-root', '60px', @@ -97,41 +131,8 @@ export class RuleChainsTableConfigResolver implements Resolve('createdTime', 'common.created-time', this.datePipe, '150px'), - new EntityTableColumn('name', 'rulechain.name', '100%'), - new EntityTableColumn('root', 'rulechain.root', '60px', - entity => { - if (this.config.componentsData.edgeId) { - return checkBoxCell((this.config.componentsData.edge.rootRuleChainId.id == entity.id.id)); - } else { - return checkBoxCell(entity.root); - } - - }) - ); } - - if (this.config.componentsData.edgeId) { - this.config.entitySelectionEnabled = ruleChain => this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id; - this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => { - this.config.componentsData.edge = edge; - this.config.componentsData.rootRuleChainId = edge.rootRuleChainId.id; - this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains'); - }); - this.config.entitiesDeleteEnabled = false; - } - else { - this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root; - this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; - } - this.configureEntityFunctions(this.config.componentsData.ruleChainScope); - this.config.groupActionDescriptors = this.configureGroupActions(this.config.componentsData.ruleChainScope); - this.config.addActionDescriptors = this.configureAddActions(this.config.componentsData.ruleChainScope); - this.config.cellActionDescriptors = this.configureCellActions(this.config.componentsData.ruleChainScope); - return this.config; + return columns; } configureAddActions(ruleChainScope: string): Array { @@ -253,7 +254,7 @@ export class RuleChainsTableConfigResolver implements Resolve entity.id.id != this.config.componentsData.edge.rootRuleChainId.id, + isEnabled: (entity) => entity.id.id != this.config.componentsData.rootRuleChainId, onAction: ($event, entity) => this.unassignFromEdge($event, entity) } ) @@ -486,7 +487,7 @@ export class RuleChainsTableConfigResolver implements Resolve