feat: selecSearchElement

This commit is contained in:
Arman committed 2023-03-30 15:03:30 +02:00
1 parent 779fa3c4d1
commit 0a307dfa86
7 files changed
+57 -10

No files matched your search

@@ -6,6 +6,7 @@
type Option = $$Generic<{
value: string | boolean | number;
label: string;
data?: string[];
}>;
type OptionArray = Option[];
+1
View File
@@ -1 +1,2 @@
export { default as Pill } from './pill.svelte';
export { default as SelectSearchItem } from './selectSearchItem.svelte';
+28
View File
@@ -0,0 +1,28 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
export let data: string[] = [];
console.log(data);
</script>
<div class="u-flex u-cross-baseline u-gap-12">
<span
class="/*u-flex-basis-140*/ u-flex-shrink-0 u-text-start u-trim-start u-x-small u-color-text-gray">
<slot />
</span>
{#if data.length}
<span
class="u-flex u-trim-1 u-gap-4"
use:tooltip={{
content: data.map((e) => e ?? 'n/a').join(' | ')
}}>
{#each data as item, i}
{#if i}
<span class="u-text-color-gray">|</span>
{/if}
<span class="text">{item ?? 'n/a'}</span>
{/each}
</span>
{/if}
</div>
@@ -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<Models.AttributeRelationship>;
@@ -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}>
<SelectSearchItem data={o.data}>
{o.label}
</SelectSearchItem>
</InputSelectSearch>
{#if data?.relatedCollection}
<div>
@@ -1,5 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { SelectSearchItem } from '$lib/elements';
import { Button, InputSelectSearch, Label } from '$lib/elements/forms';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
@@ -153,8 +154,17 @@
placeholder={`Select ${attribute.key}`}
bind:search
bind:value
options={documentList?.documents?.map((n) => ({
value: n.$id,
label: n?.[displayNames[0]]
})) ?? []} />
options={documentList?.documents?.map((n) => {
const data = displayNames.filter((name) => name !== '$id').map((name) => n?.[name]);
return {
value: n.$id,
label: n.$id,
data
};
}) ?? []}
let:option={o}>
<SelectSearchItem data={o.data}>
{o.label}
</SelectSearchItem>
</InputSelectSearch>
{/if}
@@ -6,7 +6,7 @@
import type { Models } from '@appwrite.io/console';
export let show = false;
export let data: Models.Document[];
export let data: [];
export let selectedRelationship: Models.AttributeRelationship = null;
const projectId = $page.params.project;
const databaseId = $page.params.database;
@@ -35,7 +35,7 @@
{#if i}
<span class="clickable-list-title-sep">|</span>
{/if}
<span>{doc[arg]}</span>
<span>{doc[arg] ?? 'n/a'}</span>
{/each}
<svelte:fragment slot="desc">
{doc.$id}
@@ -28,7 +28,7 @@
const databaseId = $page.params.database;
let showRelationships = false;
let selectedRelationship: Models.AttributeRelationship = null;
let relationshipData: Models.Document;
let relationshipData: [];
onMount(() => {
teamPrefs.load($organization.$id);
@@ -129,8 +129,9 @@
{#each args as arg, i}
{#if arg !== undefined}
{i ? '|' : ''}
<span class="text"
>{document[column.id]?.[arg]}</span>
<span class="text">
{document[column.id]?.[arg] ?? 'n/a'}
</span>
{/if}
{/each}
</button>