From 16d00361a2050dc6d50ce15fbe1b43be45f1080b Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 6 Jan 2025 17:14:39 +0200 Subject: [PATCH] UI: Fixed notification table templates/rules were not updated after creating a copy template/rule --- .../recipient/recipient-table-config.resolver.ts | 10 +++------- .../rule/rule-table-config.resolver.ts | 16 ++++++++-------- .../template/template-table-config.resolver.ts | 16 ++++++++-------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts index 2ffd51ec15..3d8764413d 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts @@ -55,7 +55,7 @@ export class RecipientTableConfigResolver { this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TARGET); this.config.entityResources = {} as EntityTypeResource; - this.config.addEntity = () => this.editTarget(null, true); + this.config.addEntity = () => this.notificationTargetDialog(null, true); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink); @@ -72,11 +72,7 @@ export class RecipientTableConfigResolver { this.config.handleRowClick = ($event, target) => { $event?.stopPropagation(); - this.editTarget(target).subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); + this.notificationTargetDialog(target).subscribe(res => res ? this.config.updateData() : null); return true; }; @@ -100,7 +96,7 @@ export class RecipientTableConfigResolver { return []; } - private editTarget(target: NotificationTarget, isAdd = false): Observable { + private notificationTargetDialog(target: NotificationTarget, isAdd = false): Observable { return this.dialog.open(RecipientNotificationDialogComponent, { disableClose: true, diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts index a8fbc3ff65..54f8c860f1 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts @@ -55,7 +55,7 @@ export class RuleTableConfigResolver { this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_RULE); this.config.entityResources = {} as EntityTypeResource; - this.config.addEntity = () => this.editRule(null, null, true); + this.config.addEntity = () => this.notificationRuleDialog(null, true); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRules(pageLink); @@ -70,11 +70,7 @@ export class RuleTableConfigResolver { this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, rule) => { - this.editRule($event, rule).subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); + this.editRule($event, rule); return true; }; @@ -109,12 +105,16 @@ export class RuleTableConfigResolver { name: this.translate.instant('notification.copy-rule'), icon: 'content_copy', isEnabled: () => true, - onAction: ($event, entity) => this.editRule($event, entity, false, true) + onAction: ($event, entity) => this.editRule($event, entity, true) }]; } - private editRule($event: Event, rule: NotificationRule, isAdd = false, isCopy = false): Observable { + private editRule($event: Event, rule: NotificationRule, isCopy = false): void{ $event?.stopPropagation(); + this.notificationRuleDialog(rule, false, isCopy).subscribe(res => res ? this.config.updateData() : null); + } + + private notificationRuleDialog(rule: NotificationRule, isAdd = false, isCopy = false): Observable { return this.dialog.open(RuleNotificationDialogComponent, { disableClose: true, diff --git a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts index 0b40b48eea..e1178da56f 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/template/template-table-config.resolver.ts @@ -53,7 +53,7 @@ export class TemplateTableConfigResolver { this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TEMPLATE); this.config.entityResources = {} as EntityTypeResource; - this.config.addEntity = () => this.editTemplate(null, null, true); + this.config.addEntity = () => this.notificationTemplateDialog(null, true); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTemplates(pageLink); @@ -68,11 +68,7 @@ export class TemplateTableConfigResolver { this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, template) => { - this.editTemplate($event, template).subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); + this.editTemplate($event, template); return true; }; @@ -94,13 +90,17 @@ export class TemplateTableConfigResolver { name: this.translate.instant('notification.copy-template'), icon: 'content_copy', isEnabled: () => true, - onAction: ($event, entity) => this.editTemplate($event, entity, false, true) + onAction: ($event, entity) => this.editTemplate($event, entity, true) } ]; } - private editTemplate($event: Event, template: NotificationTemplate, isAdd = false, isCopy = false): Observable { + private editTemplate($event: Event, template: NotificationTemplate, isCopy = false) { $event?.stopPropagation(); + this.notificationTemplateDialog(template, false, isCopy).subscribe((res) => res ? this.config.updateData() : null); + } + + private notificationTemplateDialog(template: NotificationTemplate, isAdd = false, isCopy = false): Observable { return this.dialog.open(TemplateNotificationDialogComponent, { disableClose: true,