Merge branch 'fix/ruleNodeDisable' of github.com:kalutkaz/thingsboard into kalutkaz-fix/ruleNodeDisable

This commit is contained in:
Vladyslav_Prykhodko 2023-08-25 16:22:31 +03:00
commit 186614a18d
4 changed files with 26 additions and 2 deletions

View File

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

View File

@ -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">

View File

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

View File

@ -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) {