Browse Source

Fix rule node disable

pull/9123/head
kalytka 3 years ago
parent
commit
638916b7cd
  1. 4
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-config.component.ts
  2. 2
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html
  3. 13
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts
  4. 9
      ui-ngx/src/app/shared/models/rule-node.models.ts

4
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);
});

2
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html

@ -22,7 +22,7 @@
</button>
</div>
<form [formGroup]="ruleNodeFormGroup" class="mat-padding">
<fieldset [disabled]="(isLoading$ | async) || !isEdit || isReadOnly">
<fieldset [disabled]="(isLoading$ | async)">
<section>
<section class="title-row">
<mat-form-field fxFlex class="mat-block">

13
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() {

9
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<void>;
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) {

Loading…
Cancel
Save