From 2c2c4cc83f35a14043d7b1efe7f7999a7e717d62 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Tue, 23 Apr 2024 23:19:23 -0600 Subject: [PATCH] Make the AE deletion context menu option actually work --- langs/en-ca.2.json | 6 ++++++ module/sheets/Items/UntypedItemSheet.mjs | 26 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/langs/en-ca.2.json b/langs/en-ca.2.json index cc81d0a..dce0efa 100644 --- a/langs/en-ca.2.json +++ b/langs/en-ca.2.json @@ -95,6 +95,12 @@ "title": "What is Calculated Capacity?", "content": "

The calculated capacity is how much space in your inventory that the item will take up, the way it is calculated is determined by the item. Usually the main thing that affects the capacity is the item's quantity, but this can be turned off by the @dotdungeon.common.gm, which means that no matter the quantity it will only use up one capacity. The @dotdungeon.common.gm can also entirely disable capacity usage which will make the used capacity always be zero.

" } + }, + "delete": { + "ActiveEffect": { + "title": "Delete Effect", + "content": "

Are you sure you would like to delete the active effect: {name}

" + } } }, "TYPES": { diff --git a/module/sheets/Items/UntypedItemSheet.mjs b/module/sheets/Items/UntypedItemSheet.mjs index 99f6862..5ae0f24 100644 --- a/module/sheets/Items/UntypedItemSheet.mjs +++ b/module/sheets/Items/UntypedItemSheet.mjs @@ -1,4 +1,5 @@ import { GenericContextMenu } from "../../utils/GenericContextMenu.mjs"; +import { DialogManager } from "../../utils/DialogManager.mjs"; import { GenericItemSheet } from "./GenericItemSheet.mjs"; import { localizer } from "../../utils/localizer.mjs"; @@ -75,8 +76,29 @@ export class UntypedItemSheet extends GenericItemSheet { }, { name: localizer(`dotdungeon.common.delete`), - callback: async () => { - (await fromUuid(html.closest(`.effect`)[0].dataset.embeddedId))?.delete(true); + callback: async (html) => { + const target = html.closest(`.effect`)[0]; + const data = target.dataset; + const id = data.embeddedId; + const doc = await fromUuid(id); + DialogManager.createOrFocus( + `${doc.uuid}-delete`, + { + title: localizer(`dotdungeon.delete.ActiveEffect.title`, doc), + content: localizer(`dotdungeon.delete.ActiveEffect.content`, doc), + buttons: { + yes: { + label: localizer(`Yes`), + callback() { + doc.delete(); + }, + }, + no: { + label: localizer(`No`), + } + } + } + ); }, } ]);