fix(migration): OptionsAvancees -> ApplicationV2

Migration V1→V2 identique à ReglesOptionnelles.
+ scrollbar dans LESS (#options-avancees > .window-content)
This commit is contained in:
fabres
2026-07-22 00:29:56 +02:00
parent 36b33890db
commit 70092ffd8f
4 changed files with 48 additions and 43 deletions
+3 -1
View File
@@ -4901,8 +4901,10 @@ body {
} }
.system-foundryvtt-reve-de-dragon .window-app.regles-optionnelles > .window-content, .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.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 #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; overflow-y: auto;
} }
.system-foundryvtt-reve-de-dragon .encaissement-tables { .system-foundryvtt-reve-de-dragon .encaissement-tables {
+3 -1
View File
@@ -76,8 +76,10 @@
.window-app.regles-optionnelles > .window-content, .window-app.regles-optionnelles > .window-content,
.window-app.dialog-encaissement-tables > .window-content, .window-app.dialog-encaissement-tables > .window-content,
.window-app.options-avancees > .window-content,
#regles-optionnelles > .window-content, #regles-optionnelles > .window-content,
#dialog-encaissement-tables > .window-content { #dialog-encaissement-tables > .window-content,
#options-avancees > .window-content {
overflow-y: auto; overflow-y: auto;
} }
+30 -29
View File
@@ -1,6 +1,8 @@
import { SYSTEM_RDD } from "../constants.js" import { SYSTEM_RDD } from "../constants.js"
import { Misc } from "../misc.js" import { Misc } from "../misc.js"
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
export const EXPORT_CSV_SCRIPTARIUM = 'export-csv-scriptarium' export const EXPORT_CSV_SCRIPTARIUM = 'export-csv-scriptarium'
export const ROLL_DIALOG_V2 = 'roll-dialog-v2' 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 }, { 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() { static initSettings() {
for (const regle of OPTIONS_AVANCEES) { for (const regle of OPTIONS_AVANCEES) {
const name = regle.name 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) { static _getId(name) {
return `rdd-advanced-${name}` return `rdd-advanced-${name}`
} }
static get defaultOptions() { async _prepareContext() {
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()
const regles = OPTIONS_AVANCEES.filter(it => game.user.isGM || it.scope == "client") const regles = OPTIONS_AVANCEES.filter(it => game.user.isGM || it.scope == "client")
.map(it => { .map(it => {
it = foundry.utils.duplicate(it) it = foundry.utils.duplicate(it)
@@ -51,9 +53,10 @@ export class OptionsAvancees extends FormApplication {
it.active = OptionsAvancees.isUsing(it.name) it.active = OptionsAvancees.isUsing(it.name)
return it return it
}) })
formData.regles = regles return {
formData.groups = Misc.classify(regles, it => it.group) regles,
return formData groups: Misc.classify(regles, it => it.group),
}
} }
static getSettingKey(name) { static getSettingKey(name) {
@@ -68,17 +71,15 @@ export class OptionsAvancees extends FormApplication {
return game.settings.set(SYSTEM_RDD, OptionsAvancees._getId(name), value ? true : false) return game.settings.set(SYSTEM_RDD, OptionsAvancees._getId(name), value ? true : false)
} }
activateListeners(html) { async _onRender(context, options) {
$(html).find(".select-option").click((event) => { this.element.querySelectorAll(".select-option").forEach(el => {
if (event.currentTarget.attributes.name) { el.addEventListener("click", async event => {
let id = event.currentTarget.attributes.name.value const id = event.currentTarget.getAttribute("name")
let isChecked = event.currentTarget.checked if (id) {
game.settings.set(SYSTEM_RDD, id, isChecked) const isChecked = event.currentTarget.checked
} await game.settings.set(SYSTEM_RDD, id, isChecked)
}
})
}) })
} }
async _updateObject(event, formData) {
this.close()
}
} }
+12 -12
View File
@@ -1,13 +1,13 @@
<form autocomplete="off" onsubmit="event.preventDefault();"> <div>
{{#each groups as |group key|}} {{#each groups as |group key|}}
<h3>{{key}}</h3> <h3>{{key}}</h3>
<ul> <ul>
{{#each group as |regle r|}} {{#each group as |regle r|}}
<li> <li>
<input class="select-option" type="checkbox" name="{{regle.id}}" {{#if regle.active}}checked{{/if}}/> <input class="select-option" type="checkbox" name="{{regle.id}}" {{#if regle.active}}checked{{/if}}/>
<label>{{regle.descr}}</label> <label>{{regle.descr}}</label>
</li> </li>
{{/each}}
</ul>
{{/each}} {{/each}}
</form> </ul>
{{/each}}
</div>