Add custom translation for Subject and Text columns in inbox notifications table

This commit is contained in:
rusikv 2023-07-19 14:40:38 +03:00
parent 15b192aad9
commit 81f9659af1

View File

@ -39,6 +39,7 @@ import {
} from '@home/pages/notification/inbox/inbox-notification-dialog.component'; } from '@home/pages/notification/inbox/inbox-notification-dialog.component';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { UtilsService } from '@core/services/utils.service';
@Injectable() @Injectable()
export class InboxTableConfigResolver implements Resolve<EntityTableConfig<Notification>> { export class InboxTableConfigResolver implements Resolve<EntityTableConfig<Notification>> {
@ -48,7 +49,8 @@ export class InboxTableConfigResolver implements Resolve<EntityTableConfig<Notif
constructor(private notificationService: NotificationService, constructor(private notificationService: NotificationService,
private translate: TranslateService, private translate: TranslateService,
private dialog: MatDialog, private dialog: MatDialog,
private datePipe: DatePipe) { private datePipe: DatePipe,
private utilsService: UtilsService) {
this.config.entityType = EntityType.NOTIFICATION; this.config.entityType = EntityType.NOTIFICATION;
this.config.detailsPanelEnabled = false; this.config.detailsPanelEnabled = false;
@ -92,8 +94,10 @@ export class InboxTableConfigResolver implements Resolve<EntityTableConfig<Notif
new DateEntityTableColumn<Notification>('createdTime', 'common.created-time', this.datePipe, '170px'), new DateEntityTableColumn<Notification>('createdTime', 'common.created-time', this.datePipe, '170px'),
new EntityTableColumn<Notification>('type', 'notification.type', '10%', (notification) => new EntityTableColumn<Notification>('type', 'notification.type', '10%', (notification) =>
this.translate.instant(NotificationTemplateTypeTranslateMap.get(notification.type).name)), this.translate.instant(NotificationTemplateTypeTranslateMap.get(notification.type).name)),
new EntityTableColumn<Notification>('subject', 'notification.subject', '30%'), new EntityTableColumn<Notification>('subject', 'notification.subject', '30%',
new EntityTableColumn<Notification>('text', 'notification.message', '60%') (entity) => this.utilsService.customTranslation(entity.subject, entity.subject)),
new EntityTableColumn<Notification>('text', 'notification.message', '60%',
(entity) => this.utilsService.customTranslation(entity.text, entity.text))
); );
} }