diff --git a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-dialog.component.ts index 193fc4bbb5..6a12ec05aa 100644 --- a/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/mobile/applications/mobile-app-dialog.component.ts @@ -23,7 +23,7 @@ import { Router } from '@angular/router'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { FormGroupDirective, NgForm, UntypedFormControl } from '@angular/forms'; import { MobileApp } from '@shared/models/mobile-app.models'; -import { MobileAppComponent } from '@home/pages/mobile/applications/mobile-app.component'; +import type { MobileAppComponent } from '@home/pages/mobile/applications/mobile-app.component'; import { PlatformType } from '@shared/models/oauth2.models'; import { MobileAppService } from '@core/http/mobile-app.service'; @@ -57,6 +57,7 @@ export class MobileAppDialogComponent extends DialogComponent; - this.config.addEntity = () => this.editTarget(null, true); + this.config.addEntity = () => this.notificationTargetDialog(null, true); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink); @@ -66,17 +65,10 @@ export class RecipientTableConfigResolver { this.config.deleteEntity = id => this.notificationService.deleteNotificationTarget(id.id); - this.config.cellActionDescriptors = this.configureCellActions(); - this.config.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; this.config.handleRowClick = ($event, target) => { - $event?.stopPropagation(); - this.editTarget(target).subscribe((res) => { - if (res) { - this.config.updateData(); - } - }); + this.editTarget($event, target); return true; }; @@ -96,11 +88,12 @@ export class RecipientTableConfigResolver { return this.config; } - private configureCellActions(): Array> { - return []; + private editTarget($event: Event, target: NotificationTarget): void { + $event?.stopPropagation(); + this.notificationTargetDialog(target).subscribe(res => res ? this.config.updateData() : null); } - 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,