Various fixes and changes based on tester feedback

This commit is contained in:
2026-03-17 13:50:32 +01:00
parent 92ba9c3501
commit 000bf348a6
29 changed files with 1450 additions and 192 deletions

View File

@@ -28,15 +28,26 @@ export default class OathHammerClassSheet extends OathHammerItemSheet {
return context
}
/** @override — collect checkbox sets explicitly so unchecking all works */
_prepareSubmitData(event, form, formData) {
const data = super._prepareSubmitData(event, form, formData)
data["system.armorProficiency"] = Array.from(
form.querySelectorAll('input[name="system.armorProficiency"]:checked')
).map(el => el.value)
data["system.weaponProficiency"] = Array.from(
form.querySelectorAll('input[name="system.weaponProficiency"]:checked')
).map(el => el.value)
return data
/** @override */
_onRender(context, options) {
super._onRender(context, options)
// Handle proficiency checkboxes directly — FormDataExtended mishandles
// multiple same-named checkboxes, so we intercept the change event,
// collect all checked values ourselves, and stop propagation to prevent
// the generic submitOnChange handler from clobbering the data.
for (const cb of this.element.querySelectorAll('.proficiency-checkboxes input[type="checkbox"]')) {
cb.addEventListener("change", this.#onProficiencyChange.bind(this))
}
}
async #onProficiencyChange(event) {
event.stopPropagation()
const root = this.element
const armorProficiency = [...root.querySelectorAll('input[name="system.armorProficiency"]:checked')].map(e => e.value)
const weaponProficiency = [...root.querySelectorAll('input[name="system.weaponProficiency"]:checked')].map(e => e.value)
await this.document.update({
"system.armorProficiency": armorProficiency,
"system.weaponProficiency": weaponProficiency,
})
}
}