From de36aa57dc6ebdd58eb71eac439b343a36517598 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Tue, 10 Jan 2023 20:22:57 +0100 Subject: [PATCH] Find: polish --- frontend/src/components/icon.svelte | 2 ++ frontend/src/components/objectgrid.svelte | 13 +++++--- .../organisms/collection-detail/find.svelte | 33 +++++++++++++++++-- frontend/src/style.css | 6 ++++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/icon.svelte b/frontend/src/components/icon.svelte index 88837a5..4f97436 100644 --- a/frontend/src/components/icon.svelte +++ b/frontend/src/components/icon.svelte @@ -14,4 +14,6 @@ {:else if name === 'x'} +{:else if name === '-'} + {/if} diff --git a/frontend/src/components/objectgrid.svelte b/frontend/src/components/objectgrid.svelte index 02036e7..867376a 100644 --- a/frontend/src/components/objectgrid.svelte +++ b/frontend/src/components/objectgrid.svelte @@ -5,6 +5,13 @@ export let key = '_id'; export let showHeaders = false; export let contained = true; + export let activeKey = ''; + + const columns = [ + { key: 'key', label: 'Key' }, + { key: 'value', label: 'Value' }, + { key: 'type', label: 'Type' }, + ]; let items = []; @@ -61,8 +68,4 @@ } - + diff --git a/frontend/src/organisms/collection-detail/find.svelte b/frontend/src/organisms/collection-detail/find.svelte index 663900c..4189902 100644 --- a/frontend/src/organisms/collection-detail/find.svelte +++ b/frontend/src/organisms/collection-detail/find.svelte @@ -26,6 +26,7 @@ let result = []; let queryField; + let activeKey = ''; $: code = `db.${collection.key}.find(${form.query || '{}'}${form.fields && form.fields !== '{}' ? `, ${form.fields}` : ''}).sort(${form.sort})${form.skip ? `.skip(${form.skip})` : ''}${form.limit ? `.limit(${form.limit})` : ''};`; $: if (collection) { @@ -33,11 +34,30 @@ } async function submitQuery() { + activeKey = ''; result = await PerformFind(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(form)); queryField?.focus(); queryField?.select(); } + function prev() { + form.skip -= form.limit; + if (form.skip < 0) { + form.skip = 0; + } + submitQuery(); + } + + function next() { + form.skip += form.limit; + submitQuery(); + } + + function remove() { + // eslint-disable-next-line no-alert + alert('yet to be implemented'); + } + onMount(() => { queryField?.focus(); queryField?.select(); @@ -80,7 +100,7 @@
- +
{#if result} @@ -88,8 +108,15 @@ {/if}
- - + + +
diff --git a/frontend/src/style.css b/frontend/src/style.css index fcd6d13..1204c45 100644 --- a/frontend/src/style.css +++ b/frontend/src/style.css @@ -77,6 +77,12 @@ p { box-shadow: 0 0 0 3px rgba(0, 0, 139, 0.2); outline: none; } +.btn.danger { + background-color: #c00; +} +.btn.danger:focus { + box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.2); +} .btn:disabled { opacity: 0.5; cursor: not-allowed;