Browse Source

dashboard-form name validation added, rule-chain-details name validation pattern and trim added

pull/3551/head
Serhii Mikhnytskyi 6 years ago
committed by Andrew Shvayka
parent
commit
3963b56102
  1. 5
      ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts
  2. 3
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html
  3. 5
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts
  4. 5
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

5
ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts

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

3
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html

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

5
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts

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

5
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

@ -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…
Cancel
Save