From afbe0cb8f14693328385501a1ce42c371c33cd0b Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 23 Jan 2021 01:43:48 +0100 Subject: [PATCH 1/2] fix dragging items from compendium to actor sheet --- package-lock.json | 2 +- src/module/actor/sheets/actor-sheet.ts | 33 +++++++++++--------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 447b66d0..50085b6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2718,7 +2718,7 @@ } }, "foundry-pc-types": { - "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#5fcca4e4327b558d5eeeb962f05470c994a394be", + "version": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#ac45653fdec5fb935bf7db72889cb40cd6b80b20", "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes", "dev": true, "requires": { diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index 3dfda80e..c8a6e522 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -208,25 +208,20 @@ export class DS4ActorSheet extends ActorSheet { - const data = JSON.parse(event.dataTransfer?.getData("text/plain")) as { type?: string }; - if (data.type === "Item") { - const item = await Item.fromDropData(data as Parameters[0]); - if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) { - ui.notifications.warn( - game.i18n.format("DS4.WarningActorCannotOwnItem", { - actorName: this.actor.name, - actorType: this.actor.data.type, - itemName: item.name, - itemType: item.data.type, - }), - ); - return false; - } + /** @override */ + async _onDropItem(event: DragEvent, data: Parameters[0]): Promise { + const item = await Item.fromDropData(data); + if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) { + ui.notifications.warn( + game.i18n.format("DS4.WarningActorCannotOwnItem", { + actorName: this.actor.name, + actorType: this.actor.data.type, + itemName: item.name, + itemType: item.data.type, + }), + ); + return false; } - return super._onDrop(event); + return super["_onDropItem"](event, data); } } From 2d6eb34d098aa9bbccd3926799284d54ebd584fb Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Sat, 23 Jan 2021 01:45:23 +0100 Subject: [PATCH 2/2] better way to call super._onDropItem --- src/module/actor/sheets/actor-sheet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/actor/sheets/actor-sheet.ts b/src/module/actor/sheets/actor-sheet.ts index c8a6e522..8565ca5c 100644 --- a/src/module/actor/sheets/actor-sheet.ts +++ b/src/module/actor/sheets/actor-sheet.ts @@ -222,6 +222,6 @@ export class DS4ActorSheet extends ActorSheet