onDrop depuis compendium async

Permettre de retrouver l'Item du compendium pour tester si un acteur
peut le recevoir
This commit is contained in:
Vincent Vandemeulebrouck 2023-01-01 22:18:18 +01:00
parent d77ecee9bd
commit 2ca601b5f8
3 changed files with 9 additions and 4 deletions

View File

@ -185,7 +185,7 @@ export class RdDBaseActorSheet extends ActorSheet {
/* -------------------------------------------- */
async _onDropItem(event, dragData) {
const destItemId = this.html.find(event.target)?.closest('.item').attr('data-item-id')
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
const dropParams = await RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
if (dropParams) {
const callSuper = await this.actor.processDropItem(dropParams)
if (callSuper) {

View File

@ -51,7 +51,7 @@ export class RdDConteneurItemSheet extends RdDItemSheet {
async _onDropItem(event, dragData) {
if (this.actor) {
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor, dragData, this.objetVersConteneur);
const dropParams = await RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor, dragData, this.objetVersConteneur);
await this.actor.processDropItem(dropParams);
await this.render(true);
}

View File

@ -1,4 +1,6 @@
import { DialogSplitItem } from "./dialog-split-item.js";
import { RdDItem } from "./item.js";
import { SystemCompendiums } from "./settings/system-compendiums.js";
export class RdDSheetUtility {
@ -19,8 +21,11 @@ export class RdDSheetUtility {
return $(event.currentTarget)?.parents(".item");
}
static prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) {
const item = fromUuidSync(dragData.uuid)
static async prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) {
let item = fromUuidSync(dragData.uuid);
if (item.pack && !item.system){
item = await RdDItem.getCorrespondingItem(item);
}
if (actor.canReceive(item)) {
return {
destId: destItemId,