RED-6082: disable download btn when a file is not processed
This commit is contained in:
parent
1bf513eaa0
commit
e4f5ee4fec
@ -7,7 +7,7 @@
|
||||
>
|
||||
<ng-container slot="right">
|
||||
<redaction-file-download-btn
|
||||
[disabled]="listingService.areSomeSelected$ | async"
|
||||
[disabled]="downloadBtnDisabled$ | async"
|
||||
[dossier]="dossier"
|
||||
[files]="entitiesService.all$ | async"
|
||||
[iqserHelpMode]="'edit_dossier_in_dossier'"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import {
|
||||
ActionConfig,
|
||||
CircleButtonTypes,
|
||||
@ -6,7 +6,7 @@ import {
|
||||
List,
|
||||
ListingService,
|
||||
LoadingService,
|
||||
Required,
|
||||
some,
|
||||
SortingService,
|
||||
Toaster,
|
||||
} from '@iqser/common-ui';
|
||||
@ -14,26 +14,25 @@ import { Dossier, File, IFile } from '@red/domain';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { ReanalysisService } from '@services/reanalysis.service';
|
||||
import { map, take } from 'rxjs/operators';
|
||||
import { combineLatest, firstValueFrom, map, Observable } from 'rxjs';
|
||||
import { saveAsCSV } from '@utils/csv-utils';
|
||||
import { UserService } from '@users/user.service';
|
||||
import { ConfigService } from '../../config.service';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { PrimaryFileAttributeService } from '@services/primary-file-attribute.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { ROLES } from '@users/roles';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-overview-screen-header [dossier]',
|
||||
selector: 'redaction-dossier-overview-screen-header [dossier] [upload]',
|
||||
templateUrl: './dossier-overview-screen-header.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DossierOverviewScreenHeaderComponent implements OnInit {
|
||||
@Input() dossier: Dossier;
|
||||
@Output() @Required() readonly upload = new EventEmitter<void>();
|
||||
@Output() readonly upload = new EventEmitter<void>();
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly roles = ROLES;
|
||||
actionConfigs: List<ActionConfig>;
|
||||
readonly downloadBtnDisabled$: Observable<boolean>;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
></redaction-file-download-btn>
|
||||
</div>
|
||||
|
||||
@ -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<User>();
|
||||
|
||||
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<void> {
|
||||
$event.stopPropagation();
|
||||
await firstValueFrom(this._reanalysisService.reanalyzeDossier(dossier));
|
||||
await this._reanalysisService.reanalyzeDossier(dossier);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<unknown> {
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 7c1c03142933874fdd2c21d46f9f8d33e7f75f95
|
||||
Subproject commit b8c3b76e56ee888a93d62d7a8fd8fbcaec1a7153
|
||||
Loading…
x
Reference in New Issue
Block a user