mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-18 16:18:47 +02:00
N°1568 Portal: Fix async error messages catching when submitting a form was redirecting to a modal that crashed (eg. Transition on object that failed to load)
SVN:trunk[5958]
This commit is contained in:
@@ -388,6 +388,16 @@
|
||||
sUrl += (sUrl.split('?')[1] ? '&':'?') + sParamName + '=' + sParamValue;
|
||||
return sUrl;
|
||||
};
|
||||
// Test is sString is a valid JSON string
|
||||
var IsJSONString = function(sString)
|
||||
{
|
||||
try {
|
||||
JSON.parse(sString);
|
||||
} catch (oException) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var GetContentLoaderTemplate = function()
|
||||
{
|
||||
return '<div class="content_loader"><div class="icon glyphicon glyphicon-refresh"></div><div class="message">{{ 'Page:PleaseWait'|dict_s }}</div></div>';
|
||||
@@ -460,6 +470,19 @@
|
||||
{
|
||||
ShowErrorDialog('{{ 'UI:ObjectDoesNotExist'|dict_s|escape('js') }}', '{{ 'Error:HTTP:404'|dict_s|escape('js') }}');
|
||||
}
|
||||
else if(oXHR.responseText !== undefined && IsJSONString(oXHR.responseText) === true)
|
||||
{
|
||||
var oData = JSON.parse(oXHR.responseText);
|
||||
// Catching AJAX exception with detailed error.
|
||||
if( (oData.error_message !== undefined) && (oData.error_title !== undefined) )
|
||||
{
|
||||
ShowErrorDialog(oData.error_message, oData.error_title);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowErrorDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowErrorDialog();
|
||||
|
||||
@@ -263,6 +263,10 @@ footer {
|
||||
/******************/
|
||||
/* Modal settings */
|
||||
/******************/
|
||||
#modal-for-alert {
|
||||
z-index: 9999;
|
||||
/* Should always be on top to display errors messages */
|
||||
}
|
||||
.modal-content .content_loader {
|
||||
margin: 7em 0em;
|
||||
text-align: center;
|
||||
|
||||
@@ -278,6 +278,9 @@ footer{
|
||||
/******************/
|
||||
/* Modal settings */
|
||||
/******************/
|
||||
#modal-for-alert{
|
||||
z-index: 9999; /* Should always be on top to display errors messages */
|
||||
}
|
||||
.modal-content .content_loader{
|
||||
margin: 7em 0em;
|
||||
text-align: center;
|
||||
|
||||
@@ -175,7 +175,15 @@ $(function()
|
||||
// Passing formmanager data to the next page, just in case it needs it (eg. when applying stimulus)
|
||||
formmanager_class: me.options.formmanager_class,
|
||||
formmanager_data: JSON.stringify(me.options.formmanager_data)
|
||||
}
|
||||
},
|
||||
function(oData, sStatus, oXHR)
|
||||
{
|
||||
if(sStatus === 'error')
|
||||
{
|
||||
// Hiding modal in case of error as the general AJAX error handler will display a message
|
||||
oModalElem.modal('hide');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
oModalElem.modal('show');
|
||||
|
||||
Reference in New Issue
Block a user