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 originalQuery = null
queryNameLabel.disableEditingState() queryNameLabel.disableEditingState()
return { ok: true }
} catch (err) { } catch (err) {
notifications.error(`Error saving query`) notifications.error(`Error saving query`)
} finally { } finally {
saving = false saving = false
} }
return { ok: false }
} }
const validateQuery = async () => { const validateQuery = async () => {
@ -482,7 +485,7 @@
return true return true
} }
return new Promise(resolve => { const shouldSave = await new Promise(resolve => {
const dialog = new ConfirmDialog({ const dialog = new ConfirmDialog({
target: document.body, target: document.body,
props: { props: {
@ -503,6 +506,19 @@
}) })
dialog.show() 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> </script>