Skip to content

Commit 8e29b19

Browse files
committed
allow jsonrpc request error modal to be conditionally hidden with new attribute [pHideSuccessErrorModal]
1 parent c2053a7 commit 8e29b19

File tree

4 files changed

+37
-30
lines changed

4 files changed

+37
-30
lines changed

src/js/api.constant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
API - Constant
33
*******************************************************************************/
4-
const C_API_VERSION = "5.0.0";
4+
const C_API_VERSION = "5.0.4";
55

66
/*******************************************************************************
77
API - Constant - URI

src/js/api.constant.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/api.library.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,10 @@ api.ajax.jsonrpc = {};
393393
* @param {*} callbackFunctionName_onError
394394
* @param {*} callbackParams_onError
395395
* @param {*} pAJAX_Params
396+
* @param {*} pItemSpinner
397+
* @param {*} pHideSuccessErrorModal
396398
*/
397-
api.ajax.jsonrpc.request = function (pAPI_URL, pAPI_Method, pAPI_Params, callbackFunctionName_onSuccess, callbackParams_onSuccess, callbackFunctionName_onError, callbackParams_onError, pAJAX_Params, pItemSpinner = null) {
399+
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) {
398400
// Default API parameters
399401
pAPI_Params = pAPI_Params || {};
400402

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

444446
if (response.error) {
445-
// Init the erro output
446-
var errorOutput = null;
447-
448-
// Check response.error.data exist
449-
if (response.error.data) {
450-
// Format the structured data, either array or object
451-
if (($.isArray(response.error.data) && response.error.data.length)
452-
|| ($.isPlainObject(response.error.data) && !$.isEmptyObject(response.error.data))) {
453-
errorOutput = $("<ul>", {
454-
class: "list-group"
455-
});
456-
$.each(response.error.data, function (_index, value) {
457-
var error = $("<li>", {
458-
class: "list-group-item",
459-
html: value.toString()
447+
if (!pHideSuccessErrorModal) {
448+
// Init the error output
449+
var errorOutput = null;
450+
451+
// Check response.error.data exist
452+
if (response.error.data) {
453+
// Format the structured data, either array or object
454+
if (($.isArray(response.error.data) && response.error.data.length)
455+
|| ($.isPlainObject(response.error.data) && !$.isEmptyObject(response.error.data))) {
456+
errorOutput = $("<ul>", {
457+
class: "list-group"
460458
});
461-
errorOutput.append(error);
462-
});
463-
} else
464-
// Plain error
465-
errorOutput = response.error.data;
466-
} else {
467-
// Get the simple message otherwise
468-
errorOutput = response.error.message;
459+
$.each(response.error.data, function (_index, value) {
460+
var error = $("<li>", {
461+
class: "list-group-item",
462+
html: value.toString()
463+
});
464+
errorOutput.append(error);
465+
});
466+
} else
467+
// Plain error
468+
errorOutput = response.error.data;
469+
} else {
470+
// Get the simple message otherwise
471+
errorOutput = response.error.message;
472+
}
473+
474+
// Pop the error in the Bootstrap Modal
475+
api.modal.error(errorOutput);
469476
}
470477

471-
// Pop the error in the Bootstrap Modal
472-
api.modal.error(errorOutput);
473478

474479
if (callbackFunctionName_onError) {
475480
api.ajax.callback(callbackFunctionName_onError, response.error, callbackParams_onError);
476481
}
477-
} else if (response.result !== undefined) {
482+
}
483+
484+
else if (response.result !== undefined) {
478485
// Check if the response.result property exist
479486
if (callbackFunctionName_onSuccess)
480487
api.ajax.callback(callbackFunctionName_onSuccess, response.result, callbackParams_onSuccess);

0 commit comments

Comments
 (0)