From a736701ab83a04511e1a14c920a714d0253801e5 Mon Sep 17 00:00:00 2001 From: Artem Babak Date: Fri, 11 Dec 2020 15:32:27 +0200 Subject: [PATCH] Edge root rule chains issue fix --- .../rulechains-table-config.resolver.ts | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 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 300a0372dc..ee9c07c2a1 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 @@ -86,27 +86,28 @@ 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 { + if (this.config.componentsData.ruleChainScope === 'tenant' || this.config.componentsData.ruleChainScope === 'edges') { this.config.entitySelectionEnabled = ruleChain => ruleChain && !ruleChain.root; this.config.deleteEnabled = (ruleChain) => ruleChain && !ruleChain.root; this.config.entitiesDeleteEnabled = true; } + else if (this.config.componentsData.ruleChainScope === 'edge') { + 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.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains'); + }); + this.config.entitiesDeleteEnabled = false; + } return this.config; } - configuteEntityTableColumns(ruleChainScope: string): Array> { + configureEntityTableColumns(ruleChainScope: string): Array> { const columns: Array> = []; if (ruleChainScope === 'tenant' || ruleChainScope === 'edge') { columns.push( @@ -115,7 +116,7 @@ export class RuleChainsTableConfigResolver implements Resolve('root', 'rulechain.root', '60px', entity => { if (ruleChainScope === 'edge') { - return checkBoxCell((this.config.componentsData.rootRuleChainId == entity.id.id)); + return checkBoxCell((this.config.componentsData.edge.rootRuleChainId.id == entity.id.id)); } else { return checkBoxCell(entity.root); } @@ -254,7 +255,7 @@ export class RuleChainsTableConfigResolver implements Resolve entity.id.id != this.config.componentsData.rootRuleChainId, + isEnabled: (entity) => entity.id.id != this.config.componentsData.edge.rootRuleChainId.id, onAction: ($event, entity) => this.unassignFromEdge($event, entity) } ) @@ -311,7 +312,7 @@ export class RuleChainsTableConfigResolver implements Resolve { if (res) { - if (this.config.componentsData.edgeId) { + if (this.config.componentsData.ruleChainScope === 'edge') { this.ruleChainService.setEdgeRootRuleChain(this.config.componentsData.edgeId, ruleChain.id.id).subscribe( (edge) => { this.config.componentsData.edge = edge; @@ -486,8 +487,8 @@ export class RuleChainsTableConfigResolver implements Resolve