RED-8711 - Filter out entity log entries that have no positions and show a toast message in dev mode
This commit is contained in:
parent
ef33f22c86
commit
c12cdddeb5
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { GenericService, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { IRedactionLog, ISectionGrid } from '@red/domain';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { GenericService, QueryParam, RequiredParam, Toaster, Validate } from '@iqser/common-ui';
|
||||
import { IRedactionLog, IRedactionLogEntry, ISectionGrid } from '@red/domain';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
@ -9,6 +9,7 @@ import { of } from 'rxjs';
|
||||
})
|
||||
export class RedactionLogService extends GenericService<unknown> {
|
||||
protected readonly _defaultModelPath = '';
|
||||
readonly #toaster = inject(Toaster);
|
||||
|
||||
@Validate()
|
||||
getRedactionLog(@RequiredParam() dossierId: string, @RequiredParam() fileId: string, withManualRedactions?: boolean) {
|
||||
@ -19,6 +20,7 @@ export class RedactionLogService extends GenericService<unknown> {
|
||||
|
||||
const redactionLog$ = this._getOne<IRedactionLog>([dossierId, fileId], 'redactionLog', queryParams);
|
||||
return redactionLog$.pipe(
|
||||
tap(redactionLog => (redactionLog.redactionLogEntry = this.#filterInvalidEntries(redactionLog.redactionLogEntry))),
|
||||
tap(redactionLog => redactionLog.redactionLogEntry.sort((a, b) => a.positions[0].page - b.positions[0].page)),
|
||||
catchError(() => of({} as IRedactionLog)),
|
||||
);
|
||||
@ -28,4 +30,14 @@ export class RedactionLogService extends GenericService<unknown> {
|
||||
getSectionGrid(@RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._getOne<ISectionGrid>([dossierId, fileId], 'sectionGrid');
|
||||
}
|
||||
|
||||
#filterInvalidEntries(redactionLogEntry: IRedactionLogEntry[]) {
|
||||
return redactionLogEntry.filter(entry => {
|
||||
const hasPositions = !!entry.positions?.length;
|
||||
if (!hasPositions) {
|
||||
this.#toaster.devInfo(`Entry ${entry.id} was skipped because it has no position`);
|
||||
}
|
||||
return hasPositions;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit d6f712232942f41a47d652cfb6dabc9d6b1694c7
|
||||
Subproject commit 8b304a7279bf5f15b86a0b8e6c5041406cbfbf1b
|
||||
Loading…
x
Reference in New Issue
Block a user