diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 02b9fc014..3d01d5803 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -13,6 +13,8 @@ export class AnnotationData { } export class FileDataModel { + hasChangeLog: boolean; + constructor(public file: File, public fileData: Blob, public redactionLog: RedactionLog, public viewedPages?: ViewedPages) {} getAnnotations( @@ -56,10 +58,7 @@ export class FileDataModel { Object.assign(redactionLogEntryWrapper, redactionLogEntry); redactionLogEntryWrapper.type = redactionLogEntry.type; - redactionLogEntryWrapper.isChangeLogEntry = this._isChangeLogEntry(redactionLogEntry); - // redactionLogEntryWrapper.changeLogType = changeLogEntry.changeType; - // redactionLogEntryWrapper.isChangeLogEntry = !!existingChangeLogEntry; - redactionLogEntryWrapper.changeLogType = 'ADDED'; + this._isChangeLogEntry(redactionLogEntry, redactionLogEntryWrapper); if ( redactionLogEntryWrapper.status === 'DECLINED' && @@ -98,23 +97,42 @@ export class FileDataModel { redactionLogEntry.legalBasisList = this.redactionLog.legalBasis; }); + result = result.filter(r => !r.hidden); + return result; } - get hasChangeLog() { - // TODO DELTA VIEW - return false; - } - - private _isChangeLogEntry(redactionLogEntry: RedactionLogEntry) { + private _isChangeLogEntry(redactionLogEntry: RedactionLogEntry, wrapper: RedactionLogEntryWrapper) { redactionLogEntry.changes.sort((a, b) => moment(a.dateTime).date() - moment(b.dateTime).date()); - // - // relevantChanges = redactionLogEntry.changes.filter(moment(change.dateTime).date() > ); - // - // lastSeenState = redactionLogEntry.changes.indexOf(relevantChanges[0]-1); - // - // - // if(redactionLogEntry.) - return false; + + const lastChange = + redactionLogEntry.changes.length >= 1 ? redactionLogEntry.changes[redactionLogEntry.changes.length - 1] : undefined; + const page = redactionLogEntry.positions?.[0].page; + const viewTime = this.viewedPages.pages + .filter(p => p.page === page) + .map(p => moment(p.viewedTime)) + .pop(); + + // page has been seen -> let's see if it's a change + if (viewTime) { + // these are all unseen changes + const relevantChanges = redactionLogEntry.changes.filter(change => moment(change.dateTime).date() > viewTime.date()); + console.log(viewTime.date(), relevantChanges, redactionLogEntry.positions[0].page); + // at least one unseen change + if (relevantChanges.length > 0) { + wrapper.changeLogType = relevantChanges[relevantChanges.length - 1].type; + wrapper.isChangeLogEntry = true; + this.hasChangeLog = true; + } else { + // no relevant changes - hide removed anyway + wrapper.isChangeLogEntry = false; + wrapper.hidden = lastChange && lastChange.type === 'REMOVED'; + } + } else { + // Page doesn't have a view-time + wrapper.isChangeLogEntry = false; + wrapper.hidden = lastChange && lastChange.type === 'REMOVED'; + } + // console.log(wrapper.changeLogType, wrapper.hidden, wrapper.isChangeLogEntry, wrapper.value, lastChange); } } diff --git a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotations-list/annotations-list.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotations-list/annotations-list.component.ts index bd0859d21..a09b7aba9 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotations-list/annotations-list.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-workload/components/annotations-list/annotations-list.component.ts @@ -24,6 +24,7 @@ export class AnnotationsListComponent { @Output() readonly deselectAnnotations = new EventEmitter(); annotationClicked(annotation: AnnotationWrapper, $event: MouseEvent): void { + console.log(annotation); if (($event.target as IqserEventTarget).localName === 'input') { return; } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 3ea6fd6a6..c4b0a10e0 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -571,6 +571,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this.addSubscription = timer(0, 5000).subscribe(async () => this.appStateService.reloadActiveFile()); this.addSubscription = this.appStateService.fileReanalysed$.subscribe(async (file: File) => { if (file.fileId === this.fileId) { + console.log('file', file); await this._loadFileData(!this._reloadFileOnReanalysis); this._reloadFileOnReanalysis = false; this._loadingService.stop(); @@ -593,6 +594,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni if (!fileData.file?.isPending && !fileData.file?.isError) { if (performUpdate) { this.fileData.redactionLog = fileData.redactionLog; + this.fileData.viewedPages = fileData.viewedPages; this.fileData.file = fileData.file; this.rebuildFilters(true); } else {