From 9ea19a55095cab4c0db1fe9c61aa9cb6de1cb403 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 22 Feb 2021 20:32:12 +0100 Subject: [PATCH] #1 Fix item deletion --- module/actor-sheet.js | 2 +- module/sos-utility.js | 30 ++++++++++++++++++++++++++++++ system.json | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index f692c25..2ad579b 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -92,7 +92,7 @@ export class SoSActorSheet extends ActorSheet { // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); - RdDUtility.confirmerSuppression(this, li); + SoSUtility.confirmDelete(this, li); }); html.find('.stat-label a').click((event) => { diff --git a/module/sos-utility.js b/module/sos-utility.js index 4e1c302..ba99a25 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -219,6 +219,36 @@ export class SoSUtility extends Entity { return 0; } + /* -------------------------------------------- */ + static async confirmDelete(actorSheet, li) { + let itemId = li.data("item-id"); + let objet = actorSheet.actor.items.find(item => item._id == itemId); + let msgTxt = "

Are you sure to delete this item ?"; + let buttons = { + delete: { + icon: '', + label: "Yes, delete it", + callback: () => { + console.log("Delete : ", itemId); + actorSheet.actor.deleteOwnedItem(itemId); + li.slideUp(200, () => actorSheet.render(false)); + } + }, + cancel: { + icon: '', + label: "Cancel" + } + } + msgTxt += "

"; + let d = new Dialog({ + title: "Confirm deletion", + content: msgTxt, + buttons: buttons, + default: "cancel" + }); + d.render(true); + } + /* -------------------------------------------- */ static async applyDamage( flipData ) { if (!this.registry) this.registry = {}; diff --git a/system.json b/system.json index ef9820b..785e64a 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-shadows-over-sol", "title": "Shadows over Sol", "description": "Shadows over Sol for FoundryVTT", - "version": "0.1.1", + "version": "0.1.2", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9",