Save before leaving

This commit is contained in:
Adria Navarro 2025-03-14 14:32:21 +01:00
parent b1af71c31a
commit 7be33806ce
1 changed files with 17 additions and 1 deletions

View File

@ -209,11 +209,14 @@
originalQuery = null
queryNameLabel.disableEditingState()
return { ok: true }
} catch (err) {
notifications.error(`Error saving query`)
} finally {
saving = false
}
return { ok: false }
}
const validateQuery = async () => {
@ -482,7 +485,7 @@
return true
}
return new Promise(resolve => {
const shouldSave = await new Promise(resolve => {
const dialog = new ConfirmDialog({
target: document.body,
props: {
@ -503,6 +506,19 @@
})
dialog.show()
})
if (!shouldSave) {
// Leave without saving anything
return true
}
const saveResult = await saveQuery()
if (!saveResult.ok) {
// We can't leave as the query was not properly saved
return false
}
return true
})
</script>