Nouvelles corrections sur la fiche
This commit is contained in:
@@ -83,6 +83,9 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
break
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.fields = doc.itemTypes.field
|
||||
context.archetypes = doc.itemTypes.archetype
|
||||
context.backgrounds = doc.itemTypes.background
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.description, { async: true }
|
||||
)
|
||||
@@ -102,7 +105,7 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
|
||||
/** @override */
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable || !this.isEditMode) return
|
||||
if (!this.isEditable) return
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
if (data.type === "Item") {
|
||||
const item = await fromUuid(data.uuid)
|
||||
@@ -110,13 +113,29 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _onDropItem(item) {
|
||||
if (!item) return
|
||||
// field/background: max 1 (replace existing); archetype: multiple allowed
|
||||
if (item.type === "field" || item.type === "background") {
|
||||
const existing = this.document.itemTypes[item.type]
|
||||
if (existing.length > 0) await existing[0].delete()
|
||||
return this.document.createEmbeddedDocuments("Item", [item.toObject()])
|
||||
}
|
||||
if (item.type === "archetype") {
|
||||
return this.document.createEmbeddedDocuments("Item", [item.toObject()])
|
||||
}
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ability item.
|
||||
* @param {Event} event - The triggering event.
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateAbility(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Ability", type: "ability" }])
|
||||
const type = "ability"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +144,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateWeapon(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Weapon", type: "weapon" }])
|
||||
const type = "weapon"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +154,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateKit(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Kit", type: "kit" }])
|
||||
const type = "kit"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +164,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
|
||||
* @param {HTMLElement} target - The target element.
|
||||
*/
|
||||
static #onCreateEquipment(event, target) {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: "New Equipment", type: "equipment" }])
|
||||
const type = "equipment"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user