From 638916b7cdc0d7b2bfadb4943bb97e2b9615141d Mon Sep 17 00:00:00 2001 From: kalytka Date: Wed, 23 Aug 2023 14:26:55 +0300 Subject: [PATCH] Fix rule node disable --- .../pages/rulechain/rule-node-config.component.ts | 4 ++++ .../rulechain/rule-node-details.component.html | 2 +- .../pages/rulechain/rule-node-details.component.ts | 13 ++++++++++++- ui-ngx/src/app/shared/models/rule-node.models.ts | 9 +++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-config.component.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-config.component.ts index 3f3071221e..90f29f555f 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-config.component.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-config.component.ts @@ -165,6 +165,9 @@ export class RuleNodeConfigComponent implements ControlValueAccessor, OnInit, On } else { this.ruleNodeConfigFormGroup.enable({emitEvent: false}); } + if (this.definedConfigComponent) { + this.definedConfigComponent.disabled = this.disabled; + } } writeValue(value: RuleNodeConfiguration): void { @@ -222,6 +225,7 @@ export class RuleNodeConfigComponent implements ControlValueAccessor, OnInit, On this.definedConfigComponent.ruleChainId = this.ruleChainId; this.definedConfigComponent.ruleChainType = this.ruleChainType; this.definedConfigComponent.configuration = this.configuration; + this.definedConfigComponent.disabled = this.disabled; this.changeSubscription = this.definedConfigComponent.configurationChanged.subscribe((configuration) => { this.updateModel(configuration); }); diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html index 34aa8167e3..e92e2a61ef 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html @@ -22,7 +22,7 @@
-
+
diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts index f1d6001c88..b0ec810083 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange, SimpleChanges, ViewChild } from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; @@ -119,6 +119,17 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O } } } + this.disableControl(changes.isEdit, changes.isReadOnly); + } + + private disableControl(isEdit: SimpleChange, isReadOnly: SimpleChange) { + if (isEdit.currentValue !== isEdit.previousValue || isReadOnly.currentValue !== isReadOnly.previousValue) { + if (!isEdit.currentValue || isReadOnly.currentValue) { + this.ruleNodeFormGroup.disable({emitEvent: false}); + } else { + this.ruleNodeFormGroup.enable({emitEvent: false}); + } + } } validate() { diff --git a/ui-ngx/src/app/shared/models/rule-node.models.ts b/ui-ngx/src/app/shared/models/rule-node.models.ts index 2a7dedabec..d38d027607 100644 --- a/ui-ngx/src/app/shared/models/rule-node.models.ts +++ b/ui-ngx/src/app/shared/models/rule-node.models.ts @@ -74,6 +74,7 @@ export interface IRuleNodeConfigurationComponent { ruleNodeId: string; ruleChainId: string; hasScript: boolean; + disabled: boolean; testScriptLabel?: string; changeScript?: EventEmitter; ruleChainType: RuleChainType; @@ -101,6 +102,14 @@ export abstract class RuleNodeConfigurationComponent extends PageComponent imple private configurationSet = false; + set disabled(value: boolean) { + if (value) { + this.configForm().disable({emitEvent: false}); + } else { + this.configForm().enable({emitEvent: false}); + } + }; + set configuration(value: RuleNodeConfiguration) { this.configurationValue = value; if (!this.configurationSet) {