From 1d914e495a0576a1e6aafa801c77fb2bfb248f8c Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Tue, 18 Jul 2023 15:30:27 +0300 Subject: [PATCH] RED-7138 fix download options --- .../src/app/modules/admin/admin.module.ts | 2 ++ .../shared-dossiers/shared-dossiers.module.ts | 2 ++ .../file-download-btn.component.ts | 2 +- .../expandable-file-actions.component.ts | 2 +- .../components/select/select.component.ts | 12 ++++++-- .../download-dialog.component.ts | 28 ++++++++++++++++--- .../src/app/modules/shared/shared.module.ts | 7 ++--- libs/common-ui | 2 +- 8 files changed, 43 insertions(+), 14 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/admin.module.ts b/apps/red-ui/src/app/modules/admin/admin.module.ts index 67eff6d7f..fc8df4e81 100644 --- a/apps/red-ui/src/app/modules/admin/admin.module.ts +++ b/apps/red-ui/src/app/modules/admin/admin.module.ts @@ -56,6 +56,7 @@ import { AuditInfoDialogComponent } from './dialogs/audit-info-dialog/audit-info import { DossierTemplateActionsComponent } from './shared/components/dossier-template-actions/dossier-template-actions.component'; import { IqserUsersModule } from '@iqser/common-ui/lib/users'; import { TenantPipe } from '@iqser/common-ui/lib/tenants'; +import { SelectComponent } from '@shared/components/select/select.component'; const dialogs = [ AddEditCloneDossierTemplateDialogComponent, @@ -123,6 +124,7 @@ const components = [ IqserAllowDirective, IqserDenyDirective, TenantPipe, + SelectComponent, ], }) export class AdminModule {} diff --git a/apps/red-ui/src/app/modules/shared-dossiers/shared-dossiers.module.ts b/apps/red-ui/src/app/modules/shared-dossiers/shared-dossiers.module.ts index 885cfbd15..6cc42f3b7 100644 --- a/apps/red-ui/src/app/modules/shared-dossiers/shared-dossiers.module.ts +++ b/apps/red-ui/src/app/modules/shared-dossiers/shared-dossiers.module.ts @@ -28,6 +28,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { DossiersListingActionsComponent } from './components/dossiers-listing-actions/dossiers-listing-actions.component'; import { IqserUsersModule } from '@iqser/common-ui/lib/users'; import { SideNavComponent, SmallChipComponent, StatusBarComponent } from '@iqser/common-ui/lib/shared'; +import { SelectComponent } from '@shared/components/select/select.component'; const components = [ FileActionsComponent, @@ -65,6 +66,7 @@ const dialogs = [EditDossierDialogComponent, AssignReviewerApproverDialogCompone DynamicInputComponent, IqserAllowDirective, IqserDenyDirective, + SelectComponent, ], }) export class SharedDossiersModule {} diff --git a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts index c55441d88..46c66374a 100644 --- a/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/buttons/file-download-btn/file-download-btn.component.ts @@ -39,7 +39,7 @@ export class FileDownloadBtnComponent implements OnChanges { } async downloadFiles() { - const ref = this._dialog.open(DownloadDialogComponent, { + const ref = this._dialog.openDefault(DownloadDialogComponent, { data: { dossier: this.dossier, files: this.files }, }); const result = await ref.result(); diff --git a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts index ff8759052..1a2d83f63 100644 --- a/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/expandable-file-actions/expandable-file-actions.component.ts @@ -79,7 +79,7 @@ export class ExpandableFileActionsComponent implements OnChanges { } async #downloadFiles(files: File[], dossier: Dossier) { - const ref = this._dialog.open(DownloadDialogComponent, { + const ref = this._dialog.openDefault(DownloadDialogComponent, { data: { dossier, files }, }); const result = await ref.result(); diff --git a/apps/red-ui/src/app/modules/shared/components/select/select.component.ts b/apps/red-ui/src/app/modules/shared/components/select/select.component.ts index be661e398..5d2ac6076 100644 --- a/apps/red-ui/src/app/modules/shared/components/select/select.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/select/select.component.ts @@ -1,11 +1,16 @@ import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostBinding, Input, TemplateRef, ViewChild } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { MatChipListbox, MatChipSelectionChange } from '@angular/material/chips'; +import { MatChipListbox, MatChipSelectionChange, MatChipsModule } from '@angular/material/chips'; +import { StopPropagationDirective } from '@iqser/common-ui'; +import { NgForOf, NgTemplateOutlet } from '@angular/common'; +import { TranslateModule } from '@ngx-translate/core'; +import { MatIconModule } from '@angular/material/icon'; @Component({ selector: 'redaction-select', templateUrl: './select.component.html', styleUrls: ['./select.component.scss'], + standalone: true, providers: [ { provide: NG_VALUE_ACCESSOR, @@ -13,16 +18,17 @@ import { MatChipListbox, MatChipSelectionChange } from '@angular/material/chips' multi: true, }, ], + imports: [StopPropagationDirective, NgTemplateOutlet, TranslateModule, NgForOf, MatChipsModule, MatIconModule], }) export class SelectComponent implements AfterViewInit, ControlValueAccessor { + private _value: any[] = []; + private _onChange: (value: any[]) => void; @Input() optionTemplate?: TemplateRef<{ option: any }>; @Input() label: string; @Input() options: any[]; @Input() disabled = false; @Input() multiple = true; @ViewChild(MatChipListbox) chipList: MatChipListbox; - private _value: any[] = []; - private _onChange: (value: any[]) => void; constructor(private readonly _changeDetector: ChangeDetectorRef, private readonly _elementRef: ElementRef) {} 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 5faffcf73..8485050a4 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 @@ -2,12 +2,17 @@ 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'; -import { AbstractControl, FormBuilder } from '@angular/forms'; +import { AbstractControl, FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { DefaultColorsService } from '@services/entity-services/default-colors.service'; -import { IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; +import { CircleButtonComponent, IconButtonComponent, IconButtonTypes, IqserDenyDirective, IqserDialogComponent } from '@iqser/common-ui'; import { Roles } from '@users/roles'; import { List } from '@iqser/common-ui/lib/utils'; import { NGXLogger } from 'ngx-logger'; +import { AsyncPipe, NgIf } from '@angular/common'; +import { SelectComponent } from '@shared/components/select/select.component'; +import { TranslateModule } from '@ngx-translate/core'; +import { ColorPickerModule } from 'ngx-color-picker'; +import { MatIconModule } from '@angular/material/icon'; export interface DownloadDialogData { readonly dossier: Dossier; @@ -23,14 +28,27 @@ export interface DownloadDialogResult { @Component({ templateUrl: './download-dialog.component.html', styleUrls: ['./download-dialog.component.scss'], + standalone: true, + imports: [ + NgIf, + ReactiveFormsModule, + SelectComponent, + TranslateModule, + IqserDenyDirective, + ColorPickerModule, + MatIconModule, + IconButtonComponent, + CircleButtonComponent, + AsyncPipe, + ], }) export class DownloadDialogComponent extends IqserDialogComponent { readonly #logger = inject(NGXLogger); readonly iconButtonTypes = IconButtonTypes; - readonly downloadTypes: { key: DownloadFileType; label: string }[] = this.#formDownloadTypes; + readonly hasApprovedFiles: boolean; + readonly downloadTypes: { key: DownloadFileType; label: string }[]; 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; @@ -41,6 +59,8 @@ export class DownloadDialogComponent extends IqserDialogComponent file.workflowStatus === WorkflowFileStatuses.APPROVED); + this.downloadTypes = this.#formDownloadTypes; } get reportTypesLength() { diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts index 5da21e2b1..b1919ca5b 100644 --- a/apps/red-ui/src/app/modules/shared/shared.module.ts +++ b/apps/red-ui/src/app/modules/shared/shared.module.ts @@ -17,7 +17,6 @@ import { IqserHelpModeModule, StopPropagationDirective, } from '@iqser/common-ui'; -import { SelectComponent } from './components/select/select.component'; import { NavigateLastDossiersScreenDirective } from './directives/navigate-last-dossiers-screen.directive'; import { DictionaryManagerComponent } from './components/dictionary-manager/dictionary-manager.component'; import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor'; @@ -43,17 +42,16 @@ import { AddEditEntityComponent } from './components/add-edit-entity/add-edit-en import { ColorPickerModule } from 'ngx-color-picker'; import { WatermarkSelectorComponent } from './components/dossier-watermark-selector/watermark-selector.component'; import { OcrProgressBarComponent } from './components/ocr-progress-bar/ocr-progress-bar.component'; -import { DownloadDialogComponent } from './dialogs/download-dialog/download-dialog.component'; import { CustomDateAdapter } from '@shared/CustomDateAdapter'; import { IqserUsersModule } from '@iqser/common-ui/lib/users'; import { SmallChipComponent } from '@iqser/common-ui/lib/shared'; +import { SelectComponent } from '@shared/components/select/select.component'; const buttons = [FileDownloadBtnComponent]; const components = [ PaginationComponent, AnnotationIconComponent, - SelectComponent, DictionaryManagerComponent, AssignUserDropdownComponent, TypeFilterComponent, @@ -82,7 +80,7 @@ const modules = [MatConfigModule, ScrollingModule, IconsModule, FormsModule, Rea const deleteThisWhenAllComponentsAreStandalone = [DonutChartComponent]; @NgModule({ - declarations: [...components, ...utils, EditorComponent, DownloadDialogComponent], + declarations: [...components, ...utils, EditorComponent], imports: [ CommonModule, ...modules, @@ -99,6 +97,7 @@ const deleteThisWhenAllComponentsAreStandalone = [DonutChartComponent]; HasScrollbarDirective, IqserAllowDirective, IqserDenyDirective, + SelectComponent, ], exports: [...modules, ...components, ...utils, ...deleteThisWhenAllComponentsAreStandalone], providers: [ diff --git a/libs/common-ui b/libs/common-ui index ae52093b5..699e74a86 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit ae52093b5d6a7f116f0c75bfae2674912dc7ff40 +Subproject commit 699e74a867e53485844e8e5bcfc91ed1d2ff2d4f