Merge pull request #351 from ZmagoD/zd_SCI_789

adds error message in samples table dropdown [fixes SCI-789]
This commit is contained in:
Zmago Devetak 2016-12-15 11:05:00 +01:00 committed by GitHub
commit 9b0d0b23dc
2 changed files with 36 additions and 11 deletions

View file

@ -946,17 +946,14 @@ function changeToEditMode() {
'>' + '>' +
'<i class="grippy"></i> ' + '<i class="grippy"></i> ' +
'<span class="text">' + generateColumnNameTooltip(el.innerText) + '</span> ' + '<span class="text">' + generateColumnNameTooltip(el.innerText) + '</span> ' +
'<input type="text" class="text-edit form-control" style="display: none;" />' + '<span class="form-group"><input type="text" class="text-edit form-control" style="display: none;" />' +
'<span class="pull-right controls">' + '<span class="pull-right controls">' +
'<span class="ok glyphicon glyphicon-ok" style="display: none;"></span>' + '<span class="ok glyphicon glyphicon-ok" style="display: none;"></span>' +
'<span class="cancel glyphicon glyphicon-remove" style="display: none;"></span>' + '<span class="cancel glyphicon glyphicon-remove" style="display: none;"></span>' +
'<span class="vis glyphicon ' + visClass + '"></span> ' + '<span class="vis glyphicon ' + visClass + '"></span> ' +
'<span class="edit glyphicon glyphicon-pencil ' + editClass + '">' + '<span class="edit glyphicon glyphicon-pencil ' + editClass + '"></span>' +
'</span> ' + '<span class="del glyphicon glyphicon-trash ' + delClass + '"></span>' +
'<span class="del glyphicon glyphicon-trash ' + delClass + '">' + '</span></span></li>';
'</span>' +
'</span>' +
'</li>';
dropdownList.append(html); dropdownList.append(html);
} }
}); });
@ -1043,13 +1040,23 @@ function changeToEditMode() {
data: {custom_field: {name: newName}}, data: {custom_field: {name: newName}},
dataType: 'json', dataType: 'json',
success: function() { success: function() {
dropdownList.sortable('enable');
$(li).clearFormErrors();
text.html(generateColumnNameTooltip(newName)); text.html(generateColumnNameTooltip(newName));
$(table.columns().header()).filter('#' + id) $(table.columns().header()).filter('#' + id)
.html(generateColumnNameTooltip(newName)); .html(generateColumnNameTooltip(newName));
cancelEditMode(); cancelEditMode();
}, },
error: function(xhr) { error: function(xhr, ajaxOptions, thrownError) {
// TODO 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) { dropdownList.on('click', '.edit:not(.disabled)', function(event) {
event.stopPropagation(); event.stopPropagation();
// Clear all input errors
_.each(dropdownList, function(el) {
$(el).clearFormErrors();
});
cancelEditMode(); cancelEditMode();
var self = $(this); var self = $(this);
@ -1098,6 +1110,7 @@ function changeToEditMode() {
dropdownList.sortable('enable'); dropdownList.sortable('enable');
var self = $(this); var self = $(this);
var li = self.closest('li'); var li = self.closest('li');
$(li).clearFormErrors();
editColumn(li); editColumn(li);
}); });
@ -1108,6 +1121,7 @@ function changeToEditMode() {
dropdownList.sortable('enable'); dropdownList.sortable('enable');
var self = $(this); var self = $(this);
var li = self.closest('li'); var li = self.closest('li');
$(li).clearFormErrors();
editColumn(li); editColumn(li);
} }
}); });
@ -1118,7 +1132,7 @@ function changeToEditMode() {
dropdownList.sortable('enable'); dropdownList.sortable('enable');
var self = $(this); var self = $(this);
var li = self.closest('li'); var li = self.closest('li');
$(li).clearFormErrors();
columnEditMode = false; columnEditMode = false;
li.removeClass('editing'); li.removeClass('editing');

View file

@ -1681,7 +1681,8 @@ textarea.textarea-sm {
} }
.cancel { .cancel {
margin-right: 28px; margin-left: 5px;
margin-right: 15px;
} }
.vis { .vis {
@ -1695,6 +1696,16 @@ textarea.textarea-sm {
.del { .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 { th.custom-field .modal-tooltiptext {