Various items fixes and enhancements
This commit is contained in:
@@ -23,7 +23,14 @@ export default class PrismRPGWeaponSheet extends PrismRPGItemSheet {
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
||||
context.enrichedPassiveDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.passiveDescription, { async: true })
|
||||
|
||||
// Enrich descriptions for all passives
|
||||
context.enrichedPassives = await Promise.all(
|
||||
this.document.system.passives.map(async (passive) => ({
|
||||
...passive,
|
||||
enrichedDescription: await foundry.applications.ux.TextEditor.implementation.enrichHTML(passive.description, { async: true })
|
||||
}))
|
||||
)
|
||||
|
||||
// Enrich descriptions for all maneuvers
|
||||
context.enrichedManeuvers = await Promise.all(
|
||||
@@ -40,6 +47,15 @@ export default class PrismRPGWeaponSheet extends PrismRPGItemSheet {
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options)
|
||||
|
||||
// Add event listeners for passive management
|
||||
this.element.querySelectorAll('[data-action="add-passive"]').forEach(el => {
|
||||
el.addEventListener("click", this._onAddPassive.bind(this))
|
||||
})
|
||||
|
||||
this.element.querySelectorAll('[data-action="delete-passive"]').forEach(el => {
|
||||
el.addEventListener("click", this._onDeletePassive.bind(this))
|
||||
})
|
||||
|
||||
// Add event listeners for maneuver management
|
||||
this.element.querySelectorAll('[data-action="add-maneuver"]').forEach(el => {
|
||||
el.addEventListener("click", this._onAddManeuver.bind(this))
|
||||
@@ -50,6 +66,20 @@ export default class PrismRPGWeaponSheet extends PrismRPGItemSheet {
|
||||
})
|
||||
}
|
||||
|
||||
async _onAddPassive(event) {
|
||||
event.preventDefault()
|
||||
const passives = [...this.document.system.passives]
|
||||
passives.push({ name: "", description: "" })
|
||||
await this.document.update({ "system.passives": passives })
|
||||
}
|
||||
|
||||
async _onDeletePassive(event) {
|
||||
event.preventDefault()
|
||||
const index = parseInt(event.currentTarget.closest("[data-passive-index]").dataset.passiveIndex)
|
||||
const passives = this.document.system.passives.filter((_, i) => i !== index)
|
||||
await this.document.update({ "system.passives": passives })
|
||||
}
|
||||
|
||||
async _onAddManeuver(event) {
|
||||
event.preventDefault()
|
||||
const maneuvers = [...this.document.system.maneuvers]
|
||||
|
||||
Reference in New Issue
Block a user