mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 15:05:26 +08:00
Merge pull request #330 from okriuchykhin/ok_SCI_695
Added sorting functionality to samples columns dropdown [SCI-695]
This commit is contained in:
commit
a1be687e45
2 changed files with 34 additions and 3 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
//= require jquery-ui
|
||||||
|
|
||||||
var rowsSelected = [];
|
var rowsSelected = [];
|
||||||
|
|
||||||
// Tells whether we're currently viewing or editing table
|
// Tells whether we're currently viewing or editing table
|
||||||
|
@ -760,8 +762,10 @@ function changeToEditMode() {
|
||||||
|
|
||||||
// loads the columns names in the dropdown list
|
// loads the columns names in the dropdown list
|
||||||
function loadColumnsNames() {
|
function loadColumnsNames() {
|
||||||
|
// First, clear the list
|
||||||
|
dropdownList.find('li[data-position]').remove();
|
||||||
_.each(table.columns().header(), function(el, index) {
|
_.each(table.columns().header(), function(el, index) {
|
||||||
if( index > 1 ) {
|
if (index > 1) {
|
||||||
var colIndex = $(el).attr('data-column-index');
|
var colIndex = $(el).attr('data-column-index');
|
||||||
var visible = table.column(colIndex).visible();
|
var visible = table.column(colIndex).visible();
|
||||||
var visClass = (visible) ? 'glyphicon-eye-open' : 'glyphicon-eye-close';
|
var visClass = (visible) ? 'glyphicon-eye-open' : 'glyphicon-eye-close';
|
||||||
|
@ -776,7 +780,7 @@ function changeToEditMode() {
|
||||||
dropdownList.append(html);
|
dropdownList.append(html);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
toggleColumnVisibility();
|
||||||
// toggles grip img
|
// toggles grip img
|
||||||
customLiHoverEffect();
|
customLiHoverEffect();
|
||||||
}
|
}
|
||||||
|
@ -816,11 +820,30 @@ function changeToEditMode() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initSorting() {
|
||||||
|
dropdownList.sortable({
|
||||||
|
items: 'li:not(.new-samples-column)',
|
||||||
|
cancel: '.new-samples-column',
|
||||||
|
axis: 'y',
|
||||||
|
update: function() {
|
||||||
|
var reorderer = table.colReorder;
|
||||||
|
var listIds = [];
|
||||||
|
// We skip first two columns
|
||||||
|
listIds.push(0, 1);
|
||||||
|
dropdownList.find('li[data-position]').each(function() {
|
||||||
|
listIds.push($(this).first().data('position'));
|
||||||
|
});
|
||||||
|
reorderer.order(listIds, false);
|
||||||
|
loadColumnsNames();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// initialze dropdown after the table is loaded
|
// initialze dropdown after the table is loaded
|
||||||
function initDropdown() {
|
function initDropdown() {
|
||||||
table.on('draw.dt', function() {
|
table.on('draw.dt', function() {
|
||||||
loadColumnsNames();
|
loadColumnsNames();
|
||||||
toggleColumnVisibility();
|
initSorting();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1590,11 +1590,19 @@ textarea.textarea-sm {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
|
|
||||||
li {
|
li {
|
||||||
|
background: $color-white;
|
||||||
border: 1px solid $color-alto;
|
border: 1px solid $color-alto;
|
||||||
|
cursor: -webkit-grab;
|
||||||
|
cursor: grab;
|
||||||
padding: 10px 10px 10px 0;
|
padding: 10px 10px 10px 0;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui-sortable-helper {
|
||||||
|
cursor: -webkit-grabbing;
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
.vis {
|
.vis {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
|
Loading…
Reference in a new issue