DataModels + Appv2 migration : OK
This commit is contained in:
66
module/applications/sheets/vehicle-sheet.mjs
Normal file
66
module/applications/sheets/vehicle-sheet.mjs
Normal file
@@ -0,0 +1,66 @@
|
||||
import BoLBaseActorSheet from "./base-actor-sheet.mjs"
|
||||
|
||||
/**
|
||||
* Actor Sheet for BoL vehicles using AppV2
|
||||
*/
|
||||
export default class BoLVehicleSheet extends BoLBaseActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
...super.DEFAULT_OPTIONS,
|
||||
classes: [...super.DEFAULT_OPTIONS.classes],
|
||||
actions: {
|
||||
...super.DEFAULT_OPTIONS.actions,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
sheet: {
|
||||
template: "systems/bol/templates/actor/vehicle-sheet.hbs",
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
tabGroups = { primary: "stats" }
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
const actor = this.document
|
||||
|
||||
context.weapons = actor.vehicleWeapons
|
||||
context.options = this.options
|
||||
context.editScore = this.options.editScore
|
||||
context.description = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
actor.system.description || "", { async: true }
|
||||
)
|
||||
|
||||
console.log("VEHICLE (AppV2)", context)
|
||||
return context
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_activateListeners() {
|
||||
super._activateListeners()
|
||||
if (!this.isEditable) return
|
||||
|
||||
// Item create via header dataset
|
||||
this.element.querySelectorAll(".item-create").forEach((el) => {
|
||||
el.addEventListener("click", (ev) => {
|
||||
ev.preventDefault()
|
||||
const header = ev.currentTarget
|
||||
const type = header.dataset.type
|
||||
const data = foundry.utils.duplicate(header.dataset)
|
||||
delete data.type
|
||||
this.actor.createEmbeddedDocuments("Item", [{ name: `New ${type}`, type, data }])
|
||||
})
|
||||
})
|
||||
|
||||
// Create generic item
|
||||
this.element.querySelectorAll(".create_item").forEach((el) => {
|
||||
el.addEventListener("click", () => {
|
||||
this.actor.createEmbeddedDocuments("Item", [{ name: "Nouvel Equipement", type: "item" }], { renderSheet: true })
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user