From bc982263c4f61d021d56e3006bab98968d404562 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Thu, 18 Nov 2021 01:40:11 +0200 Subject: [PATCH] dossier listing actions don't use methods in templates --- .../dossiers-listing-actions.component.html | 6 ++--- .../dossiers-listing-actions.component.ts | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.html b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.html index e891cb173..6c1bd51a1 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.html @@ -1,4 +1,4 @@ - +
- +
diff --git a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.ts b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.ts index 0e367be05..7ab7cf2b7 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/dossiers-listing/components/dossiers-listing-actions/dossiers-listing-actions.component.ts @@ -1,9 +1,9 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; import { PermissionsService } from '@services/permissions.service'; -import { CircleButtonTypes, StatusBarConfig } from '@iqser/common-ui'; +import { CircleButtonTypes, List, StatusBarConfig } from '@iqser/common-ui'; import { UserService } from '@services/user.service'; import { AppStateService } from '@state/app-state.service'; -import { Dossier, DossierStats, StatusSorter } from '@red/domain'; +import { Dossier, DossierStats, File, StatusSorter } from '@red/domain'; import { DossiersDialogService } from '../../../../services/dossiers-dialog.service'; import { LongPressEvent } from '@shared/directives/long-press.directive'; import { UserPreferenceService } from '@services/user-preference.service'; @@ -17,11 +17,14 @@ import { switchMapTo, tap } from 'rxjs/operators'; styleUrls: ['./dossiers-listing-actions.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class DossiersListingActionsComponent { +export class DossiersListingActionsComponent implements OnChanges { readonly circleButtonTypes = CircleButtonTypes; readonly currentUser = this._userService.currentUser; analysisForced: boolean; + statusBarConfig: List>; + files: File[]; + displayReanalyseBtn = false; @Input() dossier: Dossier; @Input() stats: DossierStats; @@ -38,10 +41,16 @@ export class DossiersListingActionsComponent { private readonly _userPreferenceService: UserPreferenceService, ) {} - statusConfig(stats: DossierStats): readonly StatusBarConfig[] { - return Object.keys(stats.fileCountPerWorkflowStatus) - .sort(StatusSorter.byStatus) - .map(status => ({ length: stats.fileCountPerWorkflowStatus[status], color: status })); + private get _statusConfig(): List> { + const { fileCountPerWorkflowStatus } = this.stats; + const statuses = Object.keys(fileCountPerWorkflowStatus).sort(StatusSorter.byStatus); + return statuses.map(status => ({ length: fileCountPerWorkflowStatus[status], color: status })); + } + + ngOnChanges() { + this.statusBarConfig = this._statusConfig; + this.files = this.filesMapService.get(this.dossier.dossierId); + this.displayReanalyseBtn = this.permissionsService.displayReanalyseBtn(this.dossier) && this.analysisForced; } forceReanalysisAction($event: LongPressEvent) {