Merge branch 'close-calibration' into 'v3'

Close calibration with confirmation

Closes #677 and openflexure-connect#40

See merge request openflexure/openflexure-microscope-server!542
This commit is contained in:
Julian Stirling 2026-03-17 23:33:24 +00:00
commit 0b3ce54a7e
3 changed files with 47 additions and 2 deletions

View file

@ -1,6 +1,13 @@
<template>
<div id="modal-example" ref="calibrationModalEl" uk-modal="bg-close: false;">
<div id="modal-example" ref="calibrationModalEl" uk-modal="bg-close: false; esc-close:false;">
<div class="uk-modal-dialog uk-modal-body">
<!-- Get the style from uk-close, but use stop.prevent to avoid it actually closing -->
<button
type="button"
class="uk-modal-close-default"
uk-close
@click.stop.prevent="confirmClose"
></button>
<h2 class="uk-modal-title">Microscope Calibration</h2>
<component
@ -40,6 +47,8 @@ export default {
tasks: [],
taskIndex: 0,
movingBackward: false,
modalOpen: false,
confirmingClose: false,
};
},
@ -152,12 +161,18 @@ export default {
},
show: function () {
this.modalOpen = true;
window.addEventListener("keydown", this.handleKeydown);
// Show the modal element
var el = this.$refs["calibrationModalEl"];
this.showModalElement(el); // Calls the mixin
},
hide: function () {
this.modalOpen = false;
window.removeEventListener("keydown", this.handleKeydown);
// Show the modal
var el = this.$refs["calibrationModalEl"];
this.hideModalElement(el); // Calls the mixin
@ -167,6 +182,34 @@ export default {
this.$emit("onClose");
},
handleKeydown(event) {
if (event.key === "Escape" && !event.repeat && this.modalOpen && !this.confirmingClose) {
event.preventDefault();
this.confirmClose();
}
},
confirmClose() {
if (this.confirmingClose) return;
this.confirmingClose = true;
let confirmationMessage =
"Close calibration wizard?<br><br>This can be re-opened from the Settings tab at any time.";
// Use standard modal confirmation
this.modalConfirm(confirmationMessage)
.then(
() => {
// User clicked YES hide modal
this.hide();
},
() => {
// User clicked NO do nothing, modal stays open
},
)
.finally(() => {
this.confirmingClose = false; // reset flag when confirmation modal is gone
});
},
/*
* Move to the previous task.
*/

View file

@ -45,5 +45,7 @@ export default {
<style scoped>
.action-button-container {
padding: 4px;
display: flex;
justify-content: center;
}
</style>

View file

@ -51,7 +51,7 @@
</ul>
</details>
</div>
<p v-else><strong>No Calibration Available</strong></p>
<p v-else><strong>No Calibration Data Available</strong></p>
</div>
</template>