-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#48 Add delete action for calibration curve
- Loading branch information
1 parent
ee655d8
commit 40b6a40
Showing
8 changed files
with
177 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script setup lang="ts"> | ||
// token to save the state of the dialog box | ||
const openConfirmBox = useState<boolean>("openConfirmBox", () => false); | ||
// message to display in the dialog box | ||
const msgConfirmBox = useState<string>("msgConfirmBox", () => ""); | ||
// token to save the answer of the dialog box | ||
const answerConfirmBox = useState<boolean>("answerConfirmBox", () => false); | ||
// function to internationalize the text | ||
const {t} = useI18n(); | ||
</script> | ||
|
||
<template> | ||
<!-- Confirm Box --> | ||
<v-dialog | ||
id="confirm-box" | ||
v-model="openConfirmBox" | ||
max-width="40%" | ||
> | ||
<v-card> | ||
<!-- title of confirm box --> | ||
<v-card-title>{{ t('title.confirmBox') }}</v-card-title> | ||
<!-- message of confirm box --> | ||
<v-card-text>{{ msgConfirmBox }}</v-card-text> | ||
<v-card-actions> | ||
<!-- buttons of confirm box --> | ||
<!-- NO or cancel --> | ||
<v-btn | ||
:text="t('button.cancel')" | ||
@click="openConfirmBox = false; answerConfirmBox = false" | ||
/> | ||
<!-- YES or ok --> | ||
<v-btn | ||
:text="t('button.yes')" | ||
@click="openConfirmBox = false; answerConfirmBox = true" | ||
/> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Marcellino Palerme <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* Manage the display and answer of a confirm box | ||
*/ | ||
|
||
import { waitElemtDom } from "./waitElemtDom"; | ||
|
||
/** | ||
* Display a confirm box with a message and wait user answer | ||
* @param message : string : message to display in confirm box | ||
* @returns Promise<boolean> : true if user click on "yes" button, | ||
* false if user click on "no/cancel" button | ||
*/ | ||
|
||
export function useConfirmBox(message: string): Promise<boolean> { | ||
// Token to dysplay confirm box | ||
const openConfirmBox = useState<boolean>("openConfirmBox",); | ||
// Token to store message to display in confirm box | ||
const msgConfirmBox = useState<string>("msgConfirmBox"); | ||
|
||
// Add message to confirm box | ||
msgConfirmBox.value=message; | ||
// Open confirm box | ||
openConfirmBox.value=true; | ||
|
||
return waitElemtDom("#confirm-box",true) // wait confirm box open | ||
.then(()=>waitElemtDom("#confirm-box",false)) // wait confirm box close | ||
.then(()=>useState<boolean>("answerConfirmBox").value); // return answer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Marcellino Palerme <[email protected]> | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* Wait changing of element in DOM | ||
*/ | ||
|
||
/** | ||
* Wait changing of element in DOM | ||
* @param selector string : css selector of element to follow | ||
* @param adding true: wait adding element in Dow; false: wait removing in Dom | ||
* @returns Promise<HTMLElement> : resolve when element is added or | ||
* removed in DOM | ||
*/ | ||
// thx https://stackoverflow.com/a/61511955 | ||
export function waitElemtDom(selector:string, adding:boolean = true) { | ||
return new Promise(resolve => { | ||
// element already in DOM | ||
if (document.querySelector(selector) && adding) { | ||
return resolve(0); | ||
} | ||
|
||
const observer = new MutationObserver(() => { | ||
// Check if the element now exists in the DOM | ||
if(adding){ | ||
if (document.querySelector(selector)) { | ||
observer.disconnect(); | ||
resolve(0); | ||
} | ||
// Check if the element no longer exists in the DOM | ||
} else if (document.querySelector(selector) == null) { | ||
observer.disconnect(); | ||
resolve(0); | ||
} | ||
}); | ||
|
||
// Start observing the DOM for the element | ||
observer.observe(document.body, { | ||
childList: true, | ||
subtree: true | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters