mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Fix dragging AE from compendium or within same actor (#1997)
This commit is contained in:
parent
7a631c27a7
commit
9f26c53af5
4 changed files with 19 additions and 40 deletions
|
|
@ -186,15 +186,6 @@ export default class AdversarySheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
async _onDragStart(event) {
|
||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||
if (inventoryItem) {
|
||||
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||
}
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -1193,15 +1193,6 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
async _onDragStart(event) {
|
||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||
if (inventoryItem) {
|
||||
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||
}
|
||||
super._onDragStart(event);
|
||||
}
|
||||
|
||||
async _onDropItem(event, item) {
|
||||
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
||||
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
||||
|
|
|
|||
|
|
@ -361,18 +361,17 @@ export default function DHApplicationMixin(Base) {
|
|||
*/
|
||||
async _onDragStart(event) {
|
||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||
if (inventoryItem) {
|
||||
const { type, itemUuid } = inventoryItem.dataset;
|
||||
if (type === 'effect') {
|
||||
const effect = await foundry.utils.fromUuid(itemUuid);
|
||||
const effectData = {
|
||||
type: 'ActiveEffect',
|
||||
data: { ...effect.toObject(), _id: null },
|
||||
fromInternal: this.document.uuid
|
||||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(effectData));
|
||||
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||
}
|
||||
if (!inventoryItem) return;
|
||||
|
||||
const { type, itemUuid } = inventoryItem.dataset;
|
||||
const effect = type === 'effect' ? await foundry.utils.fromUuid(itemUuid) : null;
|
||||
if (effect) {
|
||||
const effectData = {
|
||||
...effect.toDragData(),
|
||||
fromInternal: this.document.uuid
|
||||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(effectData));
|
||||
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,14 +381,10 @@ export default function DHApplicationMixin(Base) {
|
|||
* @protected
|
||||
*/
|
||||
_onDrop(event) {
|
||||
// Fallback to super, but note that config sheets don't have this option
|
||||
// We still need this to avoid setting apps having issues
|
||||
event.stopPropagation();
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
if (data.type === 'ActiveEffect' && data.fromInternal !== this.document.uuid) {
|
||||
this.document.createEmbeddedDocuments('ActiveEffect', [data.data]);
|
||||
} else {
|
||||
// Fallback to super, but note that item sheets do not have this function
|
||||
return super._onDrop?.(event);
|
||||
}
|
||||
return super._onDrop?.(event);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -447,13 +447,15 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
|||
|
||||
const item = await getDocFromElement(event.target);
|
||||
if (item) {
|
||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||
const dragData = {
|
||||
...item.toDragData(),
|
||||
originActor: this.document.uuid,
|
||||
originId: item.id,
|
||||
type: item.documentName,
|
||||
uuid: item.uuid
|
||||
originId: item.id
|
||||
};
|
||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||
if (inventoryItem) event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
super._onDragStart(event);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue