DIvers petites corrections pour les specialités et les competences
All checks were successful
Release Creation / build (release) Successful in 54s

This commit is contained in:
2026-01-18 18:39:51 +01:00
parent d3c24e44d8
commit f445741eda
66 changed files with 277 additions and 238 deletions

View File

@@ -186,7 +186,8 @@ export default class HeritiersActorSheet extends HandlebarsApplicationMixin(foun
const itemType = li?.dataset.itemType
const itemField = event.target.dataset.itemField
const dataType = event.target.dataset.dtype
const value = event.target.value
// Pour les checkboxes, utiliser checked au lieu de value
const value = event.target.type === 'checkbox' ? event.target.checked : event.target.value
if (itemId && itemType && itemField) {
this.actor.editItemField(itemId, itemType, itemField, dataType, value)
}

View File

@@ -11,8 +11,6 @@ export default class HeritiersCompetenceSheet extends HeritiersItemSheet {
actions: {
addSpecialite: HeritiersCompetenceSheet.#onAddSpecialite,
deleteSpecialite: HeritiersCompetenceSheet.#onDeleteSpecialite,
editSpecialite: HeritiersCompetenceSheet.#onEditSpecialite,
editSpecialiteDescription: HeritiersCompetenceSheet.#onEditSpecialiteDescription,
}
}
@@ -23,43 +21,55 @@ export default class HeritiersCompetenceSheet extends HeritiersItemSheet {
},
}
/** @override */
_onRender(context, options) {
super._onRender(context, options)
// Attacher les écouteurs pour l'édition des spécialités
this.element.querySelectorAll('.edit-specialite').forEach(input => {
input.addEventListener('change', async (event) => {
const li = event.target.closest('.specialite-item')
const index = Number.parseInt(li?.dataset.specialiteIndex)
if (index !== undefined && !Number.isNaN(index)) {
const spec = foundry.utils.duplicate(this.item.system.specialites) || []
if (spec[index]) {
spec[index].name = event.target.value
await this.item.update({ 'system.specialites': spec })
}
}
})
})
this.element.querySelectorAll('.edit-specialite-description').forEach(textarea => {
textarea.addEventListener('change', async (event) => {
const li = event.target.closest('.specialite-item')
const index = Number.parseInt(li?.dataset.specialiteIndex)
if (index !== undefined && !Number.isNaN(index)) {
const spec = foundry.utils.duplicate(this.item.system.specialites) || []
if (spec[index]) {
spec[index].description = event.target.value
await this.item.update({ 'system.specialites': spec })
}
}
})
})
}
/* -------------------------------------------- */
/* Event Handlers */
/* -------------------------------------------- */
static async #onAddSpecialite(event, target) {
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
spec.push({ name: "Nouvelle Spécialité", id: foundry.utils.randomID(16), used: false })
spec.push({ name: "Nouvelle Spécialité", description: "", used: false })
await this.item.update({ 'system.specialites': spec })
}
static async #onDeleteSpecialite(event, target) {
const li = target.closest(".specialite-item")
let index = parseInt(li.dataset.specialiteIndex)
let index = Number.parseInt(li.dataset.specialiteIndex)
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
spec.splice(index, 1)
await this.item.update({ 'system.specialites': spec })
}
static async #onEditSpecialite(event, target) {
const li = target.closest(".specialite-item")
let index = parseInt(li.dataset.specialiteIndex)
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
if (spec[index]) {
spec[index].name = target.value
spec[index].id = spec[index].id || foundry.utils.randomID(16)
await this.item.update({ 'system.specialites': spec })
}
}
static async #onEditSpecialiteDescription(event, target) {
const li = target.closest(".specialite-item")
let index = parseInt(li.dataset.specialiteIndex)
let spec = foundry.utils.duplicate(this.item.system.specialites) || []
if (spec[index]) {
spec[index].description = target.value
spec[index].id = spec[index].id || foundry.utils.randomID(16)
await this.item.update({ 'system.specialites': spec })
}
}
}