Commit b1851ccf authored by Piotr Gawron's avatar Piotr Gawron
Browse files

sort order of map-tables is preserved in user preferences

parent 931fe08b
......@@ -142,6 +142,7 @@ MapsAdminPanel.prototype._createProjectTableRow = function () {
}, {
title: 'Remove'
}],
order: [[ 0, "asc" ]],
columnDefs: [
{"orderable": false, "targets": [7, 8]}
]
......@@ -190,7 +191,9 @@ MapsAdminPanel.prototype._createProjectTableRow = function () {
*/
MapsAdminPanel.prototype.init = function () {
var self = this;
return self.getServerConnector().getProjects().then(function (projects) {
return AbstractAdminPanel.prototype.init.call(self).then(function() {
return self.getServerConnector().getProjects();
}).then(function (projects) {
return self.setProjects(projects);
}).then(function () {
return self.getServerConnector().getLoggedUser();
......@@ -199,6 +202,29 @@ MapsAdminPanel.prototype.init = function () {
var canAddProject = user.hasPrivilege(configuration.getPrivilegeType(PrivilegeType.IS_CURATOR)) ||
user.hasPrivilege(configuration.getPrivilegeType(PrivilegeType.IS_ADMIN));
$("[name='addProject']", self.getElement()).attr("disabled", !canAddProject);
var projectsTable = $("[name='projectsTable']", self.getElement())[0];
return self.bindUserGuiPreference({
jQueryObject: $(projectsTable),
event: 'order.dt',
preferenceName: 'admin-projects-datatable-order',
defaultValue: '0-asc',
getter: function () {
var order = $(projectsTable).DataTable().order();
return order[0][0] + "-" + order[0][1];
},
setter: function (value) {
var tmp = value.split("-");
var column = parseInt(tmp[0]);
var order = tmp[1];
if (Functions.isInt(column) && (order === "asc" || order === "desc")) {
return $(projectsTable).DataTable().order([column, order]).draw();
} else {
logger.warn("Invalid order: " + column + "; " + order);
}
}
});
});
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment