From bc95c66f57555a5bee648ab7cb5f088bb8ca01d7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 26 Mar 2023 22:50:37 +0000 Subject: [PATCH] fix form response handling --- UI/Component/Form.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 17b3610..c66bd47 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -1052,8 +1052,6 @@ export class Form const response = new Response(o); let successInject = null; - - if ((successInject = form.getSuccess()) !== null) { successInject(response); } else if (redirect !== null) { @@ -1099,13 +1097,25 @@ export class Form request.setResultCallback(0, function (xhr) { - self.app.notifyManager.send( - new NotificationMessage( - NotificationLevel.ERROR, - 'Failure', - 'Some failure happened' - ), NotificationType.APP_NOTIFICATION - ); + try { + const o = JSON.parse(xhr.response)[0]; + const response = new Response(o); + + if (typeof response.get('type') !== 'undefined') { + } else if (typeof o.status !== 'undefined' && o.status !== NotificationLevel.HIDDEN) { + self.app.notifyManager.send( + new NotificationMessage(o.status, o.title, o.message), NotificationType.APP_NOTIFICATION + ); + } + } catch (e) { + self.app.notifyManager.send( + new NotificationMessage( + NotificationLevel.ERROR, + 'Failure', + 'Some failure happened' + ), NotificationType.APP_NOTIFICATION + ); + } }); if (window.omsApp.state) {