Skip to content

Commit

Permalink
allow jsonrpc request error modal to be conditionally hidden with new…
Browse files Browse the repository at this point in the history
… attribute [pHideSuccessErrorModal]
  • Loading branch information
lanesCSO committed Apr 25, 2024
1 parent c2053a7 commit 8e29b19
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/js/api.constant.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
API - Constant
*******************************************************************************/
const C_API_VERSION = "5.0.0";
const C_API_VERSION = "5.0.4";

/*******************************************************************************
API - Constant - URI
Expand Down
2 changes: 1 addition & 1 deletion src/js/api.constant.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 34 additions & 27 deletions src/js/api.library.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ api.ajax.jsonrpc = {};
* @param {*} callbackFunctionName_onError
* @param {*} callbackParams_onError
* @param {*} pAJAX_Params
* @param {*} pItemSpinner
* @param {*} pHideSuccessErrorModal
*/
api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbackFunctionName_onSuccess, callbackParams_onSuccess, callbackFunctionName_onError, callbackParams_onError, pAJAX_Params, pItemSpinner = null) {
api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbackFunctionName_onSuccess, callbackParams_onSuccess, callbackFunctionName_onError, callbackParams_onError, pAJAX_Params, pItemSpinner = null, pHideSuccessErrorModal = false) {
// Default API parameters
pAPI_Params = pAPI_Params || {};

Expand Down Expand Up @@ -442,39 +444,44 @@ api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbac
}

if (response.error) {
// Init the erro output
var errorOutput = null;

// Check response.error.data exist
if (response.error.data) {
// Format the structured data, either array or object
if (($.isArray(response.error.data) && response.error.data.length)
|| ($.isPlainObject(response.error.data) && !$.isEmptyObject(response.error.data))) {
errorOutput = $("<ul>", {
class: "list-group"
});
$.each(response.error.data, function (_index, value) {
var error = $("<li>", {
class: "list-group-item",
html: value.toString()
if (!pHideSuccessErrorModal) {
// Init the error output
var errorOutput = null;

// Check response.error.data exist
if (response.error.data) {
// Format the structured data, either array or object
if (($.isArray(response.error.data) && response.error.data.length)
|| ($.isPlainObject(response.error.data) && !$.isEmptyObject(response.error.data))) {
errorOutput = $("<ul>", {
class: "list-group"
});
errorOutput.append(error);
});
} else
// Plain error
errorOutput = response.error.data;
} else {
// Get the simple message otherwise
errorOutput = response.error.message;
$.each(response.error.data, function (_index, value) {
var error = $("<li>", {
class: "list-group-item",
html: value.toString()
});
errorOutput.append(error);
});
} else
// Plain error
errorOutput = response.error.data;
} else {
// Get the simple message otherwise
errorOutput = response.error.message;
}

// Pop the error in the Bootstrap Modal
api.modal.error(errorOutput);
}

// Pop the error in the Bootstrap Modal
api.modal.error(errorOutput);

if (callbackFunctionName_onError) {
api.ajax.callback(callbackFunctionName_onError, response.error, callbackParams_onError);
}
} else if (response.result !== undefined) {
}

else if (response.result !== undefined) {
// Check if the response.result property exist
if (callbackFunctionName_onSuccess)
api.ajax.callback(callbackFunctionName_onSuccess, response.result, callbackParams_onSuccess);
Expand Down
Loading

0 comments on commit 8e29b19

Please sign in to comment.