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:
Zaid Abdulla committed 2021-10-25 13:36:23 -07:00
1 parent 88a84788a5
commit dd722ba6e0
9 files changed
+40 -27

No files matched your search

+4 -3
View File
@@ -268,17 +268,18 @@ export const component: ClosureComponent = (): Component => {
}
function onSortChange(sortedAttrs): void {
const _sort = Object.assign({}, sort);
let _sort = Object.assign({}, sort);
for (const [index, direction] of Object.entries(sortedAttrs)) {
const param = memoizedGetSortable(attributes[index].parameter);
if (param) {
// Changing the priority of columns
delete _sort[param];
_sort[param] = direction;
if (direction) _sort = Object.assign({ [param]: 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("/devices", ops);
}