mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
add error validations
This commit is contained in:
parent
6143b257d0
commit
4f2df691ba
1 changed files with 21 additions and 2 deletions
|
@ -17,7 +17,7 @@
|
||||||
});
|
});
|
||||||
validateMoveModal(id);
|
validateMoveModal(id);
|
||||||
clearModal($(id));
|
clearModal($(id));
|
||||||
reloadPageAfterUpdate($(id));
|
validateExperimentForm($(id));
|
||||||
})
|
})
|
||||||
.on("ajax:error", function() {
|
.on("ajax:error", function() {
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
|
@ -75,13 +75,32 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reload after successfully updated experiment
|
// Reload after successfully updated experiment
|
||||||
function reloadPageAfterUpdate(element){
|
function validateExperimentForm(element){
|
||||||
if ( element ) {
|
if ( element ) {
|
||||||
var form = element.find("form");
|
var form = element.find("form");
|
||||||
form
|
form
|
||||||
.on('ajax:success' , function(){
|
.on('ajax:success' , function(){
|
||||||
animateSpinner(form, true);
|
animateSpinner(form, true);
|
||||||
location.reload();
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue