Make the AE deletion context menu option actually work

This commit is contained in:
Oliver-Akins 2024-04-23 23:19:23 -06:00
parent dbeb511bdc
commit 2c2c4cc83f
2 changed files with 30 additions and 2 deletions

View file

@ -95,6 +95,12 @@
"title": "What is Calculated Capacity?",
"content": "<p>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.</p>"
}
},
"delete": {
"ActiveEffect": {
"title": "Delete Effect",
"content": "<p>Are you sure you would like to delete the active effect: {name}</p>"
}
}
},
"TYPES": {

View file

@ -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`),
}
}
}
);
},
}
]);