Commit 3963b56102f9a1d58a23d3ddf0002dffa17ea981
Committed by
Andrew Shvayka
1 parent
a3908788
dashboard-form name validation added, rule-chain-details name validation pattern and trim added
Showing
4 changed files
with
11 additions
and
7 deletions
@@ -95,11 +95,6 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> { | @@ -95,11 +95,6 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> { | ||
95 | this.entityForm.patchValue({configuration: {description: entity.configuration ? entity.configuration.description : ''}}); | 95 | this.entityForm.patchValue({configuration: {description: entity.configuration ? entity.configuration.description : ''}}); |
96 | } | 96 | } |
97 | 97 | ||
98 | - prepareFormValue(formValue: any): any { | ||
99 | - formValue.configuration = {...(this.entity.configuration || {}), ...(formValue.configuration || {})}; | ||
100 | - return formValue; | ||
101 | - } | ||
102 | - | ||
103 | onPublicLinkCopied($event) { | 98 | onPublicLinkCopied($event) { |
104 | this.store.dispatch(new ActionNotificationShow( | 99 | this.store.dispatch(new ActionNotificationShow( |
105 | { | 100 | { |
@@ -29,7 +29,8 @@ | @@ -29,7 +29,8 @@ | ||
29 | <mat-form-field fxFlex class="mat-block"> | 29 | <mat-form-field fxFlex class="mat-block"> |
30 | <mat-label translate>rulenode.name</mat-label> | 30 | <mat-label translate>rulenode.name</mat-label> |
31 | <input matInput formControlName="name" required> | 31 | <input matInput formControlName="name" required> |
32 | - <mat-error *ngIf="ruleNodeFormGroup.get('name').hasError('required')"> | 32 | + <mat-error *ngIf="ruleNodeFormGroup.get('name').hasError('required') |
33 | + || ruleNodeFormGroup.get('name').hasError('pattern')"> | ||
33 | {{ 'rulenode.name-required' | translate }} | 34 | {{ 'rulenode.name-required' | translate }} |
34 | </mat-error> | 35 | </mat-error> |
35 | </mat-form-field> | 36 | </mat-form-field> |
@@ -72,8 +72,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | @@ -72,8 +72,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | ||
72 | } | 72 | } |
73 | if (this.ruleNode) { | 73 | if (this.ruleNode) { |
74 | if (this.ruleNode.component.type !== RuleNodeType.RULE_CHAIN) { | 74 | if (this.ruleNode.component.type !== RuleNodeType.RULE_CHAIN) { |
75 | + | ||
75 | this.ruleNodeFormGroup = this.fb.group({ | 76 | this.ruleNodeFormGroup = this.fb.group({ |
76 | - name: [this.ruleNode.name, [Validators.required]], | 77 | + name: [this.ruleNode.name, [Validators.required, Validators.pattern('(.|\\s)*\\S(.|\\s)*')]], |
77 | debugMode: [this.ruleNode.debugMode, []], | 78 | debugMode: [this.ruleNode.debugMode, []], |
78 | configuration: [this.ruleNode.configuration, [Validators.required]], | 79 | configuration: [this.ruleNode.configuration, [Validators.required]], |
79 | additionalInfo: this.fb.group( | 80 | additionalInfo: this.fb.group( |
@@ -102,6 +103,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | @@ -102,6 +103,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | ||
102 | 103 | ||
103 | private updateRuleNode() { | 104 | private updateRuleNode() { |
104 | const formValue = this.ruleNodeFormGroup.value || {}; | 105 | const formValue = this.ruleNodeFormGroup.value || {}; |
106 | + | ||
105 | if (this.ruleNode.component.type === RuleNodeType.RULE_CHAIN) { | 107 | if (this.ruleNode.component.type === RuleNodeType.RULE_CHAIN) { |
106 | const targetRuleChainId: string = formValue.targetRuleChainId; | 108 | const targetRuleChainId: string = formValue.targetRuleChainId; |
107 | if (this.ruleNode.targetRuleChainId !== targetRuleChainId && targetRuleChainId) { | 109 | if (this.ruleNode.targetRuleChainId !== targetRuleChainId && targetRuleChainId) { |
@@ -115,6 +117,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | @@ -115,6 +117,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O | ||
115 | Object.assign(this.ruleNode, formValue); | 117 | Object.assign(this.ruleNode, formValue); |
116 | } | 118 | } |
117 | } else { | 119 | } else { |
120 | + formValue.name = formValue.name.trim(); | ||
118 | Object.assign(this.ruleNode, formValue); | 121 | Object.assign(this.ruleNode, formValue); |
119 | } | 122 | } |
120 | } | 123 | } |
@@ -1550,6 +1550,11 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo | @@ -1550,6 +1550,11 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo | ||
1550 | 1550 | ||
1551 | add(): void { | 1551 | add(): void { |
1552 | this.submitted = true; | 1552 | this.submitted = true; |
1553 | + | ||
1554 | + const formValue = this.ruleNodeDetailsComponent.ruleNodeFormGroup.value; | ||
1555 | + | ||
1556 | + formValue.name = formValue.name.trim(); | ||
1557 | + | ||
1553 | this.ruleNodeDetailsComponent.validate(); | 1558 | this.ruleNodeDetailsComponent.validate(); |
1554 | if (this.ruleNodeDetailsComponent.ruleNodeFormGroup.valid) { | 1559 | if (this.ruleNodeDetailsComponent.ruleNodeFormGroup.valid) { |
1555 | this.dialogRef.close(this.ruleNode); | 1560 | this.dialogRef.close(this.ruleNode); |