dossier and file attributes dialog in the same component

This commit is contained in:
Edi Cziszter 2022-01-20 13:12:18 +02:00
parent 1a3e66f4f6
commit 3fb05c2e6e
9 changed files with 81 additions and 59 deletions

View File

@ -17,7 +17,7 @@ import { ColorPickerModule } from 'ngx-color-picker';
import { AddEditFileAttributeDialogComponent } from './dialogs/add-edit-file-attribute-dialog/add-edit-file-attribute-dialog.component';
import { AddEditDossierTemplateDialogComponent } from './dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component';
import { AddEditDictionaryDialogComponent } from './dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component';
import { ConfirmDeleteFileAttributeDialogComponent } from './dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component';
import { ConfirmDeleteAttributeDialogComponent } from './dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component';
import { EditColorDialogComponent } from './dialogs/edit-color-dialog/edit-color-dialog.component';
import { ComboChartComponent, ComboSeriesVerticalComponent } from './components/combo-chart';
import { NgxChartsModule } from '@swimlane/ngx-charts';
@ -53,7 +53,7 @@ const dialogs = [
AddEditDossierTemplateDialogComponent,
AddEditDictionaryDialogComponent,
AddEditFileAttributeDialogComponent,
ConfirmDeleteFileAttributeDialogComponent,
ConfirmDeleteAttributeDialogComponent,
EditColorDialogComponent,
SmtpAuthDialogComponent,
AddEditUserDialogComponent,

View File

@ -0,0 +1,64 @@
import { Component, Inject } from '@angular/core';
import { DossierAttributeConfig, FileAttributeConfig } from '@red/domain';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
const isFileAttributeConfig = (value: DossierAttributeConfig | FileAttributeConfig): value is FileAttributeConfig => {
return value instanceof FileAttributeConfig;
};
interface CheckBox {
value: boolean;
label: string;
}
@Component({
selector: 'redaction-confirm-delete-attribute-dialog',
templateUrl: './confirm-delete-attribute-dialog.component.html',
styleUrls: ['./confirm-delete-attribute-dialog.component.scss'],
})
export class ConfirmDeleteAttributeDialogComponent {
checkboxes: CheckBox[];
showToast = false;
constructor(
public dialogRef: MatDialogRef<ConfirmDeleteAttributeDialogComponent>,
@Inject(MAT_DIALOG_DATA) public attribute: FileAttributeConfig | DossierAttributeConfig,
) {
this.checkboxes = this.checkBoxConfig;
}
get checkBoxConfig(): CheckBox[] {
return isFileAttributeConfig(this.attribute)
? [
{ value: false, label: _('confirm-delete-file-attribute.file-impacted-documents') },
{ value: false, label: _('confirm-delete-file-attribute.file-lost-details') },
{ value: false, label: _('confirm-delete-file-attribute.impacted-report') },
]
: [
{ value: false, label: _('confirm-delete-file-attribute.dossier-impacted-documents') },
{ value: false, label: _('confirm-delete-file-attribute.dossier-lost-details') },
{ value: false, label: _('confirm-delete-file-attribute.impacted-report') },
];
}
get valid() {
return this.checkboxes[0].value && this.checkboxes[1].value;
}
get type(): 'bulk' | 'single' {
return this.attribute ? 'single' : 'bulk';
}
deleteFileAttribute() {
if (this.valid) {
this.dialogRef.close(true);
} else {
this.showToast = true;
}
}
cancel() {
this.dialogRef.close();
}
}

View File

@ -1,45 +0,0 @@
import { Component, Inject } from '@angular/core';
import { IFileAttributeConfig } from '@red/domain';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({
selector: 'redaction-confirm-delete-file-attribute-dialog',
templateUrl: './confirm-delete-file-attribute-dialog.component.html',
styleUrls: ['./confirm-delete-file-attribute-dialog.component.scss'],
})
export class ConfirmDeleteFileAttributeDialogComponent {
fileAttribute: IFileAttributeConfig;
checkboxes = [
{ value: false, label: _('confirm-delete-file-attribute.impacted-documents') },
{ value: false, label: _('confirm-delete-file-attribute.lost-details') },
];
showToast = false;
constructor(
public dialogRef: MatDialogRef<ConfirmDeleteFileAttributeDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: IFileAttributeConfig,
) {
this.fileAttribute = data;
}
get valid() {
return this.checkboxes[0].value && this.checkboxes[1].value;
}
get type(): 'bulk' | 'single' {
return this.fileAttribute ? 'single' : 'bulk';
}
deleteFileAttribute() {
if (this.valid) {
this.dialogRef.close(true);
} else {
this.showToast = true;
}
}
cancel() {
this.dialogRef.close();
}
}

View File

@ -53,8 +53,8 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
await this._loadData();
}
openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: IDossierAttributeConfig) {
this._dialogService.openDialog('confirm', $event, null, async () => {
openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) {
this._dialogService.openDialog('deleteAttribute', $event, dossierAttribute, async () => {
this._loadingService.start();
const ids = dossierAttribute ? [dossierAttribute.id] : this.listingService.selected.map(item => item.id);
await firstValueFrom(this._dossierAttributesService.delete(ids));

View File

@ -88,8 +88,8 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
});
}
openConfirmDeleteAttributeDialog($event: MouseEvent, fileAttribute?: IFileAttributeConfig) {
this._dialogService.openDialog('deleteFileAttribute', $event, fileAttribute, async () => {
openConfirmDeleteAttributeDialog($event: MouseEvent, fileAttribute?: FileAttributeConfig) {
this._dialogService.openDialog('deleteAttribute', $event, fileAttribute, async () => {
this._loadingService.start();
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
if (fileAttribute) {

View File

@ -3,7 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
import { AddEditFileAttributeDialogComponent } from '../dialogs/add-edit-file-attribute-dialog/add-edit-file-attribute-dialog.component';
import { AddEditDictionaryDialogComponent } from '../dialogs/add-edit-dictionary-dialog/add-edit-dictionary-dialog.component';
import { AddEditDossierTemplateDialogComponent } from '../dialogs/add-edit-dossier-template-dialog/add-edit-dossier-template-dialog.component';
import { ConfirmDeleteFileAttributeDialogComponent } from '../dialogs/confirm-delete-file-attribute-dialog/confirm-delete-file-attribute-dialog.component';
import { ConfirmDeleteAttributeDialogComponent } from '../dialogs/confirm-delete-attribute-dialog/confirm-delete-attribute-dialog.component';
import { EditColorDialogComponent } from '../dialogs/edit-color-dialog/edit-color-dialog.component';
import { SmtpAuthDialogComponent } from '../dialogs/smtp-auth-dialog/smtp-auth-dialog.component';
import { AddEditUserDialogComponent } from '../dialogs/add-edit-user-dialog/add-edit-user-dialog.component';
@ -19,7 +19,7 @@ type DialogType =
| 'addEditDictionary'
| 'editColor'
| 'addEditFileAttribute'
| 'deleteFileAttribute'
| 'deleteAttribute'
| 'importFileAttributes'
| 'addEditUser'
| 'deleteUsers'
@ -48,8 +48,8 @@ export class AdminDialogService extends DialogService<DialogType> {
component: AddEditFileAttributeDialogComponent,
dialogConfig: { autoFocus: true },
},
deleteFileAttribute: {
component: ConfirmDeleteFileAttributeDialogComponent,
deleteAttribute: {
component: ConfirmDeleteAttributeDialogComponent,
dialogConfig: { disableClose: false },
},
importFileAttributes: {

View File

@ -395,11 +395,14 @@
"confirm-delete-file-attribute": {
"cancel": "Keep {type, select, single{Attribute} bulk{Attributes} other{}}",
"delete": "Delete {type, select, single{Attribute} bulk{Attributes} other{}}",
"impacted-documents": "All documents {type, select, single{it is} bulk{they are} other{}} used on will be impacted",
"lost-details": "All inputted details on the documents will be lost",
"file-impacted-documents": "All documents {type, select, single{it is} bulk{they are} other{}} used on will be impacted",
"dossier-impacted-documents": "All dossiers based on this template will be affected",
"file-lost-details": "All inputted details on the documents will be lost",
"dossier-lost-details": "All values for this attribute will be lost",
"title": "Delete {type, select, single{{name}} bulk{File Attributes} other{}}",
"toast-error": "Please confirm that you understand the ramifications of your action!",
"warning": "Warning: this cannot be undone!"
"warning": "Warning: this cannot be undone!",
"impacted-report": "<#reports> reports use the placeholder for this attribute and need to be adjusted"
},
"confirm-delete-users": {
"cancel": "Keep {usersCount, plural, one{User} other{Users}}",