Skip to content

Commit

Permalink
add prompt for close if using esc in script manager
Browse files Browse the repository at this point in the history
  • Loading branch information
sadnub committed Nov 24, 2023
1 parent 1299bfc commit d0e49d2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/scripts/ScriptFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<q-dialog
ref="dialogRef"
maximized
no-esc-dismiss
@hide="onDialogHide"
@show="loadEditor"
@before-hide="unloadEditor"
@keydown.esc.stop="closeEditor"
>
<q-card class="q-dialog-plugin">
<q-bar>
Expand Down Expand Up @@ -363,6 +365,13 @@ function loadEditor() {
downloadScript(script.id, { with_snippets: props.readonly }).then((r) => {
script.script_body = r.code;
editor.setValue(r.code);
watch(
() => script.script_body,
() => {
edited.value = true;
},
);
});
// watch for changes in language
Expand Down Expand Up @@ -394,6 +403,21 @@ function generateScriptOpenAI() {
});
}
// add are you sure prompt to unsaved script
const edited = ref(false);
function closeEditor() {
if (edited.value)
$q.dialog({
title: "You have unsaved changes. Are you sure you want to close?",
cancel: true,
ok: true,
}).onOk(async () => {
unloadEditor();
});
else unloadEditor();
}
// component life cycle hooks
onMounted(async () => {
agentLoading.value = true;
Expand Down

0 comments on commit d0e49d2

Please sign in to comment.