UI: Fixed notification table templates/rules were not updated after creating a copy template/rule

This commit is contained in:
Vladyslav_Prykhodko 2025-01-06 17:14:39 +02:00
parent dfbc8f1cde
commit 16d00361a2
3 changed files with 19 additions and 23 deletions

View File

@ -55,7 +55,7 @@ export class RecipientTableConfigResolver {
this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TARGET); this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TARGET);
this.config.entityResources = {} as EntityTypeResource<NotificationTarget>; this.config.entityResources = {} as EntityTypeResource<NotificationTarget>;
this.config.addEntity = () => this.editTarget(null, true); this.config.addEntity = () => this.notificationTargetDialog(null, true);
this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink); this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTargets(pageLink);
@ -72,11 +72,7 @@ export class RecipientTableConfigResolver {
this.config.handleRowClick = ($event, target) => { this.config.handleRowClick = ($event, target) => {
$event?.stopPropagation(); $event?.stopPropagation();
this.editTarget(target).subscribe((res) => { this.notificationTargetDialog(target).subscribe(res => res ? this.config.updateData() : null);
if (res) {
this.config.updateData();
}
});
return true; return true;
}; };
@ -100,7 +96,7 @@ export class RecipientTableConfigResolver {
return []; return [];
} }
private editTarget(target: NotificationTarget, isAdd = false): Observable<NotificationTarget> { private notificationTargetDialog(target: NotificationTarget, isAdd = false): Observable<NotificationTarget> {
return this.dialog.open<RecipientNotificationDialogComponent, RecipientNotificationDialogData, return this.dialog.open<RecipientNotificationDialogComponent, RecipientNotificationDialogData,
NotificationTarget>(RecipientNotificationDialogComponent, { NotificationTarget>(RecipientNotificationDialogComponent, {
disableClose: true, disableClose: true,

View File

@ -55,7 +55,7 @@ export class RuleTableConfigResolver {
this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_RULE); this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_RULE);
this.config.entityResources = {} as EntityTypeResource<NotificationRule>; this.config.entityResources = {} as EntityTypeResource<NotificationRule>;
this.config.addEntity = () => this.editRule(null, null, true); this.config.addEntity = () => this.notificationRuleDialog(null, true);
this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationRules(pageLink); 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.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.config.handleRowClick = ($event, rule) => { this.config.handleRowClick = ($event, rule) => {
this.editRule($event, rule).subscribe((res) => { this.editRule($event, rule);
if (res) {
this.config.updateData();
}
});
return true; return true;
}; };
@ -109,12 +105,16 @@ export class RuleTableConfigResolver {
name: this.translate.instant('notification.copy-rule'), name: this.translate.instant('notification.copy-rule'),
icon: 'content_copy', icon: 'content_copy',
isEnabled: () => true, 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<NotificationRule> { private editRule($event: Event, rule: NotificationRule, isCopy = false): void{
$event?.stopPropagation(); $event?.stopPropagation();
this.notificationRuleDialog(rule, false, isCopy).subscribe(res => res ? this.config.updateData() : null);
}
private notificationRuleDialog(rule: NotificationRule, isAdd = false, isCopy = false): Observable<NotificationRule> {
return this.dialog.open<RuleNotificationDialogComponent, RuleNotificationDialogData, return this.dialog.open<RuleNotificationDialogComponent, RuleNotificationDialogData,
NotificationRule>(RuleNotificationDialogComponent, { NotificationRule>(RuleNotificationDialogComponent, {
disableClose: true, disableClose: true,

View File

@ -53,7 +53,7 @@ export class TemplateTableConfigResolver {
this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TEMPLATE); this.config.entityTranslations = entityTypeTranslations.get(EntityType.NOTIFICATION_TEMPLATE);
this.config.entityResources = {} as EntityTypeResource<NotificationTemplate>; this.config.entityResources = {} as EntityTypeResource<NotificationTemplate>;
this.config.addEntity = () => this.editTemplate(null, null, true); this.config.addEntity = () => this.notificationTemplateDialog(null, true);
this.config.entitiesFetchFunction = pageLink => this.notificationService.getNotificationTemplates(pageLink); 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.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.config.handleRowClick = ($event, template) => { this.config.handleRowClick = ($event, template) => {
this.editTemplate($event, template).subscribe((res) => { this.editTemplate($event, template);
if (res) {
this.config.updateData();
}
});
return true; return true;
}; };
@ -94,13 +90,17 @@ export class TemplateTableConfigResolver {
name: this.translate.instant('notification.copy-template'), name: this.translate.instant('notification.copy-template'),
icon: 'content_copy', icon: 'content_copy',
isEnabled: () => true, 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<NotificationTemplate> { private editTemplate($event: Event, template: NotificationTemplate, isCopy = false) {
$event?.stopPropagation(); $event?.stopPropagation();
this.notificationTemplateDialog(template, false, isCopy).subscribe((res) => res ? this.config.updateData() : null);
}
private notificationTemplateDialog(template: NotificationTemplate, isAdd = false, isCopy = false): Observable<NotificationTemplate> {
return this.dialog.open<TemplateNotificationDialogComponent, TemplateNotificationDialogData, return this.dialog.open<TemplateNotificationDialogComponent, TemplateNotificationDialogData,
NotificationTemplate>(TemplateNotificationDialogComponent, { NotificationTemplate>(TemplateNotificationDialogComponent, {
disableClose: true, disableClose: true,