feat(ui): task log opens newest first

This commit is contained in:
sam committed 2026-10-25 17:41:21 +11:00
1 parent f2b8681611
commit 33da08bce5
4 files changed
+30 -8

No files matched your search

@@ -32,6 +32,8 @@ const props = defineProps<{
rowClass?: (row: Row) => string;
/** Keeps the header in view inside a scrolling container. */
stickyHeader?: boolean;
/** The sort the table opens with, on a column that has one. */
initialSort?: { id: string; desc: boolean };
}>();
const slots = defineSlots<Record<string, (props: { row: Row }) => unknown> & { empty?: () => unknown; actions?: (props: { row: Row }) => unknown; detail?: (props: { row: Row }) => unknown }>();
@@ -48,10 +50,14 @@ function toggle(id: string, on: boolean): void {
}
// Sorting covers the loaded rows only.
const sortBy = ref<{ id: string; desc: boolean } | null>(null);
const sortBy = ref<{ id: string; desc: boolean } | null>(props.initialSort ?? null);
// The column a table opens sorted by only flips direction: its unsorted order
// is the order it was sorted from.
function cycleSort(id: string): void {
const current = sortBy.value;
sortBy.value = current?.id !== id ? { id, desc: false } : current.desc ? null : { id, desc: true };
if (current?.id !== id) sortBy.value = { id, desc: false };
else if (!current.desc) sortBy.value = { id, desc: true };
else sortBy.value = props.initialSort?.id === id ? { id, desc: false } : null;
}
const sorted = computed(() => {
const key = sortBy.value && props.columns.find((c) => c.id === sortBy.value?.id)?.sort;