289 - Confirm Delete Dialogs (#298)

* Added confirm dialogs to delete

* Localization fix
This commit is contained in:
WBHarry 2025-07-08 20:04:54 +02:00 committed by GitHub
parent 5aa9ba661a
commit 61f04df765
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 101 additions and 10 deletions

View file

@ -218,7 +218,6 @@ export default function DHApplicationMixin(Base) {
*/
static async #createDoc(event, button) {
const { documentClass, type } = button.dataset;
console.log(documentClass, type);
const parent = this.document;
const cls = getDocumentClass(documentClass);
@ -250,7 +249,23 @@ export default function DHApplicationMixin(Base) {
*/
static async #deleteDoc(_event, button) {
const { type, docId } = button.dataset;
await this.document.getEmbeddedDocument(type, docId, { strict: true }).delete();
const document = this.document.getEmbeddedDocument(type, docId, { strict: true });
const typeName = game.i18n.localize(
document.type === 'base' ? `DOCUMENT.${type}` : `TYPES.${type}.${document.type}`
);
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.title', {
type: typeName,
name: document.name
})
},
content: game.i18n.format('DAGGERHEART.APPLICATIONS.DeleteConfirmation.text', { name: document.name })
});
if (!confirmed) return;
await document.delete();
}
}