From 46cec7e6b82bd63112af0603063f24a698db4e97 Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Wed, 26 Jan 2022 20:48:15 +0200 Subject: [PATCH] refactoring && update common --- ...irm-delete-attribute-dialog.component.html | 11 +---- ...nfirm-delete-attribute-dialog.component.ts | 45 +++++++++++-------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component.html b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component.html index a6ac8607a..b7442e49a 100644 --- a/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component.html +++ b/apps/red-ui/src/app/modules/admin/dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component.html @@ -1,13 +1,6 @@
- {{ - 'confirm-delete-file-attribute.title' - | translate - : { - type: type, - name: data.attribute?.label - } - }} + {{ 'confirm-delete-file-attribute.title' | translate: translateArgs }}
@@ -32,7 +25,7 @@ {{ 'confirm-delete-file-attribute.delete' | translate: { type: type } }}
, + readonly dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: DialogData, ) { this.checkboxes = this.checkBoxConfig; } get checkBoxConfig(): CheckBox[] { - const checkBoxes = isFileAttributeConfig(this.data.attribute) - ? [ - { - value: false, - label: this._translateService.instant('confirm-delete-file-attribute.file-impacted-documents', { type: this.type }), - }, - { value: false, label: this._translateService.instant('confirm-delete-file-attribute.file-lost-details') }, - ] - : [ - { value: false, label: this._translateService.instant('confirm-delete-file-attribute.dossier-impacted-documents') }, - { value: false, label: this._translateService.instant('confirm-delete-file-attribute.dossier-lost-details') }, - ]; + const checkBoxes = isFileAttributeConfig(this.data.attribute) ? this._fileAttributeCheckboxes : this._dossierAttributeCheckboxes; if (this.data.count !== 0) { checkBoxes.push({ value: false, @@ -57,13 +46,37 @@ export class ConfirmDeleteAttributeDialogComponent { } get valid() { - return this.checkboxes.reduce((initialValue, currentValue) => initialValue && currentValue.value, true); + return this.checkboxes.reduce((acc, currentValue) => acc && currentValue.value, true); } get type(): 'bulk' | 'single' { return this.data.attribute ? 'single' : 'bulk'; } + get translateArgs() { + return { + type: this.type, + name: this.data.attribute?.label, + }; + } + + private get _fileAttributeCheckboxes(): CheckBox[] { + return [ + { + value: false, + label: this._translateService.instant('confirm-delete-file-attribute.file-impacted-documents', { type: this.type }), + }, + { value: false, label: this._translateService.instant('confirm-delete-file-attribute.file-lost-details') }, + ]; + } + + private get _dossierAttributeCheckboxes(): CheckBox[] { + return [ + { value: false, label: this._translateService.instant('confirm-delete-file-attribute.dossier-impacted-documents') }, + { value: false, label: this._translateService.instant('confirm-delete-file-attribute.dossier-lost-details') }, + ]; + } + deleteFileAttribute() { if (this.valid) { this.dialogRef.close(true); @@ -71,8 +84,4 @@ export class ConfirmDeleteAttributeDialogComponent { this.showToast = true; } } - - cancel() { - this.dialogRef.close(); - } }