mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
fixed the implementation according to PR review, now validates all table names, when multiple are present, and uses gon gem
This commit is contained in:
parent
7d093fa11d
commit
c6936bc71e
1 changed files with 18 additions and 10 deletions
|
@ -545,21 +545,29 @@
|
||||||
var $tinyMCEInput = TinyMCE.getContent();
|
var $tinyMCEInput = TinyMCE.getContent();
|
||||||
var descriptionValid = textValidator(ev, $descrTextarea, 0,
|
var descriptionValid = textValidator(ev, $descrTextarea, 0,
|
||||||
<%= Constants::TEXT_MAX_LENGTH %>, false, $tinyMCEInput);
|
<%= Constants::TEXT_MAX_LENGTH %>, false, $tinyMCEInput);
|
||||||
var $table_names = $form.find(".table_name");
|
var tableNamesValidArray = [];
|
||||||
var table_nameValid;
|
// iterate over table titles and validate their length
|
||||||
if ($table_names.length > 0) // if table exists check its title, if not, its validated
|
$form.find(".table_name").each(function(index , tableName) {
|
||||||
{
|
if (tableName.value.length > 0) {
|
||||||
table_nameValid = textValidator(ev, $table_names, 1,
|
tableNamesValidArray[index] = textValidator(ev, tableName, 1,
|
||||||
<%= Constants::NAME_MAX_LENGTH %>);
|
gon.global.NAME_MAX_LENGTH);
|
||||||
}else{
|
} else {
|
||||||
table_nameValid = true
|
tableNamesValidArray[index] = true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
var tableNamesValid = true;
|
||||||
|
// passes if all table names are valid
|
||||||
|
for (var i=0;i<tableNamesValidArray.length;i++){
|
||||||
|
if(tableNamesValidArray[i] !== true){
|
||||||
|
tableNamesValid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DragNDropSteps.filesStatus() &&
|
if (DragNDropSteps.filesStatus() &&
|
||||||
checklistsValid &&
|
checklistsValid &&
|
||||||
nameValid &&
|
nameValid &&
|
||||||
descriptionValid &&
|
descriptionValid &&
|
||||||
table_nameValid ) {
|
tableNamesValid ) {
|
||||||
|
|
||||||
$form.find("[data-role='editable-table']").each(function() {
|
$form.find("[data-role='editable-table']").each(function() {
|
||||||
var hot = $(this).find(".hot").handsontable('getInstance');
|
var hot = $(this).find(".hot").handsontable('getInstance');
|
||||||
|
|
Loading…
Add table
Reference in a new issue