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.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 {
+3 -1
View File
@@ -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;
}
+30 -29
View File
@@ -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()
}
}
+12 -12
View File
@@ -1,13 +1,13 @@
<form autocomplete="off" onsubmit="event.preventDefault();">
{{#each groups as |group key|}}
<h3>{{key}}</h3>
<ul>
{{#each group as |regle r|}}
<li>
<input class="select-option" type="checkbox" name="{{regle.id}}" {{#if regle.active}}checked{{/if}}/>
<label>{{regle.descr}}</label>
</li>
{{/each}}
</ul>
<div>
{{#each groups as |group key|}}
<h3>{{key}}</h3>
<ul>
{{#each group as |regle r|}}
<li>
<input class="select-option" type="checkbox" name="{{regle.id}}" {{#if regle.active}}checked{{/if}}/>
<label>{{regle.descr}}</label>
</li>
{{/each}}
</form>
</ul>
{{/each}}
</div>