From 7d563fd843d50219be44f1a638acbfe154760d2d Mon Sep 17 00:00:00 2001 From: Hubert Nusser Date: Thu, 18 Mar 2021 19:47:32 +0100 Subject: [PATCH] fix dialog on metadata removal Signed-off-by: Hubert Nusser --- .../items/metadata/item-metadata-edit.vue | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/pages/settings/items/metadata/item-metadata-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/items/metadata/item-metadata-edit.vue index 33738ea2d8..982dd126e9 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/items/metadata/item-metadata-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/items/metadata/item-metadata-edit.vue @@ -189,20 +189,28 @@ export default { }) }, remove () { - this.$oh.api.delete(`/rest/items/${this.itemName}/metadata/${this.namespace}`).then(() => { - this.$f7.toast.create({ - text: 'Metadata deleted', - destroyOnClose: true, - closeTimeout: 2000 - }).open() - this.$f7router.back() - }).catch((err) => { - this.$f7.toast.create({ - text: 'Error while deleting metadata: ' + err, - destroyOnClose: true, - closeTimeout: 2000 - }).open() - }) + let nslabel = ([...MetadataNamespaces].find(ns => ns.name === this.namespace) || { label: this.namespace }).label + this.$f7.dialog.confirm( + `Are you sure you want to remove all metadata for "${nslabel}"?`, + 'Remove metadata', + () => { + this.$oh.api.delete(`/rest/items/${this.itemName}/metadata/${this.namespace}`).then(() => { + this.$f7.toast.create({ + text: 'Metadata deleted', + destroyOnClose: true, + closeTimeout: 2000 + }).open() + this.dirty = false + this.$f7router.back() + }).catch((err) => { + this.$f7.toast.create({ + text: 'Error while deleting metadata: ' + err, + destroyOnClose: true, + closeTimeout: 2000 + }).open() + }) + } + ) }, toYaml () { this.yaml = YAML.stringify(this.metadata)