RED-5551: when a type is missing reload dictionaries first
This commit is contained in:
parent
350c11b4c8
commit
bc7d44f457
@ -17,8 +17,6 @@ import {
|
||||
AutoUnsubscribe,
|
||||
bool,
|
||||
CircleButtonTypes,
|
||||
ConfirmationDialogInput,
|
||||
ConfirmOptions,
|
||||
CustomError,
|
||||
Debounce,
|
||||
ErrorService,
|
||||
@ -26,6 +24,7 @@ import {
|
||||
HelpModeService,
|
||||
List,
|
||||
LoadingService,
|
||||
log,
|
||||
NestedFilter,
|
||||
OnAttach,
|
||||
OnDetach,
|
||||
@ -90,7 +89,10 @@ export class FilePreviewScreenComponent
|
||||
fullScreen = false;
|
||||
readonly fileId = this.state.fileId;
|
||||
readonly dossierId = this.state.dossierId;
|
||||
readonly file$ = this.state.file$.pipe(tap(file => this._fileDataService.loadAnnotations(file)));
|
||||
readonly file$ = this.state.file$.pipe(
|
||||
tap(file => this._fileDataService.loadAnnotations(file)),
|
||||
log('file'),
|
||||
);
|
||||
width: number;
|
||||
@ViewChild('annotationFilterTemplate', {
|
||||
read: TemplateRef,
|
||||
|
||||
@ -6,7 +6,6 @@ import { Injectable } from '@angular/core';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
import { ViewedPagesService } from '@services/files/viewed-pages.service';
|
||||
import { UserPreferenceService } from '@users/user-preference.service';
|
||||
import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service';
|
||||
import { map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
@ -19,7 +18,7 @@ import { NGXLogger } from 'ngx-logger';
|
||||
import { MultiSelectService } from './multi-select.service';
|
||||
import { FilesService } from '@services/files/files.service';
|
||||
import { DefaultColorsService } from '@services/entity-services/default-colors.service';
|
||||
import { DossierDictionariesMapService } from '@services/entity-services/dossier-dictionaries-map.service';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
|
||||
const DELTA_VIEW_TIME = 10 * 60 * 1000; // 10 minutes;
|
||||
|
||||
@ -39,8 +38,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
private readonly _viewedPagesService: ViewedPagesService,
|
||||
private readonly _viewModeService: ViewModeService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
private readonly _dossierDictionariesMapService: DossierDictionariesMapService,
|
||||
private readonly _dictionaryService: DictionaryService,
|
||||
private readonly _permissionsService: PermissionsService,
|
||||
private readonly _redactionLogService: RedactionLogService,
|
||||
private readonly _earmarksService: EarmarksService,
|
||||
@ -73,12 +71,8 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
|
||||
get #annotations$() {
|
||||
return this.#redactionLog$.pipe(
|
||||
withLatestFrom(
|
||||
this._state.file$,
|
||||
this._dictionariesMapService.get$(this._state.dossierTemplateId),
|
||||
this._dossierDictionariesMapService.get$(this._state.dossierId),
|
||||
),
|
||||
map(([redactionLog, file]) => this.#buildAnnotations(redactionLog, file)),
|
||||
withLatestFrom(this._state.file$),
|
||||
switchMap(([redactionLog, file]) => this.#buildAnnotations(redactionLog, file)),
|
||||
tap(() => this.#checkMissingTypes()),
|
||||
map(annotations =>
|
||||
this._userPreferenceService.areDevFeaturesEnabled ? annotations : annotations.filter(a => !a.isFalsePositive),
|
||||
@ -172,8 +166,8 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
});
|
||||
}
|
||||
|
||||
#buildAnnotations(redactionLog: IRedactionLog, file: File) {
|
||||
const entries: RedactionLogEntry[] = this.#convertData(redactionLog, file);
|
||||
async #buildAnnotations(redactionLog: IRedactionLog, file: File) {
|
||||
const entries = await this.#convertData(redactionLog, file);
|
||||
const annotations = entries.map(entry =>
|
||||
AnnotationWrapper.fromData(entry, this._state.dictionaries, this._defaultColorsService.find(this._state.dossierTemplateId)),
|
||||
);
|
||||
@ -181,20 +175,28 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
return annotations.filter(ann => ann.manual || !file.excludedPages.includes(ann.pageNumber));
|
||||
}
|
||||
|
||||
#convertData(redactionLog: IRedactionLog, file: File): RedactionLogEntry[] {
|
||||
async #convertData(redactionLog: IRedactionLog, file: File) {
|
||||
const result: RedactionLogEntry[] = [];
|
||||
const sourceIdAnnotationIds: { [key: string]: RedactionLogEntry[] } = {};
|
||||
let checkDictionary = true;
|
||||
|
||||
redactionLog.redactionLogEntry?.forEach(redactionLogEntry => {
|
||||
for (const redactionLogEntry of redactionLog.redactionLogEntry) {
|
||||
const changeLogValues = this.#getChangeLogValues(redactionLogEntry, file);
|
||||
if (changeLogValues.hidden) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
let dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type);
|
||||
if (!dictionary && checkDictionary) {
|
||||
const dictionaryRequest = this._dictionaryService.loadDictionaryDataForDossierTemplate(this._state.dossierTemplateId);
|
||||
await firstValueFrom(dictionaryRequest);
|
||||
checkDictionary = false;
|
||||
dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type);
|
||||
}
|
||||
|
||||
const dictionary = this._state.dictionaries.find(dict => dict.type === redactionLogEntry.type);
|
||||
if (!dictionary) {
|
||||
this.missingTypes.add(redactionLogEntry.type);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const redactionLogEntryWrapper: RedactionLogEntry = new RedactionLogEntry(
|
||||
@ -213,7 +215,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
}
|
||||
|
||||
result.push(redactionLogEntryWrapper);
|
||||
});
|
||||
}
|
||||
|
||||
const sourceKeys = Object.keys(sourceIdAnnotationIds);
|
||||
return result.filter(r => !sourceKeys.includes(r.id));
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit c744c738451af53ca665b97cc99534bede42a7d4
|
||||
Subproject commit c2aa517cb7e92b989355a69de26fe50084a66301
|
||||
Loading…
x
Reference in New Issue
Block a user