diff --git a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts index 806d188a4..5faffcf73 100644 --- a/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts +++ b/apps/red-ui/src/app/modules/shared/dialogs/download-dialog/download-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, inject } from '@angular/core'; import { Dossier, DownloadFileType, DownloadFileTypes, File, IReportTemplate, WorkflowFileStatuses } from '@red/domain'; import { downloadTypesForDownloadTranslations } from '@translations/download-types-translations'; import { ReportTemplateService } from '@services/report-template.service'; @@ -7,6 +7,7 @@ import { DefaultColorsService } from '@services/entity-services/default-colors.s import { IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; import { Roles } from '@users/roles'; import { List } from '@iqser/common-ui/lib/utils'; +import { NGXLogger } from 'ngx-logger'; export interface DownloadDialogData { readonly dossier: Dossier; @@ -24,10 +25,13 @@ export interface DownloadDialogResult { styleUrls: ['./download-dialog.component.scss'], }) export class DownloadDialogComponent extends IqserDialogComponent { + readonly #logger = inject(NGXLogger); readonly iconButtonTypes = IconButtonTypes; readonly downloadTypes: { key: DownloadFileType; label: string }[] = this.#formDownloadTypes; readonly availableReportTypes = this.#availableReportTypes; readonly form = this.#getForm(); + readonly hasApprovedFiles = this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED); + initialFormValue = this.form.getRawValue(); readonly roles = Roles; @@ -52,12 +56,12 @@ export class DownloadDialogComponent extends IqserDialogComponent type === DownloadFileTypes.REDACTED) && - !this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED) - ); + const hasReportTypes = this.form.controls.reportTemplateIds.value.length; + const downloadFileTypes = this.form.controls.downloadFileTypes.value; + const onlyRedactedVersionSelected = + downloadFileTypes.length && downloadFileTypes.every(type => type === DownloadFileTypes.REDACTED); + + return !hasReportTypes || (onlyRedactedVersionSelected && !this.hasApprovedFiles); } override get valid() { @@ -77,7 +81,7 @@ export class DownloadDialogComponent extends IqserDialogComponent { - if (!this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED)) { + if (!this.hasApprovedFiles) { return type.key !== DownloadFileTypes.REDACTED; } return true; @@ -86,7 +90,7 @@ export class DownloadDialogComponent extends IqserDialogComponent { - if (!this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED)) { + if (!this.hasApprovedFiles) { return type !== DownloadFileTypes.REDACTED; } return true; @@ -99,18 +103,20 @@ export class DownloadDialogComponent extends IqserDialogComponent reportTemplate.templateId; - close() { + override close() { const result: DownloadDialogResult = { reportTemplateIds: this.form.controls.reportTemplateIds.value, downloadFileTypes: this.form.controls.downloadFileTypes.value, redactionPreviewColor: this.form.controls.redactionPreviewColor.value, }; + this.#logger.info('[DOWNLOAD] Closing with result', result); + if (result.reportTemplateIds.length === 0) { - return this.dialogRef.close(); + return super.close(); } - this.dialogRef.close(result); + super.close(result); } #hasReportTemplateOrDownloadType(control: AbstractControl) { diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 3e5de8134..570c25302 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,8 +1,8 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dev-04.iqser.cloud", - "APP_NAME": "RedactManager", + "API_URL": "https://dan.iqser.cloud", + "APP_NAME": "RedactManager very very very very long", "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", "EULA_URL": "EULA_URL", @@ -11,7 +11,7 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dev-04.iqser.cloud/auth", + "OAUTH_URL": "https://dan.iqser.cloud/auth", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", diff --git a/libs/common-ui b/libs/common-ui index 83f13eda4..dc5f14c69 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 83f13eda4f173fbe12d931334ef49e609ed9df56 +Subproject commit dc5f14c696df0bba4609a9ac95d784228d75d3a3