RED-6713 & RED-7138

This commit is contained in:
Dan Percic 2023-07-17 17:13:33 +03:00
parent 2de1f162b6
commit 45a36b8fb3
3 changed files with 22 additions and 16 deletions

View File

@ -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 { Dossier, DownloadFileType, DownloadFileTypes, File, IReportTemplate, WorkflowFileStatuses } from '@red/domain';
import { downloadTypesForDownloadTranslations } from '@translations/download-types-translations'; import { downloadTypesForDownloadTranslations } from '@translations/download-types-translations';
import { ReportTemplateService } from '@services/report-template.service'; 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 { IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
import { Roles } from '@users/roles'; import { Roles } from '@users/roles';
import { List } from '@iqser/common-ui/lib/utils'; import { List } from '@iqser/common-ui/lib/utils';
import { NGXLogger } from 'ngx-logger';
export interface DownloadDialogData { export interface DownloadDialogData {
readonly dossier: Dossier; readonly dossier: Dossier;
@ -24,10 +25,13 @@ export interface DownloadDialogResult {
styleUrls: ['./download-dialog.component.scss'], styleUrls: ['./download-dialog.component.scss'],
}) })
export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialogComponent, DownloadDialogData, DownloadDialogResult> { export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialogComponent, DownloadDialogData, DownloadDialogResult> {
readonly #logger = inject(NGXLogger);
readonly iconButtonTypes = IconButtonTypes; readonly iconButtonTypes = IconButtonTypes;
readonly downloadTypes: { key: DownloadFileType; label: string }[] = this.#formDownloadTypes; readonly downloadTypes: { key: DownloadFileType; label: string }[] = this.#formDownloadTypes;
readonly availableReportTypes = this.#availableReportTypes; readonly availableReportTypes = this.#availableReportTypes;
readonly form = this.#getForm(); readonly form = this.#getForm();
readonly hasApprovedFiles = this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED);
initialFormValue = this.form.getRawValue(); initialFormValue = this.form.getRawValue();
readonly roles = Roles; readonly roles = Roles;
@ -52,12 +56,12 @@ export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialog
} }
get invalidDownload() { get invalidDownload() {
return ( const hasReportTypes = this.form.controls.reportTemplateIds.value.length;
!this.form.controls.reportTemplateIds.value.length && const downloadFileTypes = this.form.controls.downloadFileTypes.value;
!!this.form.controls.downloadFileTypes.value.length && const onlyRedactedVersionSelected =
this.form.controls.downloadFileTypes.value.every(type => type === DownloadFileTypes.REDACTED) && downloadFileTypes.length && downloadFileTypes.every(type => type === DownloadFileTypes.REDACTED);
!this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED)
); return !hasReportTypes || (onlyRedactedVersionSelected && !this.hasApprovedFiles);
} }
override get valid() { override get valid() {
@ -77,7 +81,7 @@ export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialog
label: downloadTypesForDownloadTranslations[type], label: downloadTypesForDownloadTranslations[type],
})) }))
.filter(type => { .filter(type => {
if (!this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED)) { if (!this.hasApprovedFiles) {
return type.key !== DownloadFileTypes.REDACTED; return type.key !== DownloadFileTypes.REDACTED;
} }
return true; return true;
@ -86,7 +90,7 @@ export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialog
get #selectedDownloadTypes() { get #selectedDownloadTypes() {
return this.data.dossier.downloadFileTypes.filter(type => { return this.data.dossier.downloadFileTypes.filter(type => {
if (!this.data.files.some(file => file.workflowStatus === WorkflowFileStatuses.APPROVED)) { if (!this.hasApprovedFiles) {
return type !== DownloadFileTypes.REDACTED; return type !== DownloadFileTypes.REDACTED;
} }
return true; return true;
@ -99,18 +103,20 @@ export class DownloadDialogComponent extends IqserDialogComponent<DownloadDialog
reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId; reportTemplateValueMapper = (reportTemplate: IReportTemplate) => reportTemplate.templateId;
close() { override close() {
const result: DownloadDialogResult = { const result: DownloadDialogResult = {
reportTemplateIds: this.form.controls.reportTemplateIds.value, reportTemplateIds: this.form.controls.reportTemplateIds.value,
downloadFileTypes: this.form.controls.downloadFileTypes.value, downloadFileTypes: this.form.controls.downloadFileTypes.value,
redactionPreviewColor: this.form.controls.redactionPreviewColor.value, redactionPreviewColor: this.form.controls.redactionPreviewColor.value,
}; };
this.#logger.info('[DOWNLOAD] Closing with result', result);
if (result.reportTemplateIds.length === 0) { if (result.reportTemplateIds.length === 0) {
return this.dialogRef.close(); return super.close();
} }
this.dialogRef.close(result); super.close(result);
} }
#hasReportTemplateOrDownloadType(control: AbstractControl) { #hasReportTemplateOrDownloadType(control: AbstractControl) {

View File

@ -1,8 +1,8 @@
{ {
"ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null, "ADMIN_CONTACT_URL": null,
"API_URL": "https://dev-04.iqser.cloud", "API_URL": "https://dan.iqser.cloud",
"APP_NAME": "RedactManager", "APP_NAME": "RedactManager very very very very long",
"AUTO_READ_TIME": 3, "AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40", "BACKEND_APP_VERSION": "4.4.40",
"EULA_URL": "EULA_URL", "EULA_URL": "EULA_URL",
@ -11,7 +11,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3, "MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction", "OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null, "OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dev-04.iqser.cloud/auth", "OAUTH_URL": "https://dan.iqser.cloud/auth",
"RECENT_PERIOD_IN_HOURS": 24, "RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural", "SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",

@ -1 +1 @@
Subproject commit 83f13eda4f173fbe12d931334ef49e609ed9df56 Subproject commit dc5f14c696df0bba4609a9ac95d784228d75d3a3