First row of tests and fixes
This commit is contained in:
@@ -5,7 +5,11 @@ export default class AwEFieldSheet extends AwEItemSheet {
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["field"],
|
||||
position: { width: 620 },
|
||||
window: { contentClasses: ["field-content"] }
|
||||
window: { contentClasses: ["field-content"] },
|
||||
actions: {
|
||||
addSpecialization: AwEFieldSheet.#onAddSpecialization,
|
||||
removeSpecialization: AwEFieldSheet.#onRemoveSpecialization
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
@@ -14,4 +18,29 @@ export default class AwEFieldSheet extends AwEItemSheet {
|
||||
template: "systems/fvtt-adventures-with-emmy/templates/field.hbs"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle adding a specialization.
|
||||
* @param {PointerEvent} event - The initiating event.
|
||||
* @param {HTMLElement} target - The input element.
|
||||
*/
|
||||
static async #onAddSpecialization(event, target) {
|
||||
const value = target.value.trim()
|
||||
if (!value) return
|
||||
const current = this.document.system.specializations ?? []
|
||||
await this.document.update({ "system.specializations": [...current, value] })
|
||||
target.value = ""
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle removing a specialization.
|
||||
* @param {PointerEvent} event - The initiating click event.
|
||||
* @param {HTMLElement} target - The remove button.
|
||||
*/
|
||||
static async #onRemoveSpecialization(event, target) {
|
||||
const index = Number(target.dataset.index)
|
||||
const current = [...(this.document.system.specializations ?? [])]
|
||||
current.splice(index, 1)
|
||||
await this.document.update({ "system.specializations": current })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user