foundryvtt-reve-de-dragon/module/rdd-confirm.js

50 lines
1.5 KiB
JavaScript
Raw Normal View History

import { Grammar } from "./grammar.js";
2023-06-20 23:43:24 +02:00
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js";
export class RdDConfirm {
/* -------------------------------------------- */
static confirmer(options, autresActions) {
let buttons = {
"action": RdDConfirm._createButtonAction(options),
"cancel": RdDConfirm._createButtonCancel()
};
if (options.settingConfirmer) {
buttons = foundry.utils.mergeObject(RdDConfirm._createButtonActionSave(options), buttons);
}
if (autresActions) {
buttons = foundry.utils.mergeObject(autresActions, buttons);
}
const dialogDetails = {
title: options.title,
content: options.content,
default: "cancel",
buttons: buttons
};
new Dialog(dialogDetails, { width: 150 * Object.keys(buttons).length }).render(true);
}
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": {
icon: '<i class="fas fa-user-check"></i>',
label: options.buttonLabel + "<br>et ne plus demander",
callback: () => {
2023-06-20 23:43:24 +02:00
ReglesOptionnelles.set(options.settingConfirmer, false);
options.onAction();
}
}
};
}
}