From 0a307dfa86b60fc11c11bb6335028604fac97434 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 30 Mar 2023 15:03:30 +0200 Subject: [PATCH] feat: selecSearchElement --- .../elements/forms/inputSelectSearch.svelte | 1 + src/lib/elements/index.ts | 1 + src/lib/elements/selectSearchItem.svelte | 28 +++++++++++++++++++ .../attributes/relationship.svelte | 8 +++++- .../attributes/relationship.svelte | 18 +++++++++--- .../relationshipsModal.svelte | 4 +-- .../collection-[collection]/table.svelte | 7 +++-- 7 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 src/lib/elements/selectSearchItem.svelte diff --git a/src/lib/elements/forms/inputSelectSearch.svelte b/src/lib/elements/forms/inputSelectSearch.svelte index ecb69de83..7c965fce0 100644 --- a/src/lib/elements/forms/inputSelectSearch.svelte +++ b/src/lib/elements/forms/inputSelectSearch.svelte @@ -6,6 +6,7 @@ type Option = $$Generic<{ value: string | boolean | number; label: string; + data?: string[]; }>; type OptionArray = Option[]; diff --git a/src/lib/elements/index.ts b/src/lib/elements/index.ts index 2ebcd3892..ffd1477bb 100644 --- a/src/lib/elements/index.ts +++ b/src/lib/elements/index.ts @@ -1 +1,2 @@ export { default as Pill } from './pill.svelte'; +export { default as SelectSearchItem } from './selectSearchItem.svelte'; diff --git a/src/lib/elements/selectSearchItem.svelte b/src/lib/elements/selectSearchItem.svelte new file mode 100644 index 000000000..cb1ad1952 --- /dev/null +++ b/src/lib/elements/selectSearchItem.svelte @@ -0,0 +1,28 @@ + + +
+ + + + {#if data.length} + e ?? 'n/a').join(' | ') + }}> + {#each data as item, i} + {#if i} + | + {/if} + {item ?? 'n/a'} + {/each} + + {/if} +
diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte index b323d76c1..96f5ecf40 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte @@ -44,6 +44,7 @@ import arrowOne from './arrow-one.svg'; import arrowTwo from './arrow-two.svg'; import { camelize } from '$lib/helpers/string'; + import { SelectSearchItem } from '$lib/elements'; // Props export let data: Partial; @@ -141,7 +142,12 @@ required placeholder="Select a collection" disabled={editing} - options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} /> + options={collections?.map((n) => ({ value: n.$id, label: n.$id, data: [n.name] })) ?? []} + let:option={o}> + + {o.label} + + {#if data?.relatedCollection}
diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte index 6f5cb72b7..29f297ebb 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte @@ -1,5 +1,6 @@