mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-23 19:09:55 +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 */
|
/* 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) {
|
async _onDropItem(event, item) {
|
||||||
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
const setupCriticalItemTypes = ['class', 'subclass', 'ancestry', 'community'];
|
||||||
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
if (this.document.system.needsCharacterSetup && setupCriticalItemTypes.includes(item.type)) {
|
||||||
|
|
|
||||||
|
|
@ -361,18 +361,17 @@ export default function DHApplicationMixin(Base) {
|
||||||
*/
|
*/
|
||||||
async _onDragStart(event) {
|
async _onDragStart(event) {
|
||||||
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||||
if (inventoryItem) {
|
if (!inventoryItem) return;
|
||||||
const { type, itemUuid } = inventoryItem.dataset;
|
|
||||||
if (type === 'effect') {
|
const { type, itemUuid } = inventoryItem.dataset;
|
||||||
const effect = await foundry.utils.fromUuid(itemUuid);
|
const effect = type === 'effect' ? await foundry.utils.fromUuid(itemUuid) : null;
|
||||||
const effectData = {
|
if (effect) {
|
||||||
type: 'ActiveEffect',
|
const effectData = {
|
||||||
data: { ...effect.toObject(), _id: null },
|
...effect.toDragData(),
|
||||||
fromInternal: this.document.uuid
|
fromInternal: this.document.uuid
|
||||||
};
|
};
|
||||||
event.dataTransfer.setData('text/plain', JSON.stringify(effectData));
|
event.dataTransfer.setData('text/plain', JSON.stringify(effectData));
|
||||||
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,14 +381,10 @@ export default function DHApplicationMixin(Base) {
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_onDrop(event) {
|
_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();
|
event.stopPropagation();
|
||||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
return super._onDrop?.(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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
|
||||||
|
|
@ -447,13 +447,15 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
|
||||||
|
|
||||||
const item = await getDocFromElement(event.target);
|
const item = await getDocFromElement(event.target);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
const inventoryItem = event.currentTarget.closest('.inventory-item');
|
||||||
const dragData = {
|
const dragData = {
|
||||||
|
...item.toDragData(),
|
||||||
originActor: this.document.uuid,
|
originActor: this.document.uuid,
|
||||||
originId: item.id,
|
originId: item.id
|
||||||
type: item.documentName,
|
|
||||||
uuid: item.uuid
|
|
||||||
};
|
};
|
||||||
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
event.dataTransfer.setData('text/plain', JSON.stringify(dragData));
|
||||||
|
if (inventoryItem) event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
super._onDragStart(event);
|
super._onDragStart(event);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue