renaming and load file data flow
This commit is contained in:
parent
22c7ec4ce7
commit
7acaa9f965
@ -69,7 +69,7 @@
|
||||
|
||||
<div [class.required]="commentIsMandatory" class="iqser-input-group w-300">
|
||||
<label translate="manual-annotation.dialog.content.comment"></label>
|
||||
<textarea formControlName="comment" name="comment" redactionHasScrollbar rows="4" type="text"></textarea>
|
||||
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -80,5 +80,5 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<iqser-circle-button class="dialog-close" icon="iqser:close" (action)="close()"></iqser-circle-button>
|
||||
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
|
||||
</section>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div class="right-title heading" translate="file-preview.tabs.document-info.label">
|
||||
<div>
|
||||
<iqser-circle-button
|
||||
(action)="edit()"
|
||||
(action)="edit(file)"
|
||||
*ngIf="permissionsService.canEditFileAttributes(file)"
|
||||
[tooltip]="'file-preview.tabs.document-info.edit' | translate"
|
||||
icon="iqser:edit"
|
||||
|
||||
@ -5,8 +5,8 @@ import { DocumentInfoService } from '../../services/document-info.service';
|
||||
import { combineLatest, Observable, switchMap } from 'rxjs';
|
||||
import { PermissionsService } from '../../../../../../services/permissions.service';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
import { DossiersService } from '../../../../../../services/entity-services/dossiers.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { File } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-document-info',
|
||||
@ -21,7 +21,6 @@ export class DocumentInfoComponent {
|
||||
constructor(
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dialogService: DossiersDialogService,
|
||||
private readonly _dossiersService: DossiersService,
|
||||
readonly stateService: FilePreviewStateService,
|
||||
readonly permissionsService: PermissionsService,
|
||||
readonly documentInfoService: DocumentInfoService,
|
||||
@ -35,7 +34,7 @@ export class DocumentInfoComponent {
|
||||
);
|
||||
}
|
||||
|
||||
edit() {
|
||||
this._dialogService.openDialog('documentInfo', null, this.stateService.fileData.file);
|
||||
edit(file: File) {
|
||||
this._dialogService.openDialog('documentInfo', null, file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,15 +18,15 @@ export class ViewSwitchComponent {
|
||||
readonly canSwitchToRedactedView$: Observable<boolean>;
|
||||
|
||||
constructor(readonly viewModeService: ViewModeService, private readonly _stateService: FilePreviewStateService) {
|
||||
this.canSwitchToDeltaView$ = this._stateService.fileData$.pipe(
|
||||
this.canSwitchToDeltaView$ = _stateService.fileData$.pipe(
|
||||
filter(fileData => !!fileData),
|
||||
switchMap(fileData =>
|
||||
combineLatest([fileData.hasChangeLog$, fileData.file$]).pipe(
|
||||
combineLatest([fileData.hasChangeLog$, _stateService.file$]).pipe(
|
||||
map(([hasChangeLog, file]) => hasChangeLog && !file.isApproved),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
this.canSwitchToRedactedView$ = this._stateService.file$.pipe(map(file => !file.analysisRequired && !file.excluded));
|
||||
this.canSwitchToRedactedView$ = _stateService.file$.pipe(map(file => !file.analysisRequired && !file.excluded));
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
<div [class.required]="!isDocumentAdmin" class="iqser-input-group w-300">
|
||||
<label translate="manual-annotation.dialog.content.comment"></label>
|
||||
<textarea formControlName="comment" name="comment" redactionHasScrollbar rows="4" type="text"></textarea>
|
||||
<textarea formControlName="comment" iqserHasScrollbar name="comment" rows="4" type="text"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { forkJoin, Observable, of } from 'rxjs';
|
||||
import { catchError, map, tap } from 'rxjs/operators';
|
||||
import { forkJoin, Observable, of, switchMap } from 'rxjs';
|
||||
import { catchError, map, take, tap } from 'rxjs/operators';
|
||||
import { FileDataModel } from '@models/file/file-data.model';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { File, IRedactionLog, IViewedPage } from '@red/domain';
|
||||
@ -32,19 +32,23 @@ export class PdfViewerDataService {
|
||||
);
|
||||
}
|
||||
|
||||
loadDataFor(file: File): Observable<FileDataModel> {
|
||||
const fileData = this._stateService.fileData;
|
||||
const blob$ = fileData?.file.cacheIdentifier === file.cacheIdentifier ? of(fileData.blob$.value) : this.downloadOriginalFile(file);
|
||||
const redactionLog$ = this.loadRedactionLogFor(file.dossierId, file.fileId);
|
||||
const viewedPages$ = this.getViewedPagesFor(file);
|
||||
loadDataFor(newFile: File): Observable<FileDataModel> {
|
||||
const oldBlob$ = this._stateService.fileData?.blob$;
|
||||
const blob$ = this._stateService.file$.pipe(
|
||||
map(file => file.cacheIdentifier === newFile.cacheIdentifier && oldBlob$),
|
||||
switchMap(isSame => (isSame ? oldBlob$ : this.downloadOriginalFile(newFile))),
|
||||
take(1),
|
||||
);
|
||||
const redactionLog$ = this.loadRedactionLogFor(newFile.dossierId, newFile.fileId);
|
||||
const viewedPages$ = this.getViewedPagesFor(newFile);
|
||||
|
||||
const dossier = this._dossiersService.find(file.dossierId);
|
||||
const dossier = this._dossiersService.find(newFile.dossierId);
|
||||
|
||||
return forkJoin([blob$, redactionLog$, viewedPages$]).pipe(
|
||||
map(
|
||||
(data: [blob: Blob, redactionLog: IRedactionLog, viewedPages: IViewedPage[]]) =>
|
||||
new FileDataModel(
|
||||
file,
|
||||
newFile,
|
||||
...data,
|
||||
this._appStateService.dictionaryData[dossier.dossierTemplateId],
|
||||
this._userPreferenceService.areDevFeaturesEnabled,
|
||||
@ -60,7 +64,7 @@ export class PdfViewerDataService {
|
||||
return of([]);
|
||||
}
|
||||
|
||||
downloadOriginalFile(file: File): Observable<any> {
|
||||
downloadOriginalFile(file: File): Observable<Blob> {
|
||||
return this._fileManagementService.downloadOriginalFile(file.dossierId, file.fileId, 'body', true, file.cacheIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { File } from '@red/domain';
|
||||
import { filter, startWith } from 'rxjs/operators';
|
||||
import { shareLast } from '@iqser/common-ui';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class FilesMapService {
|
||||
@ -37,7 +38,7 @@ export class FilesMapService {
|
||||
return entities.forEach(entity => this._entityChanged$.next(entity));
|
||||
}
|
||||
|
||||
const changedEntities = [];
|
||||
const changedEntities: File[] = [];
|
||||
const deletedEntities = this.get(key).filter(oldEntity => !entities.find(newEntity => newEntity.id === oldEntity.id));
|
||||
|
||||
// Keep old object references for unchanged entities
|
||||
@ -77,6 +78,7 @@ export class FilesMapService {
|
||||
return this._entityChanged$.pipe(
|
||||
filter(entity => entity.id === entityId),
|
||||
startWith(this.get(key, entityId)),
|
||||
shareLast(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user