From dbb3f0133aac6d7cc55f567e39b22a164e56acc3 Mon Sep 17 00:00:00 2001 From: "M.Palerme" Date: Fri, 19 Jul 2024 19:13:25 +0200 Subject: [PATCH] #48 add archive action --- components/ManageCalibCurve.async.vue | 46 ++++++++++++++++++++++++++- components/TableDbAction.vue | 26 +++++++++++++++ db/init.sql | 1 + lang/en-US.ts | 3 ++ lang/fr-FR.ts | 3 ++ server/api/class/tableClass.ts | 4 +-- 6 files changed, 79 insertions(+), 4 deletions(-) diff --git a/components/ManageCalibCurve.async.vue b/components/ManageCalibCurve.async.vue index 3fe032f..c91a7af 100644 --- a/components/ManageCalibCurve.async.vue +++ b/components/ManageCalibCurve.async.vue @@ -246,7 +246,10 @@ function updateCalibCurve(){ }); } - +/** + * Confirm the delete of calibration curve + * @param item {id:String, name:String} calibration curves information + */ function deleteCalibCurveAction(item: {id: string, name: string}){ // ask user to confirm the delete of calibration curve useConfirmBox(t("message.confirm.deleteCalibCurve")) @@ -282,6 +285,46 @@ function deleteCalibCurve(item: {id: string, name: string}){ error(t("message.error.deleteCalibCurve")); }); } + +function achiveCalibCurveAction(item: {id: string, name: string}){ + // ask user to confirm the archive of calibration curve + useConfirmBox(t("message.confirm.archiveCalibCurve")) + .then((answer) => { + // if user confirm the archive of calibration curve + if (answer) { + // archive calibration curve + archiveCalibCurve(item); + } + }); +} + +/** + * Archive calibration curve + */ +function archiveCalibCurve(item: {id: string, name: string}){ + // send calibration curve id to archive + $fetch('/api/manageControl/update',{ + method: 'POST', + body: { + nameTable: "calib_curves", + id: item.id, + columns: { + date_achieve: (new Date()).toISOString(), + }, + }, + }) + .then(() => { + // We update the daughter table + rUpload.value = !rUpload.value; + // show message whose say the archive of calibration curve is a success + success(t("message.success.archiveCalibCurve")); + }) + .catch(() => { + // show message whose say the archive of calibration curve is a failure + error(t("message.error.archiveCalibCurve")); + }); +} +