Merge pull request #9123 from kalutkaz/fix/ruleNodeDisable
Fix for showing disabled form controls in rule nodes
This commit is contained in:
commit
c3db59e6f8
@ -29,16 +29,12 @@
|
|||||||
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
|
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
|
||||||
</mat-progress-bar>
|
</mat-progress-bar>
|
||||||
<div mat-dialog-content>
|
<div mat-dialog-content>
|
||||||
<fieldset [disabled]="isLoading$ | async">
|
|
||||||
<tb-rule-node #tbRuleNode
|
<tb-rule-node #tbRuleNode
|
||||||
[ruleNode]="ruleNode"
|
[ruleNode]="ruleNode"
|
||||||
[ruleChainId]="ruleChainId"
|
[ruleChainId]="ruleChainId"
|
||||||
[ruleChainType]="ruleChainType"
|
[ruleChainType]="ruleChainType"
|
||||||
[isEdit]="true"
|
isAdd>
|
||||||
[isAdd]="true"
|
|
||||||
[isReadOnly]="false">
|
|
||||||
</tb-rule-node>
|
</tb-rule-node>
|
||||||
</fieldset>
|
|
||||||
</div>
|
</div>
|
||||||
<div mat-dialog-actions fxLayoutAlign="end center">
|
<div mat-dialog-actions fxLayoutAlign="end center">
|
||||||
<button mat-button color="primary"
|
<button mat-button color="primary"
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
|
||||||
tb-json-object-edit.tb-rule-node-configuration-json {
|
tb-json-object-edit.tb-rule-node-configuration-json {
|
||||||
display: block;
|
display: block;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
|
|||||||
@ -165,6 +165,9 @@ export class RuleNodeConfigComponent implements ControlValueAccessor, OnInit, On
|
|||||||
} else {
|
} else {
|
||||||
this.ruleNodeConfigFormGroup.enable({emitEvent: false});
|
this.ruleNodeConfigFormGroup.enable({emitEvent: false});
|
||||||
}
|
}
|
||||||
|
if (this.definedConfigComponent) {
|
||||||
|
this.definedConfigComponent.disabled = this.disabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeValue(value: RuleNodeConfiguration): void {
|
writeValue(value: RuleNodeConfiguration): void {
|
||||||
@ -222,6 +225,7 @@ export class RuleNodeConfigComponent implements ControlValueAccessor, OnInit, On
|
|||||||
this.definedConfigComponent.ruleChainId = this.ruleChainId;
|
this.definedConfigComponent.ruleChainId = this.ruleChainId;
|
||||||
this.definedConfigComponent.ruleChainType = this.ruleChainType;
|
this.definedConfigComponent.ruleChainType = this.ruleChainType;
|
||||||
this.definedConfigComponent.configuration = this.configuration;
|
this.definedConfigComponent.configuration = this.configuration;
|
||||||
|
this.definedConfigComponent.disabled = this.disabled;
|
||||||
this.changeSubscription = this.definedConfigComponent.configurationChanged.subscribe((configuration) => {
|
this.changeSubscription = this.definedConfigComponent.configurationChanged.subscribe((configuration) => {
|
||||||
this.updateModel(configuration);
|
this.updateModel(configuration);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,8 +22,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form [formGroup]="ruleNodeFormGroup" class="mat-padding">
|
<form [formGroup]="ruleNodeFormGroup" class="mat-padding">
|
||||||
<fieldset [disabled]="(isLoading$ | async) || !isEdit || isReadOnly">
|
|
||||||
<section>
|
|
||||||
<section class="title-row">
|
<section class="title-row">
|
||||||
<mat-form-field fxFlex class="mat-block">
|
<mat-form-field fxFlex class="mat-block">
|
||||||
<mat-label translate>rulenode.name</mat-label>
|
<mat-label translate>rulenode.name</mat-label>
|
||||||
@ -60,6 +58,4 @@
|
|||||||
<textarea matInput formControlName="description" rows="1"></textarea>
|
<textarea matInput formControlName="description" rows="1"></textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -22,11 +22,11 @@ import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms
|
|||||||
import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
|
import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
|
||||||
import { EntityType } from '@shared/models/entity-type.models';
|
import { EntityType } from '@shared/models/entity-type.models';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { RuleChainService } from '@core/http/rule-chain.service';
|
|
||||||
import { RuleNodeConfigComponent } from './rule-node-config.component';
|
import { RuleNodeConfigComponent } from './rule-node-config.component';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { RuleChainType } from '@app/shared/models/rule-chain.models';
|
import { RuleChainType } from '@app/shared/models/rule-chain.models';
|
||||||
import { ComponentClusteringMode } from '@shared/models/component-descriptor.models';
|
import { ComponentClusteringMode } from '@shared/models/component-descriptor.models';
|
||||||
|
import { coerceBoolean } from '@shared/decorators/coercion';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-rule-node',
|
selector: 'tb-rule-node',
|
||||||
@ -47,12 +47,11 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
ruleChainType: RuleChainType;
|
ruleChainType: RuleChainType;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
isEdit: boolean;
|
@coerceBoolean()
|
||||||
|
disabled = false;
|
||||||
@Input()
|
|
||||||
isReadOnly: boolean;
|
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
|
@coerceBoolean()
|
||||||
isAdd = false;
|
isAdd = false;
|
||||||
|
|
||||||
@Output()
|
@Output()
|
||||||
@ -70,7 +69,6 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
|
|
||||||
constructor(protected store: Store<AppState>,
|
constructor(protected store: Store<AppState>,
|
||||||
private fb: UntypedFormBuilder,
|
private fb: UntypedFormBuilder,
|
||||||
private ruleChainService: RuleChainService,
|
|
||||||
private router: Router) {
|
private router: Router) {
|
||||||
super(store);
|
super(store);
|
||||||
this.ruleNodeFormGroup = this.fb.group({});
|
this.ruleNodeFormGroup = this.fb.group({});
|
||||||
@ -99,6 +97,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
} else {
|
} else {
|
||||||
this.ruleNodeFormGroup = this.fb.group({});
|
this.ruleNodeFormGroup = this.fb.group({});
|
||||||
}
|
}
|
||||||
|
if (this.disabled) {
|
||||||
|
this.ruleNodeFormGroup.disable({emitEvent: false});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateRuleNode() {
|
private updateRuleNode() {
|
||||||
@ -108,6 +109,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
if (this.disabled) {
|
||||||
|
this.ruleNodeFormGroup.disable({emitEvent: false});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
|||||||
@ -110,8 +110,6 @@
|
|||||||
[ruleNode]="editingRuleNode"
|
[ruleNode]="editingRuleNode"
|
||||||
[ruleChainId]="ruleChain.id?.id"
|
[ruleChainId]="ruleChain.id?.id"
|
||||||
[ruleChainType]="ruleChainType"
|
[ruleChainType]="ruleChainType"
|
||||||
[isEdit]="true"
|
|
||||||
[isReadOnly]="false"
|
|
||||||
(initRuleNode)="onRuleNodeInit()"
|
(initRuleNode)="onRuleNodeInit()"
|
||||||
(changeScript)="switchToFirstTab()">
|
(changeScript)="switchToFirstTab()">
|
||||||
</tb-rule-node>
|
</tb-rule-node>
|
||||||
|
|||||||
@ -74,6 +74,7 @@ export interface IRuleNodeConfigurationComponent {
|
|||||||
ruleNodeId: string;
|
ruleNodeId: string;
|
||||||
ruleChainId: string;
|
ruleChainId: string;
|
||||||
hasScript: boolean;
|
hasScript: boolean;
|
||||||
|
disabled: boolean;
|
||||||
testScriptLabel?: string;
|
testScriptLabel?: string;
|
||||||
changeScript?: EventEmitter<void>;
|
changeScript?: EventEmitter<void>;
|
||||||
ruleChainType: RuleChainType;
|
ruleChainType: RuleChainType;
|
||||||
@ -101,6 +102,14 @@ export abstract class RuleNodeConfigurationComponent extends PageComponent imple
|
|||||||
|
|
||||||
private configurationSet = false;
|
private configurationSet = false;
|
||||||
|
|
||||||
|
set disabled(value: boolean) {
|
||||||
|
if (value) {
|
||||||
|
this.configForm().disable({emitEvent: false});
|
||||||
|
} else {
|
||||||
|
this.configForm().enable({emitEvent: false});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
set configuration(value: RuleNodeConfiguration) {
|
set configuration(value: RuleNodeConfiguration) {
|
||||||
this.configurationValue = value;
|
this.configurationValue = value;
|
||||||
if (!this.configurationSet) {
|
if (!this.configurationSet) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user