Fix thKeys property

This commit is contained in:
Jorge Vergara 2022-06-12 17:47:45 -04:00
commit 1dac233219

View file

@ -144,13 +144,10 @@
}; };
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
const batchSelectedIds = writable(false); const batchSelectedIds = writable(false);
const headerItems = writable([]);
const tableRows = writable(rows); const tableRows = writable(rows);
const thKeys = derived(headerItems, () => $: thKeys = headers
headers .map(({ key }) => ({ key, id: key }))
.map(({ key }) => ({ key, id: key })) .reduce((a, c) => ({ ...a, [c.key]: c.id }), {});
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
);
const resolvePath = (object, path) => { const resolvePath = (object, path) => {
if (path in object) return object[path]; if (path in object) return object[path];
return path return path
@ -356,7 +353,7 @@
sortKey === header.key ? sortDirection : 'none'; sortKey === header.key ? sortDirection : 'none';
sortDirection = sortDirectionMap[currentSortDirection]; sortDirection = sortDirectionMap[currentSortDirection];
sortKey = sortKey =
sortDirection === 'none' ? null : $thKeys[header.key]; sortDirection === 'none' ? null : thKeys[header.key];
dispatch('click:header', { header, sortDirection }); dispatch('click:header', { header, sortDirection });
} }
}}" }}"