Commit 04e50696f679e697c13fe52e75bed345b8882987

Authored by Artem Babak
1 parent 3e67a9ad

Fix for setRootRuleChains button - for edge scope

@@ -31,7 +31,13 @@ @@ -31,7 +31,13 @@
31 <button mat-raised-button color="primary" 31 <button mat-raised-button color="primary"
32 [disabled]="(isLoading$ | async)" 32 [disabled]="(isLoading$ | async)"
33 (click)="onEntityAction($event, 'setRoot')" 33 (click)="onEntityAction($event, 'setRoot')"
34 - [fxShow]="!isEdit && !entity?.root"> 34 + [fxShow]="!isEdit && !entity?.root && !isEdgeRuleChainScope()">
  35 + {{'rulechain.set-root' | translate }}
  36 + </button>
  37 + <button mat-raised-button color="primary"
  38 + [disabled]="(isLoading$ | async)"
  39 + (click)="onEntityAction($event, 'setRoot')"
  40 + [fxShow]="!isEdit && isEdgeRuleChainScope() && !isRootRuleChain()">
35 {{'rulechain.set-root' | translate }} 41 {{'rulechain.set-root' | translate }}
36 </button> 42 </button>
37 <button mat-raised-button color="primary" 43 <button mat-raised-button color="primary"
@@ -79,6 +79,14 @@ export class RuleChainComponent extends EntityComponent<RuleChain> { @@ -79,6 +79,14 @@ export class RuleChainComponent extends EntityComponent<RuleChain> {
79 })); 79 }));
80 } 80 }
81 81
  82 + isTenantRuleChainScope() {
  83 + if (this.entitiesTableConfig) {
  84 + return this.entitiesTableConfig.componentsData.ruleChainScope == 'tenant';
  85 + } else {
  86 + return false;
  87 + }
  88 + }
  89 +
82 isEdgesRuleChainScope() { 90 isEdgesRuleChainScope() {
83 if (this.entitiesTableConfig) { 91 if (this.entitiesTableConfig) {
84 return this.entitiesTableConfig.componentsData.ruleChainScope == 'edges'; 92 return this.entitiesTableConfig.componentsData.ruleChainScope == 'edges';
@@ -86,4 +94,20 @@ export class RuleChainComponent extends EntityComponent<RuleChain> { @@ -86,4 +94,20 @@ export class RuleChainComponent extends EntityComponent<RuleChain> {
86 return false; 94 return false;
87 } 95 }
88 } 96 }
  97 +
  98 + isEdgeRuleChainScope() {
  99 + if (this.entitiesTableConfig) {
  100 + return this.entitiesTableConfig.componentsData.ruleChainScope == 'edge';
  101 + } else {
  102 + return false;
  103 + }
  104 + }
  105 +
  106 + isRootRuleChain() {
  107 + if (this.entitiesTableConfig && this.entityValue) {
  108 + return this.entitiesTableConfig.componentsData.rootRuleChainId == this.entityValue.id.id;
  109 + } else {
  110 + return false;
  111 + }
  112 + }
89 } 113 }
@@ -118,6 +118,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig< @@ -118,6 +118,7 @@ export class RuleChainsTableConfigResolver implements Resolve<EntityTableConfig<
118 this.config.entitySelectionEnabled = ruleChain => this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id; 118 this.config.entitySelectionEnabled = ruleChain => this.config.componentsData.edge.rootRuleChainId.id != ruleChain.id.id;
119 this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => { 119 this.edgeService.getEdge(this.config.componentsData.edgeId).subscribe(edge => {
120 this.config.componentsData.edge = edge; 120 this.config.componentsData.edge = edge;
  121 + this.config.componentsData.rootRuleChainId = edge.rootRuleChainId.id;
121 this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains'); 122 this.config.tableTitle = edge.name + ': ' + this.translate.instant('rulechain.edge-rulechains');
122 }); 123 });
123 this.config.entitiesDeleteEnabled = false; 124 this.config.entitiesDeleteEnabled = false;