From abea40707ee7b215682643a031633041b8c5f85a Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 24 Oct 2023 18:09:35 +0300 Subject: [PATCH] DM-535 - Components without references not displayed in Component View --- ...component-management-dialog.component.html | 2 +- ...d-component-management-dialog.component.ts | 20 ++++++++++++++++++- .../file-preview-screen.component.html | 2 +- .../file-preview-screen.component.ts | 10 +++++----- .../services/file-preview-dialog.service.ts | 11 ++++++++-- .../src/lib/component-log/component-value.ts | 1 + 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html index 96d905189..bee5aae90 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.html @@ -49,7 +49,7 @@ 'component-log-dialog.annotations' | translate : { - type: parseType(reference.type), + type: parseType(reference.displayValue), page: reference.page, ruleNumber: reference.entityRuleId } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.ts index bbc9e6be8..9e3f99c15 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/structured-component-management-dialog/structured-component-management-dialog.component.ts @@ -5,7 +5,7 @@ import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/materia import { ReplaceNbspPipe } from '@common-ui/pipes/replace-nbsp.pipe'; import { BaseDialogComponent, CircleButtonComponent, EditableInputComponent, IconButtonComponent } from '@iqser/common-ui'; import { TranslateModule } from '@ngx-translate/core'; -import { ComponentLogEntry, IFile, WorkflowFileStatuses } from '@red/domain'; +import { ComponentLogEntry, Dictionary, IFile, WorkflowFileStatuses } from '@red/domain'; import { FilesMapService } from '@services/files/files-map.service'; import { UserPreferenceService } from '@users/user-preference.service'; import { firstValueFrom } from 'rxjs'; @@ -13,6 +13,7 @@ import { ComponentLogService } from '@services/files/component-log.service'; interface ScmData { file: IFile; + dictionaries: Dictionary[]; } @Component({ @@ -130,7 +131,24 @@ export class StructuredComponentManagementDialogComponent extends BaseDialogComp this.data.file.fileId, ), ); + this.#updateDisplayValue(componentLogData); this.componentLogData.set(componentLogData); this._loadingService.stop(); } + + #updateDisplayValue(componentLogs: ComponentLogEntry[]) { + const dictionaries = this.data.dictionaries; + for (const componentLog of componentLogs) { + let foundDictionary: Dictionary; + for (const reference of componentLog.componentValues[0].entityReferences) { + if (foundDictionary) { + reference.displayValue = foundDictionary.label; + continue; + } + foundDictionary = dictionaries.find(dict => dict.type === reference.type); + foundDictionary = foundDictionary ?? ({ label: reference.type } as Dictionary); + reference.displayValue = foundDictionary.label; + } + } + } } diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html index 95e81f8de..20c8396e4 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html @@ -24,7 +24,7 @@ { @@ -34,7 +41,7 @@ export class FilePreviewDialogService extends DialogService { highlightAction: { component: HighlightActionDialogComponent, }, - rss: { + componentLog: { component: StructuredComponentManagementDialogComponent, dialogConfig: { width: '90vw' }, }, diff --git a/libs/red-domain/src/lib/component-log/component-value.ts b/libs/red-domain/src/lib/component-log/component-value.ts index ec00cf67f..e9d680f29 100644 --- a/libs/red-domain/src/lib/component-log/component-value.ts +++ b/libs/red-domain/src/lib/component-log/component-value.ts @@ -3,6 +3,7 @@ export interface EntityReference { readonly type: string; readonly entityRuleId: string; readonly page: number; + displayValue?: string; } export interface IComponentValue {