fix RED-2495
This commit is contained in:
parent
c94d76f435
commit
8d19b560fe
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Colors, IFile } from '@redaction/red-ui-http';
|
||||
import { Colors, IDossier, IFile } from '@redaction/red-ui-http';
|
||||
import { ActivationEnd, Router } from '@angular/router';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { forkJoin, Observable, of, Subject } from 'rxjs';
|
||||
@ -132,8 +132,12 @@ export class AppStateService {
|
||||
return;
|
||||
}
|
||||
|
||||
const getFiles = (dossierId: string) => this._dossiersService.find(dossierId)?.files ?? [];
|
||||
const mappedDossiers = dossiers.map(p => new Dossier(p, getFiles(p.dossierId)));
|
||||
const mappedDossiers$ = dossiers.map(async p => {
|
||||
const oldDossier = this._dossiersService.find(p.dossierId);
|
||||
const type = oldDossier?.type ?? (await this._getDictionaryFor(p));
|
||||
return new Dossier(p, oldDossier?.files ?? [], type);
|
||||
});
|
||||
const mappedDossiers = await Promise.all(mappedDossiers$);
|
||||
const fileData = await this._filesService.getFor(mappedDossiers.map(p => p.id)).toPromise();
|
||||
|
||||
for (const dossierId of Object.keys(fileData)) {
|
||||
@ -160,7 +164,7 @@ export class AppStateService {
|
||||
);
|
||||
const files = activeDossier.files.filter(file => file.fileId !== activeFile.fileId);
|
||||
files.push(activeFile);
|
||||
const newDossier = new Dossier(activeDossier, files);
|
||||
const newDossier = new Dossier(activeDossier, files, activeDossier.type);
|
||||
this._dossiersService.replace(newDossier);
|
||||
|
||||
if (activeFile.lastProcessed !== oldProcessedDate) {
|
||||
@ -278,6 +282,10 @@ export class AppStateService {
|
||||
);
|
||||
}
|
||||
|
||||
private _getDictionaryFor(dossier: IDossier) {
|
||||
return this._dictionaryService.getFor(dossier.dossierTemplateId, 'dossier_redaction', dossier.dossierId).toPromise();
|
||||
}
|
||||
|
||||
private _getDictionaryDataForDossierTemplate$(dossierTemplateId: string): Observable<{ [key: string]: any }> {
|
||||
const dictionaryData: { [key: string]: any } = {};
|
||||
|
||||
@ -527,7 +535,7 @@ export class AppStateService {
|
||||
}
|
||||
}
|
||||
|
||||
const newDossier = new Dossier(dossier, newFiles);
|
||||
const newDossier = new Dossier(dossier, newFiles, dossier.type);
|
||||
this._dossiersService.replace(newDossier);
|
||||
|
||||
return newFiles;
|
||||
|
||||
@ -32,9 +32,7 @@ export class Dossier implements IDossier, IListable {
|
||||
readonly hasNone: boolean;
|
||||
readonly hasPendingOrProcessing: boolean;
|
||||
|
||||
type?: IDictionary;
|
||||
|
||||
constructor(dossier: IDossier, readonly files: List<File> = []) {
|
||||
constructor(dossier: IDossier, readonly files: List<File> = [], public type?: IDictionary) {
|
||||
this.dossierId = dossier.dossierId;
|
||||
this.approverIds = dossier.approverIds;
|
||||
this.date = dossier.date;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user