Merge pull request #163 from ZmagoD/zd_SCI_467

fixes edit modal [fixes SCI-467]
This commit is contained in:
Zmago Devetak 2016-09-23 08:57:33 +02:00 committed by GitHub
commit e1cf66f02a

View file

@ -17,6 +17,7 @@
}); });
validateMoveModal(id); validateMoveModal(id);
clearModal($(id)); clearModal($(id));
validateExperimentForm($(id));
}) })
.on("ajax:error", function() { .on("ajax:error", function() {
animateSpinner(null, false); animateSpinner(null, false);
@ -73,6 +74,36 @@
.clearFormErrors(); .clearFormErrors();
} }
} }
// Reload after successfully updated experiment
function validateExperimentForm(element){
if ( element ) {
var form = element.find("form");
form
.on('ajax:success' , function(){
animateSpinner(form, true);
location.reload();
})
.on('ajax:error', function(e, error){
var msg = JSON.parse(error.responseText);
if ( 'name' in msg ) {
renderFormError(e,
element.find("#experiment-name"),
msg.name.toString(),
true);
} else if ( 'description' in msg ) {
renderFormError(e,
element.find("#experiment-description"),
msg.description.toString(),
true);
} else {
renderFormError(e,
element.find("#experiment-name"),
error.statusText,
true);
}
});
}
}
// Initialize no description edit link // Initialize no description edit link
function initEditNoDescription(){ function initEditNoDescription(){
var modal = "#edit-experiment-modal-"; var modal = "#edit-experiment-modal-";