RED-5406 - updated confirmation dialog component to can confirm it without being mandatory on all cases to select checkboxes if they exist

This commit is contained in:
Valentin Mihai 2022-11-15 13:42:38 +02:00
parent 7367c31d37
commit 062977dd25
2 changed files with 13 additions and 2 deletions

View File

@ -31,7 +31,7 @@
<div class="dialog-actions">
<button
(click)="confirm(ConfirmOptions.CONFIRM)"
(click)="confirm(confirmOption)"
[disabled]="(config.requireInput && confirmationDoesNotMatch()) || config.disableConfirm"
color="primary"
id="confirm"

View File

@ -36,6 +36,7 @@ interface IConfirmationDialogInput {
denyText?: string;
translateParams?: Record<string, unknown>;
checkboxes?: CheckBox[];
checkboxesValidation?: boolean;
toastMessage?: string;
}
@ -52,8 +53,10 @@ export class ConfirmationDialogInput implements IConfirmationDialogInput {
denyText: string;
translateParams: Record<string, unknown>;
checkboxes: CheckBox[];
checkboxesValidation: boolean;
toastMessage?: string;
constructor(options?: IConfirmationDialogInput) {
this.title = options?.title || _('common.confirmation-dialog.title');
this.titleColor = options?.titleColor || TitleColors.DEFAULT;
@ -67,6 +70,7 @@ export class ConfirmationDialogInput implements IConfirmationDialogInput {
this.denyText = options?.denyText || _('common.confirmation-dialog.deny');
this.translateParams = options?.translateParams || {};
this.checkboxes = options?.checkboxes || [];
this.checkboxesValidation = typeof options?.checkboxesValidation === "boolean"? options.checkboxesValidation : true;
this.toastMessage = options?.toastMessage;
}
}
@ -94,7 +98,7 @@ export class ConfirmationDialogComponent {
}
get uncheckedBoxes(): boolean {
return this.config.checkboxes.some(c => !c.value);
return this.config.checkboxesValidation && this.config.checkboxes.some(c => !c.value);
}
get isDeleteAction(): boolean {
@ -143,4 +147,11 @@ export class ConfirmationDialogComponent {
});
});
}
get confirmOption(): ConfirmOptions {
if (!this.config.checkboxesValidation && this.config.checkboxes[0]?.value) {
return ConfirmOptions.SECOND_CONFIRM;
}
return ConfirmOptions.CONFIRM;
}
}