Merge branch 'fix-dragging-from-compendium-to-actor-sheet' into 'master'

fix dragging items from compendium to actor sheet

See merge request dungeonslayers/ds4!63
This commit is contained in:
Johannes Loher 2021-01-23 01:47:53 +01:00
commit 4d09c86997
2 changed files with 15 additions and 20 deletions

2
package-lock.json generated
View file

@ -2718,7 +2718,7 @@
} }
}, },
"foundry-pc-types": { "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", "from": "git+https://git.f3l.de/dungeonslayers/foundry-pc-types.git#f3l-fixes",
"dev": true, "dev": true,
"requires": { "requires": {

View file

@ -208,25 +208,20 @@ export class DS4ActorSheet extends ActorSheet<DS4ActorDataType, DS4Actor, DS4Ite
} }
} }
/** /** @override */
* @override async _onDropItem(event: DragEvent, data: Parameters<typeof DS4Item.fromDropData>[0]): Promise<unknown> {
*/ const item = await Item.fromDropData(data);
async _onDrop(event: DragEvent): Promise<boolean | unknown> { if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) {
const data = JSON.parse(event.dataTransfer?.getData("text/plain")) as { type?: string }; ui.notifications.warn(
if (data.type === "Item") { game.i18n.format("DS4.WarningActorCannotOwnItem", {
const item = await Item.fromDropData(data as Parameters<typeof DS4Item.fromDropData>[0]); actorName: this.actor.name,
if (item && !this.actor.canOwnItemType(item.data.type as ItemType)) { actorType: this.actor.data.type,
ui.notifications.warn( itemName: item.name,
game.i18n.format("DS4.WarningActorCannotOwnItem", { itemType: item.data.type,
actorName: this.actor.name, }),
actorType: this.actor.data.type, );
itemName: item.name, return false;
itemType: item.data.type,
}),
);
return false;
}
} }
return super._onDrop(event); return super._onDropItem(event, data);
} }
} }