Removed duplicate Confirm

This commit is contained in:
Andreas Österreicher
2025-03-24 09:57:46 +01:00
parent 410231a427
commit 08e38078a0
+17 -36
View File
@@ -13,7 +13,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* @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);
}
}
}