remove files from dossier ctor
This commit is contained in:
parent
fc05e3bd42
commit
15bf3c8eaa
@ -5,7 +5,7 @@ import { Dossier, File } from '@red/domain';
|
||||
import { FileActionService } from '../../../../shared/services/file-action.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
|
||||
import { CircleButtonTypes, ConfirmationDialogInput, ListingService, LoadingService } from '@iqser/common-ui';
|
||||
import { CircleButtonTypes, ConfirmationDialogInput, EntitiesService, ListingService, LoadingService } from '@iqser/common-ui';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
@ -35,6 +35,7 @@ export class DossierOverviewBulkActionsComponent {
|
||||
private readonly _fileActionService: FileActionService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _entitiesService: EntitiesService<File>,
|
||||
private readonly _listingService: ListingService<File>,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
) {}
|
||||
@ -44,7 +45,8 @@ export class DossierOverviewBulkActionsComponent {
|
||||
}
|
||||
|
||||
get areAllFilesSelected() {
|
||||
return this.dossier.files.length !== 0 && this.selectedFiles.length === this.dossier.files.length;
|
||||
const allFilesCount = this._entitiesService.all.length;
|
||||
return allFilesCount !== 0 && this.selectedFiles.length === allFilesCount;
|
||||
}
|
||||
|
||||
get areSomeFilesSelected() {
|
||||
|
||||
@ -109,6 +109,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
activatedRoute: ActivatedRoute,
|
||||
) {
|
||||
super(_injector);
|
||||
this._appStateService.reset();
|
||||
this.dossierId = activatedRoute.snapshot.paramMap.get('dossierId');
|
||||
this.actionConfigs = this._configService.actionConfig(this.dossierId);
|
||||
this.dossier$ = this._dossiersService.getEntityChanged$(this.dossierId);
|
||||
@ -311,7 +312,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
}
|
||||
|
||||
private async _uploadFiles(files: FileUploadModel[]) {
|
||||
const fileCount = await this._fileUploadService.uploadFiles(files);
|
||||
const fileCount = await this._fileUploadService.uploadFiles(files, this.dossierId);
|
||||
if (fileCount) {
|
||||
this._statusOverlayService.openUploadStatusOverlay();
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<iqser-status-bar [configs]="statusConfig"></iqser-status-bar>
|
||||
<iqser-status-bar *ngIf="dossier.stats$ | async as stats" [configs]="statusConfig(stats)"></iqser-status-bar>
|
||||
|
||||
<div (longPress)="forceReanalysisAction($event)" class="action-buttons" redactionLongPress>
|
||||
<iqser-circle-button
|
||||
(action)="openEditDossierDialog($event, dossier.dossierId)"
|
||||
@ -16,5 +17,9 @@
|
||||
icon="iqser:refresh"
|
||||
></iqser-circle-button>
|
||||
|
||||
<redaction-file-download-btn [dossier]="dossier" [files]="dossier.files" [type]="circleButtonTypes.dark"></redaction-file-download-btn>
|
||||
<redaction-file-download-btn
|
||||
[dossier]="dossier"
|
||||
[files]="filesMapService.get(dossier.id)"
|
||||
[type]="circleButtonTypes.dark"
|
||||
></redaction-file-download-btn>
|
||||
</div>
|
||||
|
||||
@ -3,10 +3,11 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { CircleButtonTypes, StatusBarConfig } from '@iqser/common-ui';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { Dossier, StatusSorter } from '@red/domain';
|
||||
import { Dossier, DossierStats, StatusSorter } from '@red/domain';
|
||||
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
|
||||
import { LongPressEvent } from '@shared/directives/long-press.directive';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossiers-listing-actions',
|
||||
@ -24,31 +25,18 @@ export class DossiersListingActionsComponent {
|
||||
@Output() readonly actionPerformed = new EventEmitter<Dossier | undefined>();
|
||||
|
||||
constructor(
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly appStateService: AppStateService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _userService: UserService,
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly filesMapService: FilesMapService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
) {}
|
||||
|
||||
get statusConfig(): readonly StatusBarConfig<string>[] {
|
||||
if (!this.dossier) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const obj = this.dossier.files.reduce((acc, file) => {
|
||||
const status = file.status;
|
||||
if (!acc[status]) {
|
||||
acc[status] = 1;
|
||||
} else {
|
||||
acc[status]++;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return Object.keys(obj)
|
||||
statusConfig(stats: DossierStats): readonly StatusBarConfig<string>[] {
|
||||
return Object.keys(stats.fileCountPerWorkflowStatus)
|
||||
.sort(StatusSorter.byStatus)
|
||||
.map(status => ({ length: obj[status], color: status }));
|
||||
.map(status => ({ length: stats.fileCountPerWorkflowStatus[status], color: status }));
|
||||
}
|
||||
|
||||
forceReanalysisAction($event: LongPressEvent) {
|
||||
|
||||
@ -63,6 +63,7 @@ export class DossiersListingScreenComponent
|
||||
private readonly _filesService: FilesService,
|
||||
) {
|
||||
super(_injector);
|
||||
this._appStateService.reset();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
@ -21,6 +21,7 @@ import { RouterHistoryService } from '@services/router-history.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { PlatformSearchService } from '../../shared/services/platform-search.service';
|
||||
import { Dossier, IMatchedDocument, ISearchInput, ISearchListItem, ISearchResponse } from '@red/domain';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
|
||||
function toSearchInput(query: string, dossierIds: List | string): ISearchInput {
|
||||
return {
|
||||
@ -66,6 +67,7 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
|
||||
private readonly _dossiersService: DossiersService,
|
||||
readonly routerHistoryService: RouterHistoryService,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _filesMapService: FilesMapService,
|
||||
private readonly _platformSearchService: PlatformSearchService,
|
||||
) {
|
||||
super(_injector);
|
||||
@ -127,7 +129,7 @@ export class SearchScreenComponent extends ListingComponent<ISearchListItem> imp
|
||||
}
|
||||
|
||||
private _toListItem({ dossierId, fileId, unmatchedTerms, highlights, score }: IMatchedDocument): ISearchListItem {
|
||||
const file = this._dossiersService.find(dossierId, fileId);
|
||||
const file = this._filesMapService.get(dossierId, fileId);
|
||||
if (!file) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -35,9 +35,7 @@ export class FileDropComponent {
|
||||
|
||||
@HostListener('drop', ['$event'])
|
||||
onDrop(event: DragEvent) {
|
||||
const dossierId = this._activatedRoute.snapshot.paramMap.get('dossierId');
|
||||
console.log(dossierId);
|
||||
handleFileDrop(event, this._dossiersService.find(dossierId), this.uploadFiles.bind(this));
|
||||
handleFileDrop(event, this._dossiersService.activeDossier, this.uploadFiles.bind(this));
|
||||
}
|
||||
|
||||
@HostListener('dragover', ['$event'])
|
||||
@ -47,7 +45,7 @@ export class FileDropComponent {
|
||||
}
|
||||
|
||||
async uploadFiles(files: FileUploadModel[]) {
|
||||
const fileCount = await this._fileUploadService.uploadFiles(files);
|
||||
const fileCount = await this._fileUploadService.uploadFiles(files, this._dossiersService.activeDossierId);
|
||||
if (fileCount) {
|
||||
this._statusOverlayService.openUploadStatusOverlay();
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import { UploadDownloadDialogService } from './upload-download-dialog.service';
|
||||
import { IFileUploadResult } from '@red/domain';
|
||||
import { isCsv } from '@utils/file-drop-utils';
|
||||
import { ErrorMessageService, GenericService, HeadersConfiguration, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
|
||||
export interface ActiveUpload {
|
||||
subscription: Subscription;
|
||||
@ -28,7 +28,7 @@ export class FileUploadService extends GenericService<IFileUploadResult> {
|
||||
|
||||
constructor(
|
||||
private readonly _appStateService: AppStateService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _filesMapService: FilesMapService,
|
||||
private readonly _applicationRef: ApplicationRef,
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _configService: ConfigService,
|
||||
@ -55,10 +55,10 @@ export class FileUploadService extends GenericService<IFileUploadResult> {
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFiles(files: FileUploadModel[]): Promise<number> {
|
||||
async uploadFiles(files: FileUploadModel[], dossierId?: string): Promise<number> {
|
||||
const maxSizeMB = this._configService.values.MAX_FILE_SIZE_MB;
|
||||
const maxSizeBytes = maxSizeMB * 1024 * 1024;
|
||||
const dossierFiles = this._dossiersService.activeDossier.files;
|
||||
const dossierFiles = this._filesMapService.get(dossierId);
|
||||
let option: 'overwrite' | 'skip';
|
||||
for (let idx = 0; idx < files.length; ++idx) {
|
||||
const file = files[idx];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { EntitiesService, List, QueryParam, RequiredParam, shareLast, Toaster, Validate } from '@iqser/common-ui';
|
||||
import { Dossier, File, IDossier, IDossierRequest } from '@red/domain';
|
||||
import { Dossier, IDossier, IDossierRequest } from '@red/domain';
|
||||
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { BehaviorSubject, combineLatest, Observable, of, throwError } from 'rxjs';
|
||||
import { ActivationEnd, Router } from '@angular/router';
|
||||
@ -58,10 +58,6 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
});
|
||||
}
|
||||
|
||||
get allFiles(): File[] {
|
||||
return this.all.reduce((acc: File[], { files }) => [...acc, ...files], []);
|
||||
}
|
||||
|
||||
get activeDossier(): Dossier | undefined {
|
||||
return this._activeDossier$.value;
|
||||
}
|
||||
@ -70,13 +66,6 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
return this._activeDossier$.value?.dossierId;
|
||||
}
|
||||
|
||||
find(dossierId: string): Dossier | undefined;
|
||||
find(dossierId: string, fileId: string): File | undefined;
|
||||
find(dossierId: string, fileId?: string): Dossier | File | undefined {
|
||||
const dossier = super.find(dossierId);
|
||||
return fileId ? dossier?.files.find(file => file.fileId === fileId) : dossier;
|
||||
}
|
||||
|
||||
replace(newDossier: Dossier) {
|
||||
super.replace(newDossier);
|
||||
if (newDossier.dossierId === this.activeDossierId) {
|
||||
@ -105,7 +94,7 @@ export class DossiersService extends EntitiesService<Dossier, IDossier> {
|
||||
const stats$ = dossier$.pipe(switchMap(updatedDossier => this._dossierStatsService.getFor([updatedDossier.dossierId])));
|
||||
|
||||
return combineLatest([dossier$, stats$]).pipe(
|
||||
map(([updatedDossier, stats]) => new Dossier(updatedDossier, stats[0], [])),
|
||||
map(([updatedDossier, stats]) => new Dossier(updatedDossier, stats[0])),
|
||||
tap(newDossier => this.replace(newDossier)),
|
||||
catchError(showToast),
|
||||
);
|
||||
|
||||
@ -20,12 +20,12 @@ export class FilesMapService {
|
||||
return this._map.has(dossierId);
|
||||
}
|
||||
|
||||
get(key: string): File[] | undefined;
|
||||
get(key: string): File[];
|
||||
get(key: string, id: string): File | undefined;
|
||||
get(key: string, id?: string): File | File[] | undefined {
|
||||
const value = this._map.get(key)?.value;
|
||||
if (!id) {
|
||||
return value;
|
||||
return value ?? [];
|
||||
}
|
||||
return value?.find(item => item.id === id);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import { notificationsTranslations } from '../translations/notifications-transla
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@ -19,6 +20,7 @@ export class NotificationsService extends GenericService<unknown> {
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _userService: UserService,
|
||||
private readonly _filesMapService: FilesMapService,
|
||||
) {
|
||||
super(_injector, 'notification');
|
||||
}
|
||||
@ -61,7 +63,8 @@ export class NotificationsService extends GenericService<unknown> {
|
||||
const fileId = notification.target.fileId;
|
||||
const dossierId = notification.target.dossierId;
|
||||
const dossier = this._dossiersService.find(dossierId);
|
||||
const file = dossier?.files?.find(f => f.fileId === fileId);
|
||||
const files = this._filesMapService.get(dossierId);
|
||||
const file = files?.find(f => f.fileId === fileId);
|
||||
|
||||
return this._translateService.instant(translation, {
|
||||
fileHref: file?.routerLink,
|
||||
|
||||
@ -87,6 +87,9 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
get activeFile(): File | undefined {
|
||||
if (!this.activeFileId) {
|
||||
return;
|
||||
}
|
||||
return this._filesMapService.get(this._dossiersService.activeDossierId, this.activeFileId);
|
||||
}
|
||||
|
||||
@ -135,8 +138,7 @@ export class AppStateService {
|
||||
const oldDossier = this._dossiersService.find(p.dossierId);
|
||||
const type = oldDossier?.type ?? (await this._getDictionaryFor(p));
|
||||
const stats = dossierStats.find(s => s.dossierId === p.dossierId);
|
||||
console.log(stats);
|
||||
this._dossiersService.replace(new Dossier(p, stats, [], type));
|
||||
this._dossiersService.replace(new Dossier(p, stats, type));
|
||||
});
|
||||
return Promise.all(mappedDossiers$);
|
||||
}
|
||||
@ -472,7 +474,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
private async _updateLastActiveFileForDossier(dossierId: string, fileId: string) {
|
||||
this._dossiersService.activeDossier.files.forEach(f => {
|
||||
this._filesMapService.get(dossierId).forEach(f => {
|
||||
f.lastOpened = f.fileId === fileId;
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { File } from '../files';
|
||||
import { IListable, List } from '@iqser/common-ui';
|
||||
import { IDossier } from './dossier';
|
||||
import { DossierStatus } from './types';
|
||||
@ -29,7 +28,7 @@ export class Dossier implements IDossier, IListable {
|
||||
readonly stats$: Observable<DossierStats>;
|
||||
private readonly _stats$: BehaviorSubject<DossierStats>;
|
||||
|
||||
constructor(dossier: IDossier, stats: DossierStats, readonly files: List<File> = [], public type?: IDictionary) {
|
||||
constructor(dossier: IDossier, stats: DossierStats, public type?: IDictionary) {
|
||||
this.dossierId = dossier.dossierId;
|
||||
this.approverIds = dossier.approverIds;
|
||||
this.date = dossier.date;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user