diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb index 5de1b87ff..22c646c98 100644 --- a/app/assets/javascripts/samples/sample_datatable.js.erb +++ b/app/assets/javascripts/samples/sample_datatable.js.erb @@ -946,17 +946,14 @@ function changeToEditMode() { '>' + ' ' + '' + generateColumnNameTooltip(el.innerText) + ' ' + - '' + + '' + '' + '' + '' + ' ' + - '' + - ' ' + - '' + - '' + - '' + - ''; + '' + + '' + + ''; dropdownList.append(html); } }); @@ -1043,13 +1040,23 @@ function changeToEditMode() { data: {custom_field: {name: newName}}, dataType: 'json', success: function() { + dropdownList.sortable('enable'); + $(li).clearFormErrors(); text.html(generateColumnNameTooltip(newName)); $(table.columns().header()).filter('#' + id) .html(generateColumnNameTooltip(newName)); + cancelEditMode(); }, - error: function(xhr) { - // TODO + error: function(xhr, ajaxOptions, thrownError) { + dropdownList.sortable('disable'); + $(li).clearFormErrors(); + var msg = $.parseJSON(xhr.responseText); + renderFormError(event, + $(li).find('.text-edit'), + Object.keys(msg)[0] + ' '+ msg.name.toString()); + var verticalHeight = $(li).offset().top; + dropdownList.scrollTo(verticalHeight,0); } }); } @@ -1058,6 +1065,11 @@ function changeToEditMode() { dropdownList.on('click', '.edit:not(.disabled)', function(event) { event.stopPropagation(); + // Clear all input errors + _.each(dropdownList, function(el) { + $(el).clearFormErrors(); + }); + cancelEditMode(); var self = $(this); @@ -1098,6 +1110,7 @@ function changeToEditMode() { dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); + $(li).clearFormErrors(); editColumn(li); }); @@ -1108,6 +1121,7 @@ function changeToEditMode() { dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); + $(li).clearFormErrors(); editColumn(li); } }); @@ -1118,7 +1132,7 @@ function changeToEditMode() { dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); - + $(li).clearFormErrors(); columnEditMode = false; li.removeClass('editing'); diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index 14f31805e..e89f96c92 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1681,7 +1681,8 @@ textarea.textarea-sm { } .cancel { - margin-right: 28px; + margin-left: 5px; + margin-right: 15px; } .vis { @@ -1695,6 +1696,16 @@ textarea.textarea-sm { .del { } } + + .help-block { + display: inline-block; + margin-bottom: 0; + margin-left: 25px; + } +} + +.add-new-column-form .help-block { + margin-left: 0; } th.custom-field .modal-tooltiptext {