//dashconfig errors return

This commit is contained in:
Vincent Augagneur
2013-11-07 12:05:03 +01:00
parent a890410a64
commit 3c31f1a07f
2 changed files with 32 additions and 5 deletions
+19 -1
View File
@@ -251,6 +251,8 @@ function bindCancelDashConfig()
function saveDashConfig(widget_name)
{
$('section#'+widget_name+' .form-group').removeClass('has-error');
$('#'+widget_name+'_errors').remove();
configs = '';
$('#'+widget_name+' form input, #'+widget_name+' form textarea , #'+widget_name+' form select').each( function () {
if ($(this).attr('type') == 'radio' && !$(this).attr('checked'))
@@ -258,12 +260,16 @@ function saveDashConfig(widget_name)
configs += '&configs['+$(this).attr('name')+']='+$(this).val();
});
data = 'ajax=true&action=saveDashConfig&module='+widget_name+configs+'&hook='+$('#'+widget_name).closest('[id^=hook]').attr('id');
$.ajax({
url : dashboard_ajax_url,
data : data,
dataType: 'json',
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
},
success : function(jsonData){
if (!jsonData.has_errors)
{
$('#'+widget_name).find('section').not('.dash_config').remove();
@@ -271,6 +277,18 @@ function saveDashConfig(widget_name)
refreshDashboard(widget_name);
toggleDashConfig(widget_name);
}
else
{
errors_str = '<div class="alert alert-danger" id="'+widget_name+'_errors">';
for (error in jsonData.errors)
{
errors_str += jsonData.errors[error]+'<br/>';
$('#'+error).closest('.form-group').addClass('has-error');
}
errors_str += '</div>';
$('section#'+widget_name+'_config header').after(errors_str);
errors_str += '</div>';
}
}
});
}