From 6489f8480c44b5234fdaae8a89e675c00afba02c Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 24 Apr 2019 11:17:28 +0200 Subject: [PATCH] sorting in edit project dialog fixed --- frontend-js/src/main/js/GuiConnector.js | 7 ++++ .../main/js/gui/admin/CommentsAdminPanel.js | 3 +- .../main/js/gui/admin/EditProjectDialog.js | 42 +++++++++++++------ 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index 9b5189af4a..9dbb207b8d 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -106,6 +106,13 @@ GuiConnector.prototype.init = function () { }; } newUrl = ""; + + //sorting of datatable column by input value https://stackoverflow.com/a/29221907/1127920 + $.fn.dataTable.ext.order['dom-input'] = function (settings, col) { + return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) { + return $('input', td).val(); + }); + } }; diff --git a/frontend-js/src/main/js/gui/admin/CommentsAdminPanel.js b/frontend-js/src/main/js/gui/admin/CommentsAdminPanel.js index 7fe796baa2..a140ba3530 100644 --- a/frontend-js/src/main/js/gui/admin/CommentsAdminPanel.js +++ b/frontend-js/src/main/js/gui/admin/CommentsAdminPanel.js @@ -61,7 +61,8 @@ CommentsAdminPanel.prototype._createGui = function () { }, { title: 'Content' }, { - title: 'Removed' + title: 'Removed', + orderable: false }, { title: 'Pinned' }] diff --git a/frontend-js/src/main/js/gui/admin/EditProjectDialog.js b/frontend-js/src/main/js/gui/admin/EditProjectDialog.js index 1f6cc6d1ee..b21faa4fab 100644 --- a/frontend-js/src/main/js/gui/admin/EditProjectDialog.js +++ b/frontend-js/src/main/js/gui/admin/EditProjectDialog.js @@ -325,13 +325,17 @@ EditProjectDialog.prototype._createMapsTable = function () { }, { title: 'Name' }, { - title: 'Default center x' + title: 'Default center x', + orderable: false }, { - title: 'Default center y' + title: 'Default center y', + orderable: false }, { - title: 'Default zoom level' + title: 'Default zoom level', + orderable: false }, { - title: 'Update' + title: 'Update', + orderable: false }] }); @@ -397,18 +401,31 @@ EditProjectDialog.prototype._createOverlayTable = function () { }, { title: 'Description' }, { - title: 'Public' + title: 'Public', + orderable: false }, { - title: 'Default' + title: 'Default', + orderable: false }, { - title: 'Owner' + title: 'Owner', + orderable: false }, { - title: 'Data' + title: 'Data', + orderable: false }, { - title: 'Update' + title: 'Update', + orderable: false }, { - title: 'Remove' + title: 'Remove', + orderable: false }], + columnDefs: [ + { + orderDataType: "dom-input", + type: "string", + targets: [1, 2] + } + ], dom: '<"minerva-datatable-toolbar">frtip', initComplete: function () { $("div.minerva-datatable-toolbar", $(result)).html('<button name="addOverlay">Add overlay</button>'); @@ -437,7 +454,7 @@ EditProjectDialog.prototype._createOverlayTable = function () { var button = this; return self.getServerConnector().getOverlaySourceDownloadUrl({ overlayId: $(button).attr("data"), - projectId:self.getProject().getProjectId() + projectId: self.getProject().getProjectId() }).then(function (url) { return self.downloadFile(url); }).then(null, GuiConnector.alert); @@ -622,7 +639,8 @@ EditProjectDialog.prototype.initUsersTab = function () { var columns = self.createUserPrivilegeColumns(); $(usersTable).DataTable({ - columns: columns + columns: columns, + ordering: false }); return Promise.resolve(); }; -- GitLab