diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.html index 6d6f693e2..399c3cbbb 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.html @@ -1,54 +1,58 @@ -
-
- + +
+
+ - -
-
- -
-
-
-
{{ attr.label }}:
-
{{ attr.value || '-' }}
+
-
-
- - {{ 'file-preview.tabs.document-info.details.dossier' | translate: { dossierName: dossier.dossierName } }} +
+
+
+
{{ attr.label }}:
+
{{ attr.value || '-' }}
+
-
- - {{ 'file-preview.tabs.document-info.details.pages' | translate: { pages: file.numberOfPages } }} -
+
+
+ + {{ 'file-preview.tabs.document-info.details.dossier' | translate: { dossierName: dossier.dossierName } }} +
-
- - {{ 'file-preview.tabs.document-info.details.created-on' | translate: { date: file.added | date: 'mediumDate' } }} -
+
+ + {{ 'file-preview.tabs.document-info.details.pages' | translate: { pages: file.numberOfPages } }} +
-
- - {{ 'file-preview.tabs.document-info.details.due' | translate: { date: dossier.dueDate | date: 'mediumDate' } }} -
+
+ + {{ + 'file-preview.tabs.document-info.details.created-on' | translate: { date: file.added | date: 'mediumDate' } + }} +
-
- - {{ dossierTemplateName }} +
+ + {{ 'file-preview.tabs.document-info.details.due' | translate: { date: dossier.dueDate | date: 'mediumDate' } }} +
+ +
+ + {{ dossierTemplateName$ }} +
-
+ diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.ts index 0ab68a6d7..bac4a4366 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/document-info/document-info.component.ts @@ -1,44 +1,42 @@ -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; -import { Dossier, File } from '@red/domain'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { DossiersDialogService } from '../../../../services/dossiers-dialog.service'; -import { AutoUnsubscribe } from '@iqser/common-ui'; import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service'; import { DocumentInfoService } from '../../services/document-info.service'; -import { Observable } from 'rxjs'; -import { PermissionsService } from '@services/permissions.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'; @Component({ - selector: 'redaction-document-info [file] [dossier]', + selector: 'redaction-document-info', templateUrl: './document-info.component.html', styleUrls: ['./document-info.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class DocumentInfoComponent extends AutoUnsubscribe implements OnInit { - @Input() file: File; - @Input() dossier: Dossier; - - fileAttributes$: Observable<{ label: string; value: string }[]>; - dossierTemplateName: string; +export class DocumentInfoComponent { + readonly fileAttributes$: Observable<{ label: string; value: string }[]>; + readonly dossierTemplateName$: Observable; constructor( private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _dialogService: DossiersDialogService, + private readonly _dossiersService: DossiersService, + readonly stateService: FilePreviewStateService, readonly permissionsService: PermissionsService, readonly documentInfoService: DocumentInfoService, ) { - super(); - } - - ngOnInit(): void { - this.dossierTemplateName = this._dossierTemplatesService.find(this.dossier.dossierTemplateId).name; - this.fileAttributes$ = this.documentInfoService.fileAttributes$( - this.file.fileId, - this.file.dossierId, - this.dossier.dossierTemplateId, + const _dossier$ = this.stateService.file$.pipe(switchMap(file => this._dossiersService.getEntityChanged$(file.dossierId))); + this.fileAttributes$ = combineLatest([this.stateService.file$, _dossier$]).pipe( + switchMap(([file, dossier]) => this.documentInfoService.fileAttributes$(file.fileId, dossier.id, dossier.dossierTemplateId)), + ); + this.dossierTemplateName$ = _dossier$.pipe( + switchMap(dossier => this._dossierTemplatesService.getEntityChanged$(dossier.dossierTemplateId)), + map(dossierTemplate => dossierTemplate.name), ); } edit() { - this._dialogService.openDialog('documentInfo', null, this.file); + this._dialogService.openDialog('documentInfo', null, this.stateService.fileData.file); } } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index 2e8737844..63d312a1c 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -88,11 +88,7 @@ icon="red:needs-work" > - +