From 70092ffd8f65d7598cb38a404688d8656ab9b705 Mon Sep 17 00:00:00 2001 From: fabres Date: Sat, 18 Jul 2026 00:02:03 +0200 Subject: [PATCH] fix(migration): OptionsAvancees -> ApplicationV2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migration V1→V2 identique à ReglesOptionnelles. + scrollbar dans LESS (#options-avancees > .window-content) --- css/foundryvtt-reve-de-dragon.css | 4 +- less/foundryvtt-reve-de-dragon.less | 4 +- module/settings/options-avancees.js | 59 +++++++++++++------------ templates/settings/options-avancees.hbs | 24 +++++----- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/css/foundryvtt-reve-de-dragon.css b/css/foundryvtt-reve-de-dragon.css index 8cbae619..cfb6f5e5 100644 --- a/css/foundryvtt-reve-de-dragon.css +++ b/css/foundryvtt-reve-de-dragon.css @@ -4901,8 +4901,10 @@ body { } .system-foundryvtt-reve-de-dragon .window-app.regles-optionnelles > .window-content, .system-foundryvtt-reve-de-dragon .window-app.dialog-encaissement-tables > .window-content, +.system-foundryvtt-reve-de-dragon .window-app.options-avancees > .window-content, .system-foundryvtt-reve-de-dragon #regles-optionnelles > .window-content, -.system-foundryvtt-reve-de-dragon #dialog-encaissement-tables > .window-content { +.system-foundryvtt-reve-de-dragon #dialog-encaissement-tables > .window-content, +.system-foundryvtt-reve-de-dragon #options-avancees > .window-content { overflow-y: auto; } .system-foundryvtt-reve-de-dragon .encaissement-tables { diff --git a/less/foundryvtt-reve-de-dragon.less b/less/foundryvtt-reve-de-dragon.less index 6ce70e01..6449b185 100644 --- a/less/foundryvtt-reve-de-dragon.less +++ b/less/foundryvtt-reve-de-dragon.less @@ -76,8 +76,10 @@ .window-app.regles-optionnelles > .window-content, .window-app.dialog-encaissement-tables > .window-content, + .window-app.options-avancees > .window-content, #regles-optionnelles > .window-content, - #dialog-encaissement-tables > .window-content { + #dialog-encaissement-tables > .window-content, + #options-avancees > .window-content { overflow-y: auto; } diff --git a/module/settings/options-avancees.js b/module/settings/options-avancees.js index 96e75ae1..4b0ba77a 100644 --- a/module/settings/options-avancees.js +++ b/module/settings/options-avancees.js @@ -1,6 +1,8 @@ import { SYSTEM_RDD } from "../constants.js" import { Misc } from "../misc.js" +const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api + export const EXPORT_CSV_SCRIPTARIUM = 'export-csv-scriptarium' export const ROLL_DIALOG_V2 = 'roll-dialog-v2' @@ -9,7 +11,7 @@ const OPTIONS_AVANCEES = [ { group: 'Menus', name: EXPORT_CSV_SCRIPTARIUM, descr: "Proposer le menu d'export csv Scriptarium", default: false }, ] -export class OptionsAvancees extends FormApplication { +export class OptionsAvancees extends HandlebarsApplicationMixin(ApplicationV2) { static initSettings() { for (const regle of OPTIONS_AVANCEES) { const name = regle.name @@ -26,24 +28,24 @@ export class OptionsAvancees extends FormApplication { }) } + static DEFAULT_OPTIONS = { + tag: "form", + id: "options-avancees", + classes: ["options-avancees"], + form: { submitOnChange: false, closeOnSubmit: true }, + position: { width: 550, height: 650 }, + window: { title: "Options avancées", icon: "fa-solid fa-bars" } + } + + static PARTS = { + form: { template: "systems/foundryvtt-reve-de-dragon/templates/settings/options-avancees.hbs" } + } + static _getId(name) { return `rdd-advanced-${name}` } - static get defaultOptions() { - return foundry.utils.mergeObject(super.defaultOptions, { - id: "options-avancees", - template: "systems/foundryvtt-reve-de-dragon/templates/settings/options-avancees.hbs", - height: 650, - width: 550, - minimizable: false, - closeOnSubmit: true, - title: "Options avancées" - }, { inplace: false }) - } - - getData() { - let formData = super.getData() + async _prepareContext() { const regles = OPTIONS_AVANCEES.filter(it => game.user.isGM || it.scope == "client") .map(it => { it = foundry.utils.duplicate(it) @@ -51,9 +53,10 @@ export class OptionsAvancees extends FormApplication { it.active = OptionsAvancees.isUsing(it.name) return it }) - formData.regles = regles - formData.groups = Misc.classify(regles, it => it.group) - return formData + return { + regles, + groups: Misc.classify(regles, it => it.group), + } } static getSettingKey(name) { @@ -68,17 +71,15 @@ export class OptionsAvancees extends FormApplication { return game.settings.set(SYSTEM_RDD, OptionsAvancees._getId(name), value ? true : false) } - activateListeners(html) { - $(html).find(".select-option").click((event) => { - if (event.currentTarget.attributes.name) { - let id = event.currentTarget.attributes.name.value - let isChecked = event.currentTarget.checked - game.settings.set(SYSTEM_RDD, id, isChecked) - } + async _onRender(context, options) { + this.element.querySelectorAll(".select-option").forEach(el => { + el.addEventListener("click", async event => { + const id = event.currentTarget.getAttribute("name") + if (id) { + const isChecked = event.currentTarget.checked + await game.settings.set(SYSTEM_RDD, id, isChecked) + } + }) }) } - - async _updateObject(event, formData) { - this.close() - } } diff --git a/templates/settings/options-avancees.hbs b/templates/settings/options-avancees.hbs index 6ea970cd..3f44c53a 100644 --- a/templates/settings/options-avancees.hbs +++ b/templates/settings/options-avancees.hbs @@ -1,13 +1,13 @@ -
- {{#each groups as |group key|}} -

{{key}}

- +
+{{#each groups as |group key|}} +

{{key}}

+
    + {{#each group as |regle r|}} +
  • + + +
  • {{/each}} - \ No newline at end of file +
+{{/each}} +
\ No newline at end of file