From 08e38078a003f4afb922ca3f8fcb0c10dbd67bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 24 Mar 2025 09:57:46 +0100 Subject: [PATCH] Removed duplicate Confirm --- public/js/plugin/FhcAlert.js | 53 ++++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/public/js/plugin/FhcAlert.js b/public/js/plugin/FhcAlert.js index 4f07fdf24..6b4d780e3 100644 --- a/public/js/plugin/FhcAlert.js +++ b/public/js/plugin/FhcAlert.js @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * @usage: * Preperations: * Be sure to have PrimeVue loaded with the toast and confirmdialog @@ -23,38 +23,38 @@ * Use: * In your component you can call now the global property $fhcAlert * which has the following functions: - * + * * alertSuccess * ------------ * Displays a success message * @param string message * @return void - * + * * alertInfo * --------- * Displays an info message * @param string message * @return void - * + * * alertWarning * ------------ * Displays a warning * @param string message * @return void - * + * * alertError * ---------- * Displays an error * @param string message * @return void - * + * * alertSystemError * ---------------- * Displays an alert with the error details and a button to mail * the error to the Support Team * @param string message * @return void - * + * * confirmDelete * ------------- * Displays a confirmation dialog and returns a Promise which resolves @@ -67,7 +67,7 @@ * with true or false depending und the pressed button. * @param string message * @return Promise - * + * * alertDefault * ------------ * Displays an alert @@ -76,7 +76,7 @@ * @param string message * @param boolean sticky (optional) defaults to false * @return void - * + * * alertMultiple * ------------- * Displays multiple alerts @@ -85,14 +85,14 @@ * @param string title (optional) defaults to 'Info' * @param boolean sticky (optional) defaults to false * @return void - * + * * handleSystemError * ----------------- * Automatiticly determine how to display an system error and display it. * This would be used in a catch block of an ajax call. * @param mixed error * @return void - * + * * handleSystemMessage * ------------------- * Automatiticly determine how to display a message and display it. @@ -253,28 +253,9 @@ export default { }); }); }, - confirm(message) { - return new Promise((resolve, reject) => { - helperAppInstance.$confirm.require({ - group: 'fhcAlertConfirm', - header: 'Achtung', - message: message, - acceptLabel: 'Ja', - acceptClass: 'btn btn-success', - rejectLabel: 'Abbrechen', - rejectClass: 'btn btn-outline-secondary', - accept() { - resolve(true); - }, - reject() { - resolve(false); - }, - }); - }); - }, alertDefault(severity, title, message, sticky = false) { let options = { severity: severity, summary: title, detail: message}; - + if (!sticky) options.life = 3000; @@ -292,7 +273,7 @@ export default { // don't show an error message to the user if the error was an aborted request if(error.hasOwnProperty('name') && error.name.toLowerCase() === "AbortError".toLowerCase()) return; - + // Error is string if (typeof error === 'string') return $fhcAlert.alertSystemError(error); @@ -304,7 +285,7 @@ export default { // Error has been handled already if (error.hasOwnProperty('handled') && error.handled) return; - + // Error is object if (typeof error === 'object' && error !== null) { let errMsg = ''; @@ -320,7 +301,7 @@ export default { if (error.hasOwnProperty('stack')) errMsg += 'Error Stack: ' + error.stack + '\r\n'; - + // Fallback object error message if (errMsg == '') errMsg = 'Error Message: ' + JSON.stringify(error) + '\r\n'; @@ -394,7 +375,7 @@ export default { // NOTE(chris): reset form validation $fhcAlert.resetFormValidation(form); - + // NOTE(chris): set form input validation const notFound = Object.entries(errors).filter(([key, detail]) => { const input = form.querySelector('[data-fhc-form-validate="' + key + '"]'); @@ -447,4 +428,4 @@ export default { app.config.globalProperties.$fhcAlert = $fhcAlert; app.provide('$fhcAlert', app.config.globalProperties.$fhcAlert); } -} \ No newline at end of file +}