Actor Sheet : Patch Owned Items onDragStart
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user