Merge pull request #13516 from vvlladd28/bug/notifiaction-template/max-length-validation

Add missing validation for notification length message.
This commit is contained in:
Igor Kulikov 2025-06-06 18:58:36 +03:00 committed by GitHub
commit e313b42114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 4 deletions

View File

@ -62,6 +62,12 @@
*ngIf="actionButtonConfigForm.get('link').hasError('required')"> *ngIf="actionButtonConfigForm.get('link').hasError('required')">
{{ 'notification.link-required' | translate }} {{ 'notification.link-required' | translate }}
</mat-error> </mat-error>
<mat-error
*ngIf="actionButtonConfigForm.get('link').hasError('maxlength')">
{{ 'notification.link-max-length' | translate :
{length: actionButtonConfigForm.get('link').getError('maxlength').requiredLength}
}}
</mat-error>
</mat-form-field> </mat-form-field>
<ng-template #dashboardSelector> <ng-template #dashboardSelector>
<tb-dashboard-autocomplete <tb-dashboard-autocomplete

View File

@ -84,7 +84,7 @@ export class NotificationActionButtonConfigurationComponent implements ControlVa
enabled: [false], enabled: [false],
text: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(50)]], text: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(50)]],
linkType: [ActionButtonLinkType.LINK], linkType: [ActionButtonLinkType.LINK],
link: [{value: '', disabled: true}, Validators.required], link: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(300)]],
dashboardId: [{value: null, disabled: true}, Validators.required], dashboardId: [{value: null, disabled: true}, Validators.required],
dashboardState: [{value: null, disabled: true}], dashboardState: [{value: null, disabled: true}],
setEntityIdInState: [{value: true, disabled: true}] setEntityIdInState: [{value: true, disabled: true}]

View File

@ -44,6 +44,11 @@
<mat-error *ngIf="templateConfigurationForm.get('WEB.subject').hasError('required')"> <mat-error *ngIf="templateConfigurationForm.get('WEB.subject').hasError('required')">
{{ 'notification.subject-required' | translate }} {{ 'notification.subject-required' | translate }}
</mat-error> </mat-error>
<mat-error *ngIf="templateConfigurationForm.get('WEB.subject').hasError('maxlength')">
{{'notification.subject-max-length' | translate :
{length: templateConfigurationForm.get('WEB.subject').getError('maxlength').requiredLength}
}}
</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">
<mat-label translate>notification.message</mat-label> <mat-label translate>notification.message</mat-label>
@ -56,6 +61,11 @@
<mat-error *ngIf="templateConfigurationForm.get('WEB.body').hasError('required')"> <mat-error *ngIf="templateConfigurationForm.get('WEB.body').hasError('required')">
{{ 'notification.message-required' | translate }} {{ 'notification.message-required' | translate }}
</mat-error> </mat-error>
<mat-error *ngIf="templateConfigurationForm.get('WEB.body').hasError('maxlength')">
{{ 'notification.message-max-length' | translate :
{length: templateConfigurationForm.get('WEB.body').getError('maxlength').requiredLength}
}}
</mat-error>
</mat-form-field> </mat-form-field>
<section formGroupName="additionalConfig" class="tb-form-panel no-padding no-border"> <section formGroupName="additionalConfig" class="tb-form-panel no-padding no-border">
<div class="tb-form-row space-between" formGroupName="icon"> <div class="tb-form-row space-between" formGroupName="icon">
@ -194,6 +204,11 @@
<mat-error *ngIf="templateConfigurationForm.get('EMAIL.subject').hasError('required')"> <mat-error *ngIf="templateConfigurationForm.get('EMAIL.subject').hasError('required')">
{{ 'notification.subject-required' | translate }} {{ 'notification.subject-required' | translate }}
</mat-error> </mat-error>
<mat-error *ngIf="templateConfigurationForm.get('EMAIL.subject').hasError('maxlength')">
{{'notification.subject-max-length' | translate :
{length: templateConfigurationForm.get('EMAIL.subject').getError('maxlength').requiredLength}
}}
</mat-error>
</mat-form-field> </mat-form-field>
<mat-label class="tb-title tb-required" <mat-label class="tb-title tb-required"
[class.tb-error]="(interacted || templateConfigurationForm.get('EMAIL.body').touched) && templateConfigurationForm.get('EMAIL.body').hasError('required')" [class.tb-error]="(interacted || templateConfigurationForm.get('EMAIL.body').touched) && templateConfigurationForm.get('EMAIL.body').hasError('required')"

View File

@ -226,8 +226,8 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
switch (deliveryMethod) { switch (deliveryMethod) {
case NotificationDeliveryMethod.WEB: case NotificationDeliveryMethod.WEB:
deliveryMethodForm = this.fb.group({ deliveryMethodForm = this.fb.group({
subject: ['', Validators.required], subject: ['', [Validators.required, Validators.maxLength(150)]],
body: ['', Validators.required], body: ['', [Validators.required, Validators.maxLength(250)]],
additionalConfig: this.fb.group({ additionalConfig: this.fb.group({
icon: this.fb.group({ icon: this.fb.group({
enabled: [false], enabled: [false],
@ -252,7 +252,7 @@ export class NotificationTemplateConfigurationComponent implements OnDestroy, Co
break; break;
case NotificationDeliveryMethod.EMAIL: case NotificationDeliveryMethod.EMAIL:
deliveryMethodForm = this.fb.group({ deliveryMethodForm = this.fb.group({
subject: ['', Validators.required], subject: ['', [Validators.required, Validators.maxLength(250)]],
body: ['', Validators.required] body: ['', Validators.required]
}); });
break; break;

View File

@ -3963,6 +3963,7 @@
"input-fields-support-templatization": "Input fields support templatization.", "input-fields-support-templatization": "Input fields support templatization.",
"link": "Link", "link": "Link",
"link-required": "Link is required", "link-required": "Link is required",
"link-max-length": "Link should be less than or equal to {{ length }} characters",
"link-type": { "link-type": {
"dashboard": "Open dashboard", "dashboard": "Open dashboard",
"link": "Open URL link" "link": "Open URL link"