mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-28 09:43:01 +08:00
setup experiment modal input validation
This commit is contained in:
parent
9440371f3f
commit
de6c03a73b
2 changed files with 19 additions and 3 deletions
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
// Create ajax hook on given 'element', which should return modal with 'id' =>
|
// Create ajax hook on given 'element', which should return modal with 'id' =>
|
||||||
// show that modal
|
// show that modal
|
||||||
function initializeModal(element, id){
|
function initializeModal(element, id){
|
||||||
|
|
||||||
|
// Initializev new experiment modal listner
|
||||||
$(element)
|
$(element)
|
||||||
.on("ajax:beforeSend", function(){
|
.on("ajax:beforeSend", function(){
|
||||||
animateSpinner();
|
animateSpinner();
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
keyboard: false,
|
keyboard: false,
|
||||||
});
|
});
|
||||||
validateMoveModal(id);
|
validateMoveModal(id);
|
||||||
|
validateExperimentForm();
|
||||||
})
|
})
|
||||||
.on("ajax:error", function() {
|
.on("ajax:error", function() {
|
||||||
animateSpinner(null, false);
|
animateSpinner(null, false);
|
||||||
|
@ -63,6 +65,14 @@
|
||||||
})
|
})
|
||||||
.clearFormErrors();
|
.clearFormErrors();
|
||||||
}
|
}
|
||||||
|
// Setup front-end validations for experiment form
|
||||||
|
function validateExperimentForm(){
|
||||||
|
var form = $("#new-experiment-modal").find("form");
|
||||||
|
form.on('submit', function(ev){
|
||||||
|
textValidator(ev, $('#new-experiment-name'), false);
|
||||||
|
textValidator(ev, $('#new-experiment-description'), true);
|
||||||
|
});
|
||||||
|
form.clearFormErrors();
|
||||||
}
|
}
|
||||||
// Initialize no description edit link
|
// Initialize no description edit link
|
||||||
function initEditNoDescription(){
|
function initEditNoDescription(){
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= form.text_field :name, label: t("experiments.new.name"), autofocus: true, placeholder: t("experiments.new.name_placeholder") %>
|
<%= form.text_field :name,
|
||||||
|
label: t("experiments.new.name"),
|
||||||
|
autofocus: true,
|
||||||
|
placeholder: t("experiments.new.name_placeholder"),
|
||||||
|
id: 'new-experiment-name'%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +13,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= form.text_area :description, label: t('experiments.new.description') %>
|
<%= form.text_area :description,
|
||||||
|
label: t('experiments.new.description'),
|
||||||
|
id: 'new-experiment-description' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue