import { Grammar } from "./grammar.js"; 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: '', label: "Annuler" }; } static _createButtonAction(options) { return { icon: '', label: options.buttonLabel, callback: () => options.onAction() }; } static _createButtonActionSave(options) { return { "actionSave": { icon: '', label: options.buttonLabel + "
et ne plus demander", callback: () => { ReglesOptionnelles.set(options.settingConfirmer, false); options.onAction(); } } }; } }