Removed lastOpened
This commit is contained in:
parent
7539b2a0f7
commit
8abdb55b6f
@ -139,9 +139,9 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
}
|
||||
}
|
||||
|
||||
disabledFn = (fileStatus: File) => fileStatus.excluded;
|
||||
disabledFn = (file: File) => file.excluded;
|
||||
|
||||
lastOpenedFn = (fileStatus: File) => fileStatus.lastOpened;
|
||||
lastOpenedFn = (file: File) => this._userPreferenceService.getLastOpenedFileForDossier(file.dossierId) === file.id;
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this._loadEntitiesFromState();
|
||||
|
||||
@ -119,6 +119,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _filesMapService: FilesMapService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
) {
|
||||
super();
|
||||
this._loadingService.start();
|
||||
@ -258,6 +259,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this._userPreferenceService.saveLastOpenedFileForDossier(this.dossierId, this.fileId);
|
||||
|
||||
await this._loadFileData();
|
||||
this.displayPDFViewer = true;
|
||||
this._updateCanPerformActions();
|
||||
|
||||
@ -6,7 +6,6 @@ import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { catchError, first, map, tap } from 'rxjs/operators';
|
||||
import { currentComponentRoute, FALLBACK_COLOR, hexToRgb } from '@utils/functions';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DictionaryService } from '@shared/services/dictionary.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
@ -35,7 +34,6 @@ export class AppStateService {
|
||||
private readonly _dossierStatsService: DossierStatsService,
|
||||
private readonly _fileAttributesService: FileAttributesService,
|
||||
private readonly _filesMapService: FilesMapService,
|
||||
private readonly _userPreferenceService: UserPreferenceService,
|
||||
) {
|
||||
_router.events.pipe(currentComponentRoute).subscribe(async (event: ActivationEnd) => {
|
||||
const fileId = event.snapshot.paramMap.get('fileId');
|
||||
@ -50,7 +48,7 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
const dossierId = event.snapshot.paramMap.get('dossierId');
|
||||
return this.activateFile(dossierId, fileId);
|
||||
return this._activateFile(dossierId, fileId);
|
||||
});
|
||||
}
|
||||
|
||||
@ -154,26 +152,11 @@ export class AppStateService {
|
||||
|
||||
const fileAttributes = this._fileAttributesService.getFileAttributeConfig(dossier.dossierTemplateId);
|
||||
const newFiles = files.map(iFile => new File(iFile, this._userService.getNameForId(iFile.currentReviewer), fileAttributes));
|
||||
|
||||
const lastOpenedFileId = this._userPreferenceService.getLastOpenedFileForDossier(dossier.id);
|
||||
newFiles.forEach(file => (file.lastOpened = file.fileId === lastOpenedFileId));
|
||||
this._filesMapService.set(dossier.dossierId, newFiles);
|
||||
|
||||
return newFiles;
|
||||
}
|
||||
|
||||
async activateFile(dossierId: string, fileId: string) {
|
||||
const activeDossierId = await this._dossiersService.activeDossierId$.pipe(first()).toPromise();
|
||||
if (activeDossierId === dossierId && this.activeFileId === fileId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._dossiersService.activeDossier) {
|
||||
this._appState.activeFileId = fileId;
|
||||
}
|
||||
await this._updateLastActiveFileForDossier(dossierId, fileId);
|
||||
}
|
||||
|
||||
activateDictionary(dictionaryType: string) {
|
||||
if (this._dossierTemplatesService.activeDossierTemplate) {
|
||||
this._appState.activeDictionaryType = dictionaryType;
|
||||
@ -258,6 +241,17 @@ export class AppStateService {
|
||||
);
|
||||
}
|
||||
|
||||
private async _activateFile(dossierId: string, fileId: string) {
|
||||
const activeDossierId = await this._dossiersService.activeDossierId$.pipe(first()).toPromise();
|
||||
if (activeDossierId === dossierId && this.activeFileId === fileId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._dossiersService.activeDossier) {
|
||||
this._appState.activeFileId = fileId;
|
||||
}
|
||||
}
|
||||
|
||||
private _getDictionaryDataForDossierTemplate$(dossierTemplateId: string): Observable<{ [key: string]: any }> {
|
||||
const dictionaryData: { [key: string]: any } = {};
|
||||
|
||||
@ -449,12 +443,4 @@ export class AppStateService {
|
||||
|
||||
return forkJoin([typeObs, colorsObs]).pipe(map(() => dictionaryData));
|
||||
}
|
||||
|
||||
private async _updateLastActiveFileForDossier(dossierId: string, fileId: string) {
|
||||
this._filesMapService.get(dossierId).forEach(f => {
|
||||
f.lastOpened = f.fileId === fileId;
|
||||
});
|
||||
|
||||
await this._userPreferenceService.saveLastOpenedFileForDossier(dossierId, fileId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,6 @@ export class File extends Entity<IFile> implements IFile {
|
||||
readonly workflowStatus: WorkflowFileStatus;
|
||||
|
||||
readonly primaryAttribute?: string;
|
||||
lastOpened = false;
|
||||
readonly statusSort: number;
|
||||
readonly cacheIdentifier?: string;
|
||||
readonly hintsOnly: boolean;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user