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

+5 -3
View File
@@ -107,14 +107,16 @@ export const component: ClosureComponent = (): Component => {
}
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("/faults", ops);
}