Skip to content

Commit 5ed3342

Browse files
committed
Selection table: fix sorting of color table
This was likely broken when introducing new visibility columns. Also, the sorting column selection has been made more robust by using column names rather than index values. Fixes #2283
1 parent e17e802 commit 5ed3342

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

django/applications/catmaid/static/js/widgets/selection-table.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,20 +1321,23 @@
13211321
orderCellsTop: true,
13221322
columns: [
13231323
{
1324+
"name": "index",
13241325
"type": "text",
13251326
"visible": false,
13261327
"render": function(data, type, row, meta) {
13271328
return row.index + '';
13281329
}
13291330
},
13301331
{
1332+
"name": "remove",
13311333
"orderable": false,
13321334
"className": "dt-center cm-center",
13331335
"render": function(data, type, row, meta) {
13341336
return '<i class="fa fa-remove fa-fw clickable action-remove" alt="Remove" title="Remove"></i>';
13351337
}
13361338
},
13371339
{
1340+
"name": "name",
13381341
"type": "text",
13391342
"render": {
13401343
"display": (data, type, row, meta) => {
@@ -1349,59 +1352,68 @@
13491352
}
13501353
},
13511354
{
1355+
"name": "review",
13521356
"type": "text",
13531357
"render": function(data, type, row, meta) {
13541358
return row.reviewPercentage + "%";
13551359
}
13561360
},
13571361
{
1362+
"name": "selected",
13581363
"render": function(data, type, row, meta) {
13591364
return createCheckbox('selected', row.skeleton);
13601365
}
13611366
},
13621367
{
1368+
"name": "pre_visible",
13631369
"orderable": false,
13641370
"visible": this.showVisibilityControls,
13651371
"render": function(data, type, row, meta) {
13661372
return createCheckbox('pre_visible', row.skeleton);
13671373
}
13681374
},
13691375
{
1376+
"name": "post_visible",
13701377
"orderable": false,
13711378
"visible": this.showVisibilityControls,
13721379
"render": function(data, type, row, meta) {
13731380
return createCheckbox('post_visible', row.skeleton);
13741381
}
13751382
},
13761383
{
1384+
"name": "desmo_visible",
13771385
"orderable": false,
13781386
"visible": this.showVisibilityControls,
13791387
"render": function(data, type, row, meta) {
13801388
return createCheckbox('desmosome_visible', row.skeleton);
13811389
}
13821390
},
13831391
{
1392+
"name": "mito_visible",
13841393
"orderable": false,
13851394
"visible": this.showVisibilityControls,
13861395
"render": function(data, type, row, meta) {
13871396
return createCheckbox('mitochondrion_visible', row.skeleton);
13881397
}
13891398
},
13901399
{
1400+
"name": "text_visible",
13911401
"orderable": false,
13921402
"visible": this.showVisibilityControls,
13931403
"render": function(data, type, row, meta) {
13941404
return createCheckbox('text_visible', row.skeleton);
13951405
}
13961406
},
13971407
{
1408+
"name": "meta_visible",
13981409
"orderable": false,
13991410
"visible": this.showVisibilityControls,
14001411
"render": function(data, type, row, meta) {
14011412
return createCheckbox('meta_visible', row.skeleton);
14021413
}
14031414
},
14041415
{
1416+
"name": "color",
14051417
"type": "hslcolor",
14061418
"className": "dt-center cm-center",
14071419
"render": {
@@ -1418,6 +1430,7 @@
14181430
}
14191431
},
14201432
{
1433+
"name": "actions",
14211434
"orderable": false,
14221435
"render": function(data, type, row, meta) {
14231436
return '<i class="fa fa-tag fa-fw clickable action-annotate" ' +
@@ -1635,17 +1648,18 @@
16351648
* Re-apply current order to skeleton list.
16361649
*/
16371650
SelectionTable.prototype.reapplyOrder = function() {
1638-
var col = this.order[0][0];
1651+
const columnIndex = this.order[0][0];
1652+
const column = this.gui.datatable.settings().init().columns[columnIndex].name;
16391653
var desc = 'desc' === this.order[0][1];
16401654

16411655
// Use only first level sort
1642-
if (2 === col) { // Name
1656+
if ('name' === column) {
16431657
this.sortByName(desc);
1644-
} else if (3 === col) { // Review
1658+
} else if ('review' === column) {
16451659
this.sortByReview(desc);
1646-
} else if (4 === col) { // Selected
1660+
} else if ('selected' === column) {
16471661
this.sortBySelected(desc);
1648-
} else if (10 === col) { // Color
1662+
} else if ('color' === column) {
16491663
this.sortByColor(desc);
16501664
}
16511665
};

0 commit comments

Comments
 (0)