Fixed so items can be dropped into the Party sheet

This commit is contained in:
WBHarry 2025-11-06 22:21:05 +01:00
parent e8961afc5e
commit c96cd2beac

View file

@ -5,6 +5,8 @@ import FilterMenu from '../../ux/filter-menu.mjs';
import DaggerheartMenu from '../../sidebar/tabs/daggerheartMenu.mjs'; import DaggerheartMenu from '../../sidebar/tabs/daggerheartMenu.mjs';
import { socketEvent } from '../../../systemRegistration/socket.mjs'; import { socketEvent } from '../../../systemRegistration/socket.mjs';
import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs'; import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs';
import DhpActor from '../../../documents/actor.mjs';
import DHItem from '../../../documents/item.mjs';
export default class Party extends DHBaseActorSheet { export default class Party extends DHBaseActorSheet {
constructor(options) { constructor(options) {
@ -55,7 +57,7 @@ export default class Party extends DHBaseActorSheet {
// }, // },
inventory: { inventory: {
template: 'systems/daggerheart/templates/sheets/actors/party/inventory.hbs', template: 'systems/daggerheart/templates/sheets/actors/party/inventory.hbs',
scrollable: [''] scrollable: ['.tab.inventory .items-section']
}, },
notes: { template: 'systems/daggerheart/templates/sheets/actors/party/notes.hbs' } notes: { template: 'systems/daggerheart/templates/sheets/actors/party/notes.hbs' }
}; };
@ -445,21 +447,25 @@ export default class Party extends DHBaseActorSheet {
} }
async _onDrop(event) { async _onDrop(event) {
// Prevent event bubbling to avoid duplicate handling
event.preventDefault();
event.stopPropagation();
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event); const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
const actor = await foundry.utils.fromUuid(data.uuid); const item = await foundry.utils.fromUuid(data.uuid);
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
if (foundry.utils.parseUuid(data.uuid).collection instanceof CompendiumCollection) return; if (item instanceof DhpActor) {
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
if (currentMembers.includes(data.uuid)) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.duplicateCharacter'));
}
if (actor.type !== 'character') { await this.document.update({ 'system.partyMembers': [...currentMembers, item.uuid] });
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.onlyCharactersInPartySheet')); } else if (item instanceof DHItem) {
this.document.createEmbeddedDocuments('Item', [item.toObject()]);
} else {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.onlyCharactersInPartySheet'));
} }
if (currentMembers.includes(data.uuid)) {
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.duplicateCharacter'));
}
await this.document.update({ 'system.partyMembers': [...currentMembers, actor.uuid] });
} }
static async #deletePartyMember(_event, target) { static async #deletePartyMember(_event, target) {