From 4be36f08e0e09b33d9ed520ef7e5a0c59c8d6107 Mon Sep 17 00:00:00 2001 From: Serhii Shymkiv Date: Sun, 12 Aug 2018 16:31:19 +0300 Subject: [PATCH] * Error details rendering on the client side. --- src/main/resources/static/css/app.css | 11 ++++++++ src/main/resources/static/js/private/app.js | 28 ++++++++++++++----- .../resources/templates/account/checkout.html | 3 +- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index d3b0a71..0d21a14 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -62,3 +62,14 @@ body { text-align: left; white-space: pre-wrap; } + +.error-message { + color: #575757; + font-size: 15px; +} + +.error-details { + color: gray; + font-size: 12px; + text-align: left; +} diff --git a/src/main/resources/static/js/private/app.js b/src/main/resources/static/js/private/app.js index ed33ce8..19e79cb 100644 --- a/src/main/resources/static/js/private/app.js +++ b/src/main/resources/static/js/private/app.js @@ -68,22 +68,36 @@ $(function() { color = "red"; } - if (json.state !== undefined) { + if (json.state) { text = json.state; } // noinspection JSUnresolvedVariable - if (json.errorResponse !== undefined && - json.errorResponse != null && - json.errorResponse.message != null) { - // noinspection JSUnresolvedVariable - message = '

' + json.errorResponse.message + '

'; + if (json.errorResponse && + json.errorResponse.message) { + message = '

' + json.errorResponse.message + '

'; + + if (json.errorResponse.details) { + message += '

'; + + $.each(json.errorResponse.details, function(index, value) { + // noinspection JSUnresolvedVariable + message += (index + 1) + '. ' + value.field + ': ' + value.issue + '
'; + }); + + message += '

'; + } } } else { color = "red"; } - paymentProcessingInfoId.append('

' + text.toUpperCase() + '

' + message + '
'); + paymentProcessingInfoId.append( + '
' + + '

' + text.toUpperCase() + '

' + + message + + '
' + ); paymentProcDialog.modal("show"); }); diff --git a/src/main/resources/templates/account/checkout.html b/src/main/resources/templates/account/checkout.html index e0e8563..881c793 100644 --- a/src/main/resources/templates/account/checkout.html +++ b/src/main/resources/templates/account/checkout.html @@ -4,6 +4,7 @@ + @@ -78,7 +79,7 @@

- +