refactor admin crud popups
All checks were successful
deploy / build-and-deploy (push) Successful in 23s

This commit is contained in:
2025-05-21 17:22:20 +02:00
parent 8b18623232
commit e47268111a
46 changed files with 889 additions and 1041 deletions

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import { setContext, type Snippet } from 'svelte';
import { type Writable, writable } from 'svelte/store';
import { getObjectEntryByKey } from '@util/objects.ts';
// types
interface Props {
@@ -21,8 +22,8 @@
function onSort(key: string, order: 'asc' | 'desc') {
data.update((old) => {
old.sort((a, b) => {
let entryA = getDataEntryByKey(key, a);
let entryB = getDataEntryByKey(key, b);
let entryA = getObjectEntryByKey(key, a);
let entryB = getObjectEntryByKey(key, b);
if (entryA === undefined || entryB === undefined) return 0;
@@ -40,16 +41,6 @@
return old;
});
}
function getDataEntryByKey(key: string, data: { [key: string]: any }): any | undefined {
let entry = data;
for (const part of key.split('.')) {
if ((entry = entry[part]) === undefined) {
return undefined;
}
}
return entry;
}
</script>
<tr {...restProps}>