diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html index 878131dd24..7358e06d77 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.html @@ -384,28 +384,54 @@ - +
notification.button-text - - + + {{ 'notification.button-text-required' | translate }} - + {{ 'notification.button-text-max-length' | translate : - {length: microsoftTeamsTemplateForm.get('button.name').getError('maxlength').requiredLength} + {length: microsoftTeamsTemplateForm.get('button.text').getError('maxlength').requiredLength} }} - +
+
+ + notification.action-type + + + {{ actionButtonLinkTypeTranslateMap.get(actionButtonLinkType) | translate }} + + + + notification.link - - + + {{ 'notification.link-required' | translate }} + + + + + +
+ + {{ 'notification.set-entity-from-notification' | translate }} +
diff --git a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss index 7d838eab70..97eb99a9fc 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/notification/sent/sent-notification-dialog.component.scss @@ -242,8 +242,12 @@ } } - .tb-form-panel .mat-expansion-panel.tb-settings > .mat-expansion-panel-content > .mat-expansion-panel-body { - gap: 0; + .tb-form-panel .mat-expansion-panel.tb-settings { + padding: 11px 16px; + + & > .mat-expansion-panel-content > .mat-expansion-panel-body { + gap: 0; + } } } diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts index dade64c22e..c2dc5355e8 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-configuration.ts @@ -98,15 +98,7 @@ export abstract class TemplateConfiguration extends DialogComponent< icon: [{value: 'notifications', disabled: true}, Validators.required], color: [{value: '#757575', disabled: true}] }), - actionButtonConfig: this.fb.group({ - enabled: [false], - text: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(50)]], - linkType: [ActionButtonLinkType.LINK], - link: [{value: '', disabled: true}, Validators.required], - dashboardId: [{value: null, disabled: true}, Validators.required], - dashboardState: [{value: null, disabled: true}], - setEntityIdInState: [{value: true, disabled: true}], - }), + actionButtonConfig: this.createButtonConfigForm() }) }); @@ -122,37 +114,6 @@ export abstract class TemplateConfiguration extends DialogComponent< } }); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.enabled').valueChanges.pipe( - takeUntil(this.destroy$) - ).subscribe((value) => { - if (value) { - this.webTemplateForm.get('additionalConfig.actionButtonConfig').enable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.linkType').updateValueAndValidity({onlySelf: true}); - } else { - this.webTemplateForm.get('additionalConfig.actionButtonConfig').disable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.enabled').enable({emitEvent: false}); - } - }); - - this.webTemplateForm.get('additionalConfig.actionButtonConfig.linkType').valueChanges.pipe( - takeUntil(this.destroy$) - ).subscribe((value) => { - const isEnabled = this.webTemplateForm.get('additionalConfig.actionButtonConfig.enabled').value; - if (isEnabled) { - if (value === ActionButtonLinkType.LINK) { - this.webTemplateForm.get('additionalConfig.actionButtonConfig.link').enable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.dashboardId').disable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.dashboardState').disable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.setEntityIdInState').disable({emitEvent: false}); - } else { - this.webTemplateForm.get('additionalConfig.actionButtonConfig.link').disable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.dashboardId').enable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.dashboardState').enable({emitEvent: false}); - this.webTemplateForm.get('additionalConfig.actionButtonConfig.setEntityIdInState').enable({emitEvent: false}); - } - } - }); - this.emailTemplateForm = this.fb.group({ subject: ['', Validators.required], body: ['', Validators.required] @@ -170,22 +131,7 @@ export abstract class TemplateConfiguration extends DialogComponent< subject: [''], body: ['', Validators.required], themeColor: [''], - button: this.fb.group({ - enabled: [false], - name: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(50)]], - uri: [{value: '', disabled: true}, Validators.required], - }), - }); - - this.microsoftTeamsTemplateForm.get('button.enabled').valueChanges.pipe( - takeUntil(this.destroy$) - ).subscribe((value) => { - if (value) { - this.microsoftTeamsTemplateForm.get('button').enable({emitEvent: false}); - } else { - this.microsoftTeamsTemplateForm.get('button').disable({emitEvent: false}); - this.microsoftTeamsTemplateForm.get('button.enabled').enable({emitEvent: false}); - } + button: this.createButtonConfigForm() }); this.deliveryMethodFormsMap = new Map([ @@ -224,4 +170,48 @@ export abstract class TemplateConfiguration extends DialogComponent< }); return deepTrim(template); } + + private createButtonConfigForm(): FormGroup { + const form = this.fb.group({ + enabled: [false], + text: [{value: '', disabled: true}, [Validators.required, Validators.maxLength(50)]], + linkType: [ActionButtonLinkType.LINK], + link: [{value: '', disabled: true}, Validators.required], + dashboardId: [{value: null, disabled: true}, Validators.required], + dashboardState: [{value: null, disabled: true}], + setEntityIdInState: [{value: true, disabled: true}], + }); + + form.get('enabled').valueChanges.pipe( + takeUntil(this.destroy$) + ).subscribe((value) => { + if (value) { + form.enable({emitEvent: false}); + form.get('linkType').updateValueAndValidity({onlySelf: true}); + } else { + form.disable({emitEvent: false}); + form.get('enabled').enable({emitEvent: false}); + } + }); + + form.get('linkType').valueChanges.pipe( + takeUntil(this.destroy$) + ).subscribe((value) => { + const isEnabled = form.get('enabled').value; + if (isEnabled) { + if (value === ActionButtonLinkType.LINK) { + form.get('link').enable({emitEvent: false}); + form.get('dashboardId').disable({emitEvent: false}); + form.get('dashboardState').disable({emitEvent: false}); + form.get('setEntityIdInState').disable({emitEvent: false}); + } else { + form.get('link').disable({emitEvent: false}); + form.get('dashboardId').enable({emitEvent: false}); + form.get('dashboardState').enable({emitEvent: false}); + form.get('setEntityIdInState').enable({emitEvent: false}); + } + } + }); + return form; + } } diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html index 6d27ef4980..81ca756263 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.html @@ -310,28 +310,54 @@ - +
notification.button-text - - + + {{ 'notification.button-text-required' | translate }} - + {{ 'notification.button-text-max-length' | translate : - {length: microsoftTeamsTemplateForm.get('button.name').getError('maxlength').requiredLength} + {length: microsoftTeamsTemplateForm.get('button.text').getError('maxlength').requiredLength} }} - +
+
+ + notification.action-type + + + {{ actionButtonLinkTypeTranslateMap.get(actionButtonLinkType) | translate }} + + + + notification.link - - + + {{ 'notification.link-required' | translate }} + + + + + +
+ + {{ 'notification.set-entity-from-notification' | translate }} +
diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.scss index 507054440d..cf41bae5d0 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-notification-dialog.component.scss @@ -126,8 +126,12 @@ } } - .tb-form-panel .mat-expansion-panel.tb-settings > .mat-expansion-panel-content > .mat-expansion-panel-body { - gap: 0; + .tb-form-panel .mat-expansion-panel.tb-settings { + padding: 11px 16px; + + & > .mat-expansion-panel-content > .mat-expansion-panel-body { + gap: 0; + } } } } diff --git a/ui-ngx/src/app/shared/models/notification.models.ts b/ui-ngx/src/app/shared/models/notification.models.ts index 9414368029..047ec7b38d 100644 --- a/ui-ngx/src/app/shared/models/notification.models.ts +++ b/ui-ngx/src/app/shared/models/notification.models.ts @@ -328,15 +328,17 @@ interface WebDeliveryMethodAdditionalConfig { icon: string; color: string; }; - actionButtonConfig: { - enabled: boolean; - text: string; - linkType: ActionButtonLinkType; - link?: string; - dashboardId?: string; - dashboardState?: string; - setEntityIdInState?: boolean; - }; + actionButtonConfig: NotificationButtonConfig; +} + +interface NotificationButtonConfig { + enabled: boolean; + text: string; + linkType: ActionButtonLinkType; + link?: string; + dashboardId?: string; + dashboardState?: string; + setEntityIdInState?: boolean; } interface EmailDeliveryMethodNotificationTemplate { @@ -350,11 +352,7 @@ interface SlackDeliveryMethodNotificationTemplate { interface MicrosoftTeamsDeliveryMethodNotificationTemplate { subject?: string; - button: { - enabled: boolean; - name?: string; - uri?: string; - }; + button: NotificationButtonConfig; } export enum NotificationStatus {