adjusted to new search and missing dossier status

This commit is contained in:
Timo Bejan 2022-03-21 13:53:34 +02:00
parent 3154d0c1c4
commit 1a122ceea3
11 changed files with 29 additions and 34 deletions

View File

@ -17,7 +17,7 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { workflowFileStatusTranslations } from '../../../translations/file-status-translations';
import { TranslateService } from '@ngx-translate/core';
import { RouterHistoryService } from '@services/router-history.service';
import { Dossier, DossierStatuses, IMatchedDocument, ISearchListItem, ISearchResponse } from '@red/domain';
import { Dossier, IMatchedDocument, ISearchListItem, ISearchResponse } from '@red/domain';
import { FilesMapService } from '@services/entity-services/files-map.service';
import { PlatformSearchService } from '@services/entity-services/platform-search.service';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
@ -51,7 +51,8 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
this._platformSearchService.search({
query,
dossierIds,
dossierStatus: onlyActive ? [] : [DossierStatuses.ACTIVE, DossierStatuses.ARCHIVED],
inDeletedDossiers: false,
inArchivedDossiers: !onlyActive,
}),
),
map(searchResult => this._toMatchedDocuments(searchResult)),
@ -154,20 +155,27 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
return matchedDocuments.map(document => this._toListItem(document)).filter(value => value);
}
private _toListItem({ dossierId, fileId, unmatchedTerms, highlights, score, dossierStatus }: IMatchedDocument): ISearchListItem {
private _toListItem({
dossierId,
fileId,
unmatchedTerms,
highlights,
score,
dossierDeleted,
dossierArchived,
}: IMatchedDocument): ISearchListItem {
const file = this._filesMapService.get(dossierId, fileId);
if (!file) {
return undefined;
}
const dossier = (dossierStatus === DossierStatuses.ARCHIVED ? this._archivedDossiersService : this._activeDossiersService).find(
dossierId,
);
const dossier = (dossierArchived ? this._archivedDossiersService : this._activeDossiersService).find(dossierId);
return {
id: fileId,
dossierId,
dossierStatus,
deleted: dossierDeleted,
archived: dossierArchived,
unmatched: unmatchedTerms || null,
highlights,
status: file.workflowStatus,

View File

@ -21,7 +21,7 @@ export class PlatformSearchService extends GenericService<ISearchResponse> {
super(_injector, 'search-v2');
}
search({ dossierIds, query, dossierStatus }: ISearchInput): Observable<ISearchResponse> {
search({ dossierIds, query, inDeletedDossiers, inArchivedDossiers }: ISearchInput): Observable<ISearchResponse> {
if (!query) {
return of({
matchedDocuments: [],
@ -35,7 +35,8 @@ export class PlatformSearchService extends GenericService<ISearchResponse> {
page: 0,
returnSections: false,
pageSize: 300,
dossierStatus,
inDeletedDossiers,
inArchivedDossiers,
};
return this._post(body).pipe(switchMap(searchValue => this._loadMissingFiles$(searchValue)));

View File

@ -1,6 +1,5 @@
import { IListable, IRouterPath, List } from '@iqser/common-ui';
import { IDossier } from './dossier';
import { DossierStatus, DossierStatuses } from './types';
import { DownloadFileType } from '../shared';
export class Dossier implements IDossier, IListable, IRouterPath {
@ -19,7 +18,6 @@ export class Dossier implements IDossier, IListable, IRouterPath {
readonly hardDeletedTime?: string;
readonly softDeletedTime?: string;
readonly startDate?: string;
readonly status: DossierStatus;
readonly watermarkEnabled: boolean;
readonly watermarkPreviewEnabled: boolean;
readonly archivedTime: string;
@ -41,7 +39,6 @@ export class Dossier implements IDossier, IListable, IRouterPath {
this.reportTemplateIds = dossier.reportTemplateIds;
this.softDeletedTime = dossier.softDeletedTime;
this.startDate = dossier.startDate;
this.status = dossier.status;
this.watermarkEnabled = dossier.watermarkEnabled;
this.watermarkPreviewEnabled = dossier.watermarkPreviewEnabled;
this.archivedTime = dossier.archivedTime;
@ -61,11 +58,11 @@ export class Dossier implements IDossier, IListable, IRouterPath {
}
get isActive(): boolean {
return this.status === DossierStatuses.ACTIVE;
return this.softDeletedTime == null && this.archivedTime == null;
}
get isSoftDeleted(): boolean {
return this.status === DossierStatuses.DELETED;
return this.softDeletedTime !== null;
}
hasMember(memberId: string): boolean {

View File

@ -1,4 +1,3 @@
import { DossierStatus } from './types';
import { DownloadFileType } from '../shared';
import { List } from '@iqser/common-ui';
@ -18,7 +17,6 @@ export interface IDossier {
readonly reportTemplateIds: List;
readonly softDeletedTime?: string;
readonly startDate?: string;
readonly status: DossierStatus;
readonly watermarkEnabled: boolean;
readonly watermarkPreviewEnabled: boolean;
readonly archivedTime: string;

View File

@ -1,5 +1,4 @@
export * from './dossier';
export * from './dossier.request';
export * from './dossier.model';
export * from './types';
export * from './dossier-changes';

View File

@ -1,7 +0,0 @@
export const DossierStatuses = {
ACTIVE: 'ACTIVE',
DELETED: 'DELETED',
ARCHIVED: 'ARCHIVED',
} as const;
export type DossierStatus = keyof typeof DossierStatuses;

View File

@ -1,12 +1,12 @@
import { IMatchedSection } from './matched-section';
import { List } from '@iqser/common-ui';
import { DossierStatus } from '../dossiers';
export interface IMatchedDocument {
containsAllMatchedSections?: boolean;
dossierId?: string;
dossierTemplateId?: string;
dossierStatus?: DossierStatus;
dossierDeleted?: boolean;
dossierArchived?: boolean;
fileId?: string;
highlights?: { [key: string]: List };
matchedSections?: List<IMatchedSection>;

View File

@ -1,8 +1,8 @@
import { List } from '@iqser/common-ui';
import { DossierStatus } from '../dossiers';
export interface ISearchInput {
readonly query: string;
readonly dossierIds?: List;
readonly dossierStatus?: List<DossierStatus>;
readonly inDeletedDossiers: boolean;
readonly inArchivedDossiers: boolean;
}

View File

@ -1,15 +1,15 @@
import { IListable, List } from '@iqser/common-ui';
import { DossierStatus } from '../dossiers';
export interface ISearchListItem extends IListable {
readonly dossierId: string;
readonly dossierStatus: DossierStatus;
readonly filename: string;
readonly assignee: string;
readonly unmatched: List | null;
readonly highlights: Record<string, List>;
readonly routerLink: string;
readonly status: string;
readonly deleted: boolean;
readonly archived: boolean;
readonly dossierName: string;
readonly numberOfPages: number;
}

View File

@ -1,10 +1,10 @@
import { List } from '@iqser/common-ui';
import { DossierStatus } from '../dossiers';
export interface ISearchRequest {
readonly dossierIds?: List;
readonly dossierTemplateIds?: List;
readonly dossierStatus?: List<DossierStatus>;
readonly inDeletedDossiers: boolean;
readonly inArchivedDossiers: boolean;
readonly fileId?: string;
readonly page?: number;
readonly pageSize?: number;

View File

@ -1,4 +1,3 @@
import { DossierStatus } from '../dossiers';
import { WorkflowFileStatus } from '../files';
export type Color = WorkflowFileStatus | DossierStatus | string;
export type Color = WorkflowFileStatus | string;