diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index d4de55a86..6c4a00bcb 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -24,14 +24,14 @@ $: column = $columns.find((c) => c.id === columnId) as Column; - $: operatorsForColumn = Object.entries(operators) + $: operatorsForColumn = Object.entries($operators) .filter(([, v]) => v.types.includes(column?.type)) .map(([k]) => ({ label: k, value: k })); - $: operator = operatorKey ? operators[operatorKey] : null; + $: operator = operatorKey ? $operators[operatorKey] : null; $: { columnId; operatorKey = null; diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index f919a9402..1f7777aba 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -1,6 +1,6 @@ import { goto } from '$app/navigation'; -import { derived, get, writable } from 'svelte/store'; +import { derived, get, writable, type Writable } from 'svelte/store'; import { page } from '$app/stores'; import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; @@ -105,7 +105,7 @@ export function addFilter( } } -export const operators: Record = { +export const operators: Writable> = writable({ 'starts with': { toQuery: Query.startsWith, toTag: (attribute, input) => `**${attribute}** starts with **${input}**`, @@ -172,7 +172,7 @@ export const operators: Record = { }, types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] } -}; +}); function formatArray(array: string[]) { if (!array?.length) return;