mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Fix] Inventory Item Transfer (#1316)
* Fixed so items from the inventory tab of the Party sheet can be dragged out * Added transfer logic * Added translation * Improved item transfer dialog title * Simplified title * Updated image * Simplified the handlebars templates for itemTransfer * Improved item-identicial check * Slight improved rendering * .
This commit is contained in:
parent
9f7554cdff
commit
2920ead81a
15 changed files with 228 additions and 47 deletions
|
|
@ -8,7 +8,6 @@ import { getDocFromElement, getDocFromElementSync } from '../../../helpers/utils
|
|||
|
||||
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
||||
|
||||
const { TextEditor } = foundry.applications.ux;
|
||||
export default class CharacterSheet extends DHBaseActorSheet {
|
||||
/**@inheritdoc */
|
||||
static DEFAULT_OPTIONS = {
|
||||
|
|
@ -881,6 +880,8 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
const item = await getDocFromElement(event.target);
|
||||
|
||||
const dragData = {
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
|
|
@ -894,9 +895,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
// Prevent event bubbling to avoid duplicate handling
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
|
||||
super._onDrop(event);
|
||||
this._onDropItem(event, TextEditor.getDragEventData(event));
|
||||
const { cancel } = await super._onDrop(event);
|
||||
if (cancel) return;
|
||||
|
||||
this._onDropItem(event, data);
|
||||
}
|
||||
|
||||
async _onDropItem(event, data) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import { socketEvent } from '../../../systemRegistration/socket.mjs';
|
|||
import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs';
|
||||
import DhpActor from '../../../documents/actor.mjs';
|
||||
import DHItem from '../../../documents/item.mjs';
|
||||
import DhParty from '../../../data/actor/party.mjs';
|
||||
|
||||
export default class Party extends DHBaseActorSheet {
|
||||
constructor(options) {
|
||||
|
|
@ -21,7 +20,7 @@ export default class Party extends DHBaseActorSheet {
|
|||
classes: ['party'],
|
||||
position: {
|
||||
width: 550,
|
||||
height: 900,
|
||||
height: 900
|
||||
},
|
||||
window: {
|
||||
resizable: true
|
||||
|
|
@ -41,7 +40,7 @@ export default class Party extends DHBaseActorSheet {
|
|||
selectRefreshable: DaggerheartMenu.selectRefreshable,
|
||||
refreshActors: DaggerheartMenu.refreshActors
|
||||
},
|
||||
dragDrop: [{ dragSelector: '.actors-section .inventory-item', dropSelector: null }]
|
||||
dragDrop: [{ dragSelector: '[data-item-id][draggable="true"]', dropSelector: null }]
|
||||
};
|
||||
|
||||
/**@override */
|
||||
|
|
@ -439,23 +438,28 @@ export default class Party extends DHBaseActorSheet {
|
|||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async _onDragStart(event) {
|
||||
const item = event.currentTarget.closest('.inventory-item');
|
||||
const item = await getDocFromElement(event.target);
|
||||
const dragData = {
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
};
|
||||
|
||||
if (item) {
|
||||
const adversaryData = { type: 'Actor', uuid: item.dataset.itemUuid };
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(adversaryData));
|
||||
event.dataTransfer.setDragImage(item, 60, 0);
|
||||
}
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
super._onDragStart(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 { cancel } = await super._onDrop(event);
|
||||
if (cancel) return;
|
||||
|
||||
const document = await foundry.utils.fromUuid(data.uuid);
|
||||
|
||||
if (document instanceof DhpActor && Party.ALLOWED_ACTOR_TYPES.includes(document.type)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue