2023-06-20 23:43:24 +02:00
|
|
|
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
|
2022-10-04 23:23:43 +02:00
|
|
|
|
|
|
|
export class RdDConfirm {
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
static confirmer(options, autresActions) {
|
2024-06-29 00:07:48 +02:00
|
|
|
if (options.settingConfirmer && !ReglesOptionnelles.isSet(options.settingConfirmer)) {
|
|
|
|
return options.onAction()
|
|
|
|
}
|
2024-05-26 22:13:47 +02:00
|
|
|
let buttons = {
|
|
|
|
"action": RdDConfirm._createButtonAction(options),
|
|
|
|
"cancel": RdDConfirm._createButtonCancel()
|
|
|
|
};
|
|
|
|
if (options.settingConfirmer) {
|
|
|
|
buttons = foundry.utils.mergeObject(RdDConfirm._createButtonActionSave(options), buttons);
|
2022-10-04 23:23:43 +02:00
|
|
|
}
|
2024-05-26 22:13:47 +02:00
|
|
|
if (autresActions) {
|
2024-06-01 01:53:14 +02:00
|
|
|
buttons = foundry.utils.mergeObject(autresActions, buttons, { inplace: false });
|
2022-10-04 23:23:43 +02:00
|
|
|
}
|
2024-05-26 22:13:47 +02:00
|
|
|
const dialogDetails = {
|
|
|
|
title: options.title,
|
|
|
|
content: options.content,
|
|
|
|
default: "cancel",
|
|
|
|
buttons: buttons
|
|
|
|
};
|
|
|
|
new Dialog(dialogDetails, { width: 150 * Object.keys(buttons).length }).render(true);
|
2022-10-04 23:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static _createButtonCancel() {
|
|
|
|
return { icon: '<i class="fas fa-times"></i>', label: "Annuler" };
|
|
|
|
}
|
|
|
|
|
|
|
|
static _createButtonAction(options) {
|
|
|
|
return {
|
|
|
|
icon: '<i class="fas fa-check"></i>',
|
|
|
|
label: options.buttonLabel,
|
|
|
|
callback: () => options.onAction()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static _createButtonActionSave(options) {
|
|
|
|
return {
|
|
|
|
"actionSave": {
|
2022-10-04 23:45:14 +02:00
|
|
|
icon: '<i class="fas fa-user-check"></i>',
|
2022-11-28 12:03:49 +01:00
|
|
|
label: options.buttonLabel + "<br>et ne plus demander",
|
2022-10-04 23:23:43 +02:00
|
|
|
callback: () => {
|
2023-06-20 23:43:24 +02:00
|
|
|
ReglesOptionnelles.set(options.settingConfirmer, false);
|
2022-10-04 23:23:43 +02:00
|
|
|
options.onAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|