Improve sorting toggle behavior
Last sorted column now takes precedence over any previously sorted columns. This makes for a more intuitive user experience.
This commit is contained in:
1 parent
88a84788a5
commit
dd722ba6e0
9 files changed
+40
-27
No files matched your search
@@ -173,14 +173,16 @@ export const component: ClosureComponent = (): Component => {
|
||||
sortAttributes[i] = sort[attributes[i].id] || 0;
|
||||
|
||||
function onSortChange(sortAttrs): void {
|
||||
const _sort = Object.assign({}, sort);
|
||||
let _sort = Object.assign({}, sort);
|
||||
for (const [index, direction] of Object.entries(sortAttrs)) {
|
||||
// Changing the priority of columns
|
||||
delete _sort[attributes[index].id];
|
||||
_sort[attributes[index].id] = direction;
|
||||
if (direction)
|
||||
_sort = Object.assign({ [attributes[index].id]: direction }, _sort);
|
||||
}
|
||||
|
||||
const ops = { sort: JSON.stringify(_sort) };
|
||||
const ops = {};
|
||||
if (Object.keys(_sort).length) ops["sort"] = JSON.stringify(_sort);
|
||||
if (vnode.attrs["filter"]) ops["filter"] = vnode.attrs["filter"];
|
||||
m.route.set("/admin/virtualParameters", ops);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user