filter entries without positions

This commit is contained in:
Dan Percic 2024-03-07 15:22:57 +02:00
parent 8ba4721828
commit 843dcde601
2 changed files with 18 additions and 4 deletions

View File

@ -1,13 +1,15 @@
import { Injectable } from '@angular/core';
import { GenericService, QueryParam } from '@iqser/common-ui';
import { inject, Injectable } from '@angular/core';
import { GenericService, isIqserDevMode, QueryParam, Toaster } from '@iqser/common-ui';
import { IRedactionLog, ISectionGrid } from '@red/domain';
import { catchError } from 'rxjs/operators';
import { firstValueFrom, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
export class RedactionLogService extends GenericService<unknown> {
readonly #isIqserDevMode = isIqserDevMode();
readonly #toaster = inject(Toaster);
protected readonly _defaultModelPath = '';
async getRedactionLog(dossierId: string, fileId: string, withManualRedactions?: boolean) {
@ -18,6 +20,18 @@ export class RedactionLogService extends GenericService<unknown> {
const redactionLog$ = this._getOne<IRedactionLog>([dossierId, fileId], 'redactionLog', queryParams);
const redactionLog = await firstValueFrom(redactionLog$.pipe(catchError(() => of({} as IRedactionLog))));
redactionLog.redactionLogEntry = redactionLog.redactionLogEntry.filter(entry => {
const hasPositions = entry.positions && entry.positions.length;
if (!hasPositions && this.#isIqserDevMode) {
this.#toaster.info(`Entry ${entry.id} was skipped because has no positions`, {
timeOut: 10000,
easing: 'ease-in-out',
easeTime: 500,
useRaw: true,
});
}
return hasPositions;
});
redactionLog.redactionLogEntry.sort((a, b) => a.positions[0].page - b.positions[0].page);
return redactionLog;
}

@ -1 +1 @@
Subproject commit 3776e8ecefba36b39c47567f86b451f5440e75f7
Subproject commit 1610a4c3a59ab6669cd96a02f2c68d5b0e5dcfd9