From d9971b450224522407bfac7a4565e2c34494d33c Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 13 Dec 2016 17:08:19 +0100 Subject: [PATCH 1/4] adds error message in samples table dropdown [fixes SCI-789] --- .../javascripts/samples/sample_datatable.js | 28 ++++++++++++++----- app/assets/stylesheets/themes/scinote.scss | 13 ++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/samples/sample_datatable.js b/app/assets/javascripts/samples/sample_datatable.js index 362b90234..9de40dcbf 100644 --- a/app/assets/javascripts/samples/sample_datatable.js +++ b/app/assets/javascripts/samples/sample_datatable.js @@ -937,15 +937,15 @@ function changeToEditMode() { '>' + ' ' + '' + el.innerText + ' ' + - '' + + '' + '' + '' + '' + ' ' + '' + - ' ' + - '' + '' + + '' + + '' + '' + ''; dropdownList.append(html); @@ -1034,10 +1034,15 @@ function changeToEditMode() { success: function() { text.text(newName); $(table.columns().header()).filter('#' + id).text(newName); + $(li).clearFormErrors(); cancelEditMode(); }, - error: function(xhr) { - // TODO + error: function(xhr, ajaxOptions, thrownError) { + $(li).clearFormErrors(); + var msg = $.parseJSON(xhr.responseText); + renderFormError(event, + $(li).find('.text-edit'), + Object.keys(msg)[0] + ' '+ msg.name.toString()); } }); } @@ -1067,7 +1072,10 @@ function changeToEditMode() { controls.hide(); textEdit.css('display', ''); // show() doesn't work controlsEdit.css('display', ''); // show() doesn't work - + dropdownList.sortable('disable'); + dropdownList.on('click', function(ev) { + ev.stopPropagation(); + }); // Focus input textEdit.focus(); }); @@ -1080,8 +1088,10 @@ function changeToEditMode() { // On ok buttons click dropdownList.on('click', '.ok', function(event) { event.stopPropagation(); + dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); + $(li).clearFormErrors(); editColumn(li); }); @@ -1089,8 +1099,10 @@ function changeToEditMode() { dropdownList.on('keydown', 'input.text-edit', function(event) { if (event.keyCode === 13) { event.preventDefault(); + dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); + $(li).clearFormErrors(); editColumn(li); } }); @@ -1098,9 +1110,10 @@ function changeToEditMode() { // On cancel buttons click dropdownList.on('click', '.cancel', function(event) { event.stopPropagation(); + dropdownList.sortable('enable'); var self = $(this); var li = self.closest('li'); - + $(li).clearFormErrors(); columnEditMode = false; li.removeClass('editing'); @@ -1206,6 +1219,7 @@ function changeToEditMode() { }); $('#samples-columns-dropdown').on('show.bs.dropdown', function() { loadColumnsNames(); + dropdownList.sortable('enable'); }); } diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index cb1e0c311..ca3f4c8a8 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1676,7 +1676,8 @@ textarea.textarea-sm { } .cancel { - margin-right: 28px; + margin-right: 15px; + margin-left: 5px; } .vis { @@ -1690,4 +1691,14 @@ textarea.textarea-sm { .del { } } + + .help-block { + display: inline-block; + margin-bottom: 0; + margin-left: 25px; + } +} + +.add-new-column-form .help-block { + margin-left: 0; } From b003d192c34b76cb20a5f1eec92cdba758b05f8b Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 15 Dec 2016 09:54:38 +0100 Subject: [PATCH 2/4] fixed edit mode --- app/assets/javascripts/samples/sample_datatable.js | 5 +++++ app/assets/stylesheets/themes/scinote.scss | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/samples/sample_datatable.js b/app/assets/javascripts/samples/sample_datatable.js index 9de40dcbf..dfe1871e2 100644 --- a/app/assets/javascripts/samples/sample_datatable.js +++ b/app/assets/javascripts/samples/sample_datatable.js @@ -1051,6 +1051,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); diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index ca3f4c8a8..78b9085f2 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -1676,8 +1676,8 @@ textarea.textarea-sm { } .cancel { - margin-right: 15px; margin-left: 5px; + margin-right: 15px; } .vis { From b1648862704c27a3615ea70da0f20c3c67250840 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 15 Dec 2016 10:44:23 +0100 Subject: [PATCH 3/4] fixed error mesage scroll --- app/assets/javascripts/samples/sample_datatable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/samples/sample_datatable.js b/app/assets/javascripts/samples/sample_datatable.js index dfe1871e2..6e34a0742 100644 --- a/app/assets/javascripts/samples/sample_datatable.js +++ b/app/assets/javascripts/samples/sample_datatable.js @@ -1032,12 +1032,16 @@ function changeToEditMode() { data: {custom_field: {name: newName}}, dataType: 'json', success: function() { + dropdownList.sortable('enable'); text.text(newName); $(table.columns().header()).filter('#' + id).text(newName); $(li).clearFormErrors(); cancelEditMode(); }, error: function(xhr, ajaxOptions, thrownError) { + dropdownList.sortable('disable'); + var verticalHeight = $(li).offset().top; + dropdownList.scrollTo(verticalHeight,0); $(li).clearFormErrors(); var msg = $.parseJSON(xhr.responseText); renderFormError(event, From 3e31f114d473b7fff0d0205edf02bcd1cbad0a65 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 15 Dec 2016 10:51:17 +0100 Subject: [PATCH 4/4] app/assets/javascripts/samples/sample_datatable.js --- app/assets/javascripts/samples/sample_datatable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/samples/sample_datatable.js b/app/assets/javascripts/samples/sample_datatable.js index 6e34a0742..4e34e8ed4 100644 --- a/app/assets/javascripts/samples/sample_datatable.js +++ b/app/assets/javascripts/samples/sample_datatable.js @@ -1040,13 +1040,13 @@ function changeToEditMode() { }, error: function(xhr, ajaxOptions, thrownError) { dropdownList.sortable('disable'); - var verticalHeight = $(li).offset().top; - dropdownList.scrollTo(verticalHeight,0); $(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); } }); }