Actor Sheet : Patch Owned Items onDragStart

This commit is contained in:
Vlyan
2022-03-31 18:26:08 +02:00
parent 7b7926674a
commit a9f9d9ce2e
2 changed files with 25 additions and 1 deletions

View File

@@ -268,6 +268,30 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
return this.actor.createEmbeddedDocuments("Item", [itemData]); return this.actor.createEmbeddedDocuments("Item", [itemData]);
} }
/** @inheritdoc */
_onDragStart(event) {
// Patch Owned Items
const li = event.currentTarget;
if (li.dataset.itemParentId && li.dataset.itemId) {
const item = this.actor.items.get(li.dataset.itemParentId)?.items.get(li.dataset.itemId);
if (item) {
const dragData = {
actorId: this.actor.id,
sceneId: this.actor.isToken ? canvas.scene?.id : null,
tokenId: this.actor.isToken ? this.actor.token.id : null,
pack: this.actor.pack,
type: "Item",
data: foundry.utils.duplicate(item.data),
};
dragData.data.data.parent_id = null;
event.dataTransfer.setData("text/plain", JSON.stringify(dragData));
return;
}
}
// Else regular
super._onDragStart(event);
}
/** /**
* Subscribe to events from the sheet. * Subscribe to events from the sheet.
* @param {jQuery} html HTML content of the sheet. * @param {jQuery} html HTML content of the sheet.

View File

@@ -1,4 +1,4 @@
<li class="item technique flexcol" data-item-id="{{technique._id}}"> <li class="item technique flexcol" data-item-id="{{technique._id}}" {{#if technique.data.parent_id.item_id}}data-item-parent-id="{{technique.data.parent_id.item_id}}"{{/if}}>
<ul class="item-header technique-controls"> <ul class="item-header technique-controls">
<li class="item-img"><img src="{{technique.img}}" title="{{technique.name}}" width="32px" height="32px"/></li> <li class="item-img"><img src="{{technique.img}}" title="{{technique.name}}" width="32px" height="32px"/></li>
<li class="item-name l5r5e-tooltip {{#if technique.data.skill}}dice-picker-tech{{/if}}" data-item-id="{{technique._id}}" {{#if technique.data.parent_id.item_id}}data-item-parent-id="{{technique.data.parent_id.item_id}}"{{/if}}>{{technique.name}}</li> <li class="item-name l5r5e-tooltip {{#if technique.data.skill}}dice-picker-tech{{/if}}" data-item-id="{{technique._id}}" {{#if technique.data.parent_id.item_id}}data-item-parent-id="{{technique.data.parent_id.item_id}}"{{/if}}>{{technique.name}}</li>