dashboard-form name validation added, rule-chain-details name validation pattern and trim added
This commit is contained in:
parent
a39087883a
commit
3963b56102
@ -95,11 +95,6 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> {
|
||||
this.entityForm.patchValue({configuration: {description: entity.configuration ? entity.configuration.description : ''}});
|
||||
}
|
||||
|
||||
prepareFormValue(formValue: any): any {
|
||||
formValue.configuration = {...(this.entity.configuration || {}), ...(formValue.configuration || {})};
|
||||
return formValue;
|
||||
}
|
||||
|
||||
onPublicLinkCopied($event) {
|
||||
this.store.dispatch(new ActionNotificationShow(
|
||||
{
|
||||
|
||||
@ -29,7 +29,8 @@
|
||||
<mat-form-field fxFlex class="mat-block">
|
||||
<mat-label translate>rulenode.name</mat-label>
|
||||
<input matInput formControlName="name" required>
|
||||
<mat-error *ngIf="ruleNodeFormGroup.get('name').hasError('required')">
|
||||
<mat-error *ngIf="ruleNodeFormGroup.get('name').hasError('required')
|
||||
|| ruleNodeFormGroup.get('name').hasError('pattern')">
|
||||
{{ 'rulenode.name-required' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
@ -72,8 +72,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
}
|
||||
if (this.ruleNode) {
|
||||
if (this.ruleNode.component.type !== RuleNodeType.RULE_CHAIN) {
|
||||
|
||||
this.ruleNodeFormGroup = this.fb.group({
|
||||
name: [this.ruleNode.name, [Validators.required]],
|
||||
name: [this.ruleNode.name, [Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]],
|
||||
debugMode: [this.ruleNode.debugMode, []],
|
||||
configuration: [this.ruleNode.configuration, [Validators.required]],
|
||||
additionalInfo: this.fb.group(
|
||||
@ -102,6 +103,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
|
||||
private updateRuleNode() {
|
||||
const formValue = this.ruleNodeFormGroup.value || {};
|
||||
|
||||
if (this.ruleNode.component.type === RuleNodeType.RULE_CHAIN) {
|
||||
const targetRuleChainId: string = formValue.targetRuleChainId;
|
||||
if (this.ruleNode.targetRuleChainId !== targetRuleChainId && targetRuleChainId) {
|
||||
@ -115,6 +117,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
|
||||
Object.assign(this.ruleNode, formValue);
|
||||
}
|
||||
} else {
|
||||
formValue.name = formValue.name.trim();
|
||||
Object.assign(this.ruleNode, formValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1550,6 +1550,11 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo
|
||||
|
||||
add(): void {
|
||||
this.submitted = true;
|
||||
|
||||
const formValue = this.ruleNodeDetailsComponent.ruleNodeFormGroup.value;
|
||||
|
||||
formValue.name = formValue.name.trim();
|
||||
|
||||
this.ruleNodeDetailsComponent.validate();
|
||||
if (this.ruleNodeDetailsComponent.ruleNodeFormGroup.valid) {
|
||||
this.dialogRef.close(this.ruleNode);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user