report count in dialog
This commit is contained in:
parent
e69a6b64bd
commit
b0d088fc7a
@ -5,7 +5,7 @@
|
||||
| translate
|
||||
: {
|
||||
type: type,
|
||||
name: attribute?.label
|
||||
name: data.attribute?.label
|
||||
}
|
||||
}}
|
||||
</div>
|
||||
@ -20,14 +20,11 @@
|
||||
<div class="dialog-content">
|
||||
<div class="heading" translate="confirm-delete-file-attribute.warning"></div>
|
||||
|
||||
<mat-checkbox
|
||||
*ngFor="let checkbox of checkboxes; let idx = index"
|
||||
[(ngModel)]="checkbox.value"
|
||||
[class.error]="!checkbox.value && showToast"
|
||||
color="primary"
|
||||
>
|
||||
{{ checkbox.label | translate: { type: type } }}
|
||||
</mat-checkbox>
|
||||
<ng-container *ngFor="let checkbox of checkboxes; let idx = index">
|
||||
<mat-checkbox [(ngModel)]="checkbox.value" [class.error]="!checkbox.value && showToast" color="primary">
|
||||
{{ checkbox.label }}
|
||||
</mat-checkbox>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
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';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
const isFileAttributeConfig = (value: DossierAttributeConfig | FileAttributeConfig): value is FileAttributeConfig => {
|
||||
return value instanceof FileAttributeConfig;
|
||||
};
|
||||
const isFileAttributeConfig = (value: DossierAttributeConfig | FileAttributeConfig): value is FileAttributeConfig =>
|
||||
value instanceof FileAttributeConfig;
|
||||
|
||||
interface CheckBox {
|
||||
value: boolean;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface DialogData {
|
||||
attribute: FileAttributeConfig | DossierAttributeConfig;
|
||||
count: number;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-confirm-delete-attribute-dialog',
|
||||
templateUrl: './confirm-delete-attribute-dialog.component.html',
|
||||
@ -22,32 +26,42 @@ export class ConfirmDeleteAttributeDialogComponent {
|
||||
showToast = false;
|
||||
|
||||
constructor(
|
||||
private readonly _translateService: TranslateService,
|
||||
public dialogRef: MatDialogRef<ConfirmDeleteAttributeDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public attribute: FileAttributeConfig | DossierAttributeConfig,
|
||||
@Inject(MAT_DIALOG_DATA) public data: DialogData,
|
||||
) {
|
||||
this.checkboxes = this.checkBoxConfig;
|
||||
}
|
||||
|
||||
get checkBoxConfig(): CheckBox[] {
|
||||
return isFileAttributeConfig(this.attribute)
|
||||
const checkBoxes = isFileAttributeConfig(this.data.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: 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: _('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') },
|
||||
{ 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') },
|
||||
];
|
||||
if (this.data.count !== 0) {
|
||||
checkBoxes.push({
|
||||
value: false,
|
||||
label: this._translateService.instant('confirm-delete-file-attribute.impacted-report', { count: this.data.count }),
|
||||
});
|
||||
}
|
||||
|
||||
return checkBoxes;
|
||||
}
|
||||
|
||||
get valid() {
|
||||
return this.checkboxes[0].value && this.checkboxes[1].value;
|
||||
return this.checkboxes.reduce((initialValue, currentValue) => initialValue && currentValue.value, true);
|
||||
}
|
||||
|
||||
get type(): 'bulk' | 'single' {
|
||||
return this.attribute ? 'single' : 'bulk';
|
||||
return this.data.attribute ? 'single' : 'bulk';
|
||||
}
|
||||
|
||||
deleteFileAttribute() {
|
||||
|
||||
@ -57,10 +57,11 @@ export class DossierAttributesListingScreenComponent extends ListingComponent<Do
|
||||
|
||||
async openConfirmDeleteAttributeDialog($event: MouseEvent, dossierAttribute?: DossierAttributeConfig) {
|
||||
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
|
||||
const resp = await firstValueFrom(this._reportTemplateService.getTemplatesByPlaceholder(dossierTemplateId, dossierAttribute.id));
|
||||
console.log(resp);
|
||||
const resp = await firstValueFrom(
|
||||
this._reportTemplateService.getTemplatesByPlaceholder(dossierTemplateId, dossierAttribute.placeholder),
|
||||
);
|
||||
|
||||
this._dialogService.openDialog('deleteAttribute', $event, dossierAttribute, async () => {
|
||||
this._dialogService.openDialog('deleteAttribute', $event, { attribute: dossierAttribute, count: resp.length }, async () => {
|
||||
this._loadingService.start();
|
||||
const ids = dossierAttribute ? [dossierAttribute.id] : this.listingService.selected.map(item => item.id);
|
||||
await firstValueFrom(this._dossierAttributesService.delete(ids));
|
||||
|
||||
@ -18,6 +18,7 @@ import { FileAttributesService } from '@services/entity-services/file-attributes
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { HttpStatusCode } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { ReportTemplateService } from '../../../../services/report-template.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './file-attributes-listing-screen.component.html',
|
||||
@ -60,6 +61,7 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
|
||||
private readonly _dossierTemplatesService: DossierTemplatesService,
|
||||
private readonly _dialogService: AdminDialogService,
|
||||
private readonly _fileAttributesService: FileAttributesService,
|
||||
private readonly _reportTemplateService: ReportTemplateService,
|
||||
) {
|
||||
super(_injector);
|
||||
}
|
||||
@ -88,10 +90,14 @@ export class FileAttributesListingScreenComponent extends ListingComponent<FileA
|
||||
});
|
||||
}
|
||||
|
||||
openConfirmDeleteAttributeDialog($event: MouseEvent, fileAttribute?: FileAttributeConfig) {
|
||||
this._dialogService.openDialog('deleteAttribute', $event, fileAttribute, async () => {
|
||||
async openConfirmDeleteAttributeDialog($event: MouseEvent, fileAttribute?: FileAttributeConfig) {
|
||||
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
|
||||
const resp = await firstValueFrom(
|
||||
this._reportTemplateService.getTemplatesByPlaceholder(dossierTemplateId, fileAttribute.placeholder),
|
||||
);
|
||||
|
||||
this._dialogService.openDialog('deleteAttribute', $event, { attribute: fileAttribute, count: resp.length }, async () => {
|
||||
this._loadingService.start();
|
||||
const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId;
|
||||
if (fileAttribute) {
|
||||
await firstValueFrom(this._fileAttributesService.deleteFileAttributes([fileAttribute.id], dossierTemplateId));
|
||||
} else {
|
||||
|
||||
@ -45,7 +45,7 @@ export class ReportTemplateService extends GenericService<unknown> {
|
||||
|
||||
@Validate()
|
||||
getTemplatesByPlaceholder(@RequiredParam() dossierTemplateId: string, @RequiredParam() attributeId: string) {
|
||||
return this._post({ value: attributeId }, `/templates/${dossierTemplateId}`);
|
||||
return this._post<IReportTemplate[]>({ value: attributeId }, `templates/${dossierTemplateId}`);
|
||||
}
|
||||
|
||||
downloadReportTemplate(dossierTemplateId: string, templateId: string, observe: 'response'): Observable<HttpResponse<Blob>>;
|
||||
|
||||
@ -395,11 +395,14 @@
|
||||
"confirm-delete-file-attribute": {
|
||||
"cancel": "{type, select, single{Attribut} bulk{Attribute} other{}} behalten",
|
||||
"delete": "{type, select, single{Attribut} bulk{Attribute} other{}} löschen",
|
||||
"impacted-documents": "Alle Dokumente {type, select, single{ist} bulk{sind} other{}} betroffen",
|
||||
"lost-details": "Alle in die Dokumente eingegebenen Daten gehen verloren",
|
||||
"file-impacted-documents": "Alle Dokumente {type, select, single{ist} bulk{sind} other{}} betroffen",
|
||||
"dossier-impacted-documents": "",
|
||||
"file-lost-details": "Alle in die Dokumente eingegebenen Daten gehen verloren",
|
||||
"dossier-lost-details": "",
|
||||
"title": "{type, select, single{{name}} bulk{Datei-Attribute} other{}} löschen",
|
||||
"toast-error": "Bitte bestätigen Sie, dass Ihnen die Konsequenzen dieser Aktion bewusst sind!",
|
||||
"warning": "Achtung: Diese Aktion kann nicht rückgängig gemacht werden!"
|
||||
"warning": "Achtung: Diese Aktion kann nicht rückgängig gemacht werden!",
|
||||
"impacted-report": "{count}"
|
||||
},
|
||||
"confirm-delete-users": {
|
||||
"cancel": "{usersCount, plural, one{Benutzer} other{Benutzer}} behalten",
|
||||
|
||||
@ -402,7 +402,7 @@
|
||||
"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!",
|
||||
"impacted-report": "<#reports> reports use the placeholder for this attribute and need to be adjusted"
|
||||
"impacted-report": "{count} reports use the placeholder for this attribute and need to be adjusted"
|
||||
},
|
||||
"confirm-delete-users": {
|
||||
"cancel": "Keep {usersCount, plural, one{User} other{Users}}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user