From 41df6257d5e9c846ef8f9533d7bdcc6f5ba89438 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Thu, 12 Nov 2020 17:06:19 +0100 Subject: [PATCH] #11 Gestion conteneur et suppression --- module/actor-sheet.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 9cc84b58..bc955925 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -175,6 +175,31 @@ export class RdDActorSheet extends ActorSheet { this.actor.computeEncombrementTotal(); } + /* -------------------------------------------- */ + async confirmerSuppression(li) { + let itemId = li.data("item-id"); + let d = new Dialog({ + title: "Confirmer la suppression", + content: "

Etes vous certain de vouloir supprimer cet objet ?

", + buttons: { + delete: { + icon: '', + label: "Supprimer", + callback: () => { + this.actor.deleteOwnedItem( itemId ); + li.slideUp(200, () => this.render(false)); + } + }, + cancel: { + icon: '', + label: "Annuler" + } + }, + default: "cancel", + }); + d.render(true); + } + /* -------------------------------------------- */ /** @override */ activateListeners(html) { @@ -193,9 +218,7 @@ export class RdDActorSheet extends ActorSheet { // Delete Inventory Item html.find('.item-delete').click(ev => { const li = $(ev.currentTarget).parents(".item"); - this.actor.deleteOwnedItem(li.data("item-id")); - console.log("Delete item :", li.data("item-id") ); - li.slideUp(200, () => this.render(false)); + this.confirmerSuppression( li ); }); // Update Inventory Item