From dc664c5ea67e44a07d767016681ec1d990f87f57 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 5 Mar 2024 16:28:19 +0100 Subject: [PATCH] feat: add enum detection --- src/lib/components/filters/content.svelte | 37 ++++++++++--------- src/lib/helpers/types.ts | 2 + .../collection-[collection]/+page.svelte | 4 +- .../collection-[collection]/table.svelte | 5 ++- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 973802398..7e31df2ae 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -13,6 +13,7 @@ import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; + import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; export let columns: Writable; @@ -83,6 +84,7 @@ contains: { toQuery: Query.contains, toTag: (attribute, input) => { + console.log(attribute, input); return { value: input, tag: `**${attribute}** contains **${Array.isArray(input) ? formatArray(input) : input}**` @@ -110,6 +112,7 @@ /* eslint @typescript-eslint/no-explicit-any: 'off' */ let value: any = null; + let search: string; $: { columnId; value = column?.array ? [] : null; @@ -141,8 +144,6 @@ } $: isDisabled = !operator; - - $: console.log($tags);
@@ -168,26 +169,26 @@ {#if column && operator && !operator?.hideInput} {#if column?.array} - {#if column.type === 'enum'} - test - - {:else} - - {/if} + bind:tags={arrayValues} + placeholder="Enter values" /> {:else}
    - {#if column.type === 'integer' || column.type === 'double'} + {#if column.format === 'enum'} + ({ label: value, value }))} + label="Value" + showLabel={false} + interactiveOutput /> + {:else if column.type === 'integer' || column.type === 'double'} {:else if column.type === 'boolean'} >( diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte index fd9f05552..7b5de902a 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte @@ -29,7 +29,9 @@ title: attribute.key, type: attribute.type as ColumnType, show: selected?.includes(attribute.key) ?? true, - array: attribute?.array + array: attribute?.array, + format: 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null, + elements: 'elements' in attribute ? attribute.elements : null })) ); diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte index b2d8bcb48..b888be29d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte @@ -92,7 +92,10 @@ title: attribute.key, type: attribute.type as ColumnType, show: selected?.includes(attribute.key) ?? true, - array: attribute?.array + array: attribute?.array, + format: + 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null, + elements: 'elements' in attribute ? attribute.elements : null })) ); }