diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/screen-header/dossier-overview-screen-header.component.html b/apps/red-ui/src/app/modules/dossier-overview/components/screen-header/dossier-overview-screen-header.component.html index c8fc509e7..6f54ab04f 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/screen-header/dossier-overview-screen-header.component.html +++ b/apps/red-ui/src/app/modules/dossier-overview/components/screen-header/dossier-overview-screen-header.component.html @@ -7,7 +7,7 @@ > (); + @Output() readonly upload = new EventEmitter(); readonly circleButtonTypes = CircleButtonTypes; readonly roles = ROLES; actionConfigs: List; + readonly downloadBtnDisabled$: Observable; constructor( private readonly _toaster: Toaster, @@ -47,7 +46,12 @@ export class DossierOverviewScreenHeaderComponent implements OnInit { private readonly _reanalysisService: ReanalysisService, private readonly _loadingService: LoadingService, private readonly _primaryFileAttributeService: PrimaryFileAttributeService, - ) {} + ) { + const someNotProcessed$ = this.entitiesService.all$.pipe(some(file => !file.lastProcessed)); + this.downloadBtnDisabled$ = combineLatest([this.listingService.areSomeSelected$, someNotProcessed$]).pipe( + map(([someSelected, someNotProcessed]) => someSelected || someNotProcessed), + ); + } ngOnInit() { this.actionConfigs = this.configService.actionConfig(this.dossier.id, this.listingService.areSomeSelected$); @@ -56,7 +60,7 @@ export class DossierOverviewScreenHeaderComponent implements OnInit { async reanalyseDossier() { this._loadingService.start(); try { - await firstValueFrom(this._reanalysisService.reanalyzeDossier(this.dossier, true)); + await this._reanalysisService.reanalyzeDossier(this.dossier, true); this._toaster.success(_('dossier-overview.reanalyse-dossier.success')); } catch (e) { this._toaster.error(_('dossier-overview.reanalyse-dossier.error')); @@ -64,34 +68,33 @@ export class DossierOverviewScreenHeaderComponent implements OnInit { this._loadingService.stop(); } - downloadDossierAsCSV() { - const sortedEntities$ = this.listingService.displayed$.pipe(map(entities => this.sortingService.defaultSort(entities))); - sortedEntities$.pipe(take(1)).subscribe(entities => { - const fileName = this.dossier.dossierName + '.export.csv'; - const mapper = (file?: File) => ({ - ...file, - assignee: this._userService.getName(file.assignee) || '-', - primaryAttribute: this._primaryFileAttributeService.getPrimaryFileAttributeValue(file, this.dossier.dossierTemplateId), - }); - const fileFields = [ - 'dossierId', - 'fileId', - 'filename', - 'primaryAttribute', - 'numberOfPages', - 'assignee', - 'workflowStatus', - 'processingStatus', - 'lastUpdated', - 'lastUploaded', - 'lastProcessed', - 'hasHints', - 'hasImages', - 'hasRedactions', - 'hasUpdates', - 'excluded', - ]; - saveAsCSV(fileName, entities, fileFields, mapper); + async downloadDossierAsCSV() { + const displayedEntities = await firstValueFrom(this.listingService.displayed$); + const entities = this.sortingService.defaultSort(displayedEntities); + const fileName = this.dossier.dossierName + '.export.csv'; + const mapper = (file?: File) => ({ + ...file, + assignee: this._userService.getName(file.assignee) || '-', + primaryAttribute: this._primaryFileAttributeService.getPrimaryFileAttributeValue(file, this.dossier.dossierTemplateId), }); + const fileFields = [ + 'dossierId', + 'fileId', + 'filename', + 'primaryAttribute', + 'numberOfPages', + 'assignee', + 'workflowStatus', + 'processingStatus', + 'lastUpdated', + 'lastUploaded', + 'lastProcessed', + 'hasHints', + 'hasImages', + 'hasRedactions', + 'hasUpdates', + 'excluded', + ]; + saveAsCSV(fileName, entities, fileFields, mapper); } } diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.html b/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.html index adc772359..970a0a44a 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.html +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.html @@ -4,7 +4,7 @@ *allow="roles.dossiers.read; if: currentUser.isUser" [icon]="(iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager ? 'iqser:edit' : 'red:info'" [iqserHelpMode]="'edit_dossier_dossier_info'" - [scrollableParentView]="scrollableParentView" + [scrollableParentView]="scrollableParentViews.VIRTUAL_SCROLL" [tooltip]=" ((iqserPermissionsService.has$(roles.dossiers.edit) | async) && currentUser.isManager ? 'dossier-listing.edit.action' @@ -26,7 +26,7 @@ [dossier]="dossier" [files]="files" [iqserHelpMode]="'download_dossier'" - [scrollableParentView]="scrollableParentView" + [scrollableParentView]="scrollableParentViews.VIRTUAL_SCROLL" [type]="circleButtonTypes.dark" > diff --git a/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.ts b/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.ts index e5c21e317..7b0ebde2b 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/components/dossiers-listing-actions/dossiers-listing-actions.component.ts @@ -1,23 +1,22 @@ -import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core'; +import { Component, Input, OnChanges } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { CircleButtonTypes, getCurrentUser, IqserPermissionsService, ScrollableParentView, ScrollableParentViews } from '@iqser/common-ui'; +import { CircleButtonTypes, getCurrentUser, IqserPermissionsService, ScrollableParentViews } from '@iqser/common-ui'; import { Dossier, File, User } from '@red/domain'; import { DossiersDialogService } from '../../services/dossiers-dialog.service'; import { LongPressEvent } from '@shared/directives/long-press.directive'; import { UserPreferenceService } from '@users/user-preference.service'; import { FilesMapService } from '@services/files/files-map.service'; import { ReanalysisService } from '@services/reanalysis.service'; -import { firstValueFrom } from 'rxjs'; import { ROLES } from '@users/roles'; @Component({ selector: 'redaction-dossiers-listing-actions [dossier]', templateUrl: './dossiers-listing-actions.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, }) export class DossiersListingActionsComponent implements OnChanges { readonly circleButtonTypes = CircleButtonTypes; readonly roles = ROLES; + readonly scrollableParentViews = ScrollableParentViews; readonly currentUser = getCurrentUser(); analysisForced: boolean; @@ -35,10 +34,6 @@ export class DossiersListingActionsComponent implements OnChanges { private readonly _userPreferenceService: UserPreferenceService, ) {} - get scrollableParentView(): ScrollableParentView { - return ScrollableParentViews.VIRTUAL_SCROLL; - } - ngOnChanges() { this.files = this.filesMapService.get(this.dossier.id); this.displayReanalyseBtn = this.permissionsService.displayReanalyseBtn(this.dossier) && this.analysisForced; @@ -54,6 +49,6 @@ export class DossiersListingActionsComponent implements OnChanges { async reanalyseDossier($event: MouseEvent, dossier: Dossier): Promise { $event.stopPropagation(); - await firstValueFrom(this._reanalysisService.reanalyzeDossier(dossier)); + await this._reanalysisService.reanalyzeDossier(dossier); } } diff --git a/apps/red-ui/src/app/services/reanalysis.service.ts b/apps/red-ui/src/app/services/reanalysis.service.ts index 91a0e3610..15ed1b22c 100644 --- a/apps/red-ui/src/app/services/reanalysis.service.ts +++ b/apps/red-ui/src/app/services/reanalysis.service.ts @@ -5,7 +5,7 @@ import { catchError, switchMap, tap } from 'rxjs/operators'; import { FilesService } from './files/files.service'; import { FilesMapService } from './files/files-map.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; -import { of } from 'rxjs'; +import { firstValueFrom, of } from 'rxjs'; export interface ReanalyzeQueryParams { force?: boolean; @@ -89,13 +89,14 @@ export class ReanalysisService extends GenericService { } @Validate() - reanalyzeDossier(@RequiredParam() dossier: Dossier, force?: boolean) { + async reanalyzeDossier(@RequiredParam() dossier: Dossier, force?: boolean) { const { dossierId } = dossier; const queryParams: QueryParam[] = []; if (force) { queryParams.push({ key: 'force', value: force }); } - return this._post({}, `reanalyze/${dossierId}`, queryParams).pipe(switchMap(() => this._filesService.loadAll(dossierId))); + await firstValueFrom(this._post({}, `reanalyze/${dossierId}`, queryParams)); + return await firstValueFrom(this._filesService.loadAll(dossierId)); } } diff --git a/libs/common-ui b/libs/common-ui index 7c1c03142..b8c3b76e5 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 7c1c03142933874fdd2c21d46f9f8d33e7f75f95 +Subproject commit b8c3b76e56ee888a93d62d7a8fd8fbcaec1a7153