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 | 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 | 98 | onPublicLinkCopied($event) { |
104 | 99 | this.store.dispatch(new ActionNotificationShow( |
105 | 100 | { | ... | ... |
... | ... | @@ -29,7 +29,8 @@ |
29 | 29 | <mat-form-field fxFlex class="mat-block"> |
30 | 30 | <mat-label translate>rulenode.name</mat-label> |
31 | 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 | 34 | {{ 'rulenode.name-required' | translate }} |
34 | 35 | </mat-error> |
35 | 36 | </mat-form-field> | ... | ... |
... | ... | @@ -72,8 +72,9 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O |
72 | 72 | } |
73 | 73 | if (this.ruleNode) { |
74 | 74 | if (this.ruleNode.component.type !== RuleNodeType.RULE_CHAIN) { |
75 | + | |
75 | 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 | 78 | debugMode: [this.ruleNode.debugMode, []], |
78 | 79 | configuration: [this.ruleNode.configuration, [Validators.required]], |
79 | 80 | additionalInfo: this.fb.group( |
... | ... | @@ -102,6 +103,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O |
102 | 103 | |
103 | 104 | private updateRuleNode() { |
104 | 105 | const formValue = this.ruleNodeFormGroup.value || {}; |
106 | + | |
105 | 107 | if (this.ruleNode.component.type === RuleNodeType.RULE_CHAIN) { |
106 | 108 | const targetRuleChainId: string = formValue.targetRuleChainId; |
107 | 109 | if (this.ruleNode.targetRuleChainId !== targetRuleChainId && targetRuleChainId) { |
... | ... | @@ -115,6 +117,7 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O |
115 | 117 | Object.assign(this.ruleNode, formValue); |
116 | 118 | } |
117 | 119 | } else { |
120 | + formValue.name = formValue.name.trim(); | |
118 | 121 | Object.assign(this.ruleNode, formValue); |
119 | 122 | } |
120 | 123 | } | ... | ... |
... | ... | @@ -1550,6 +1550,11 @@ export class AddRuleNodeDialogComponent extends DialogComponent<AddRuleNodeDialo |
1550 | 1550 | |
1551 | 1551 | add(): void { |
1552 | 1552 | this.submitted = true; |
1553 | + | |
1554 | + const formValue = this.ruleNodeDetailsComponent.ruleNodeFormGroup.value; | |
1555 | + | |
1556 | + formValue.name = formValue.name.trim(); | |
1557 | + | |
1553 | 1558 | this.ruleNodeDetailsComponent.validate(); |
1554 | 1559 | if (this.ruleNodeDetailsComponent.ruleNodeFormGroup.valid) { |
1555 | 1560 | this.dialogRef.close(this.ruleNode); | ... | ... |