From 1571eaa8974835c89460cff5b99886a547c5dd3f Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Tue, 17 Jan 2023 21:03:01 +0100 Subject: [PATCH] Indexes: context menu --- frontend/src/components/objectgrid.svelte | 11 ++++++----- .../connection/collection/indexes.svelte | 16 ++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/objectgrid.svelte b/frontend/src/components/objectgrid.svelte index bb76b8a..9d8d5b5 100644 --- a/frontend/src/components/objectgrid.svelte +++ b/frontend/src/components/objectgrid.svelte @@ -19,10 +19,11 @@ if (Array.isArray(data)) { for (const item of data) { - const _item = {}; - _item.key = item[key]; - _item.children = dissectObject(item); - items = [ ...items, _item ]; + const newItem = {}; + newItem.key = item[key]; + newItem.children = dissectObject(item); + newItem.menu = item.menu; + items = [ ...items, newItem ]; } } else { @@ -57,7 +58,7 @@ return entries.map(([ key, value ]) => { key = key + ''; const type = getType(value); - const child = { key, value, type }; + const child = { key, value, type, menu: value.menu }; if (type.startsWith('object') || type.startsWith('array')) { child.children = dissectObject(value); diff --git a/frontend/src/organisms/connection/collection/indexes.svelte b/frontend/src/organisms/connection/collection/indexes.svelte index 2f43f04..b102e28 100644 --- a/frontend/src/organisms/connection/collection/indexes.svelte +++ b/frontend/src/organisms/connection/collection/indexes.svelte @@ -16,13 +16,14 @@ } } - async function dropActive() { - if (!activeKey) { + async function drop(key = activeKey) { + if (!key) { return; } - const success = await DropIndex(collection.hostKey, collection.dbKey, collection.key, activeKey); + const success = await DropIndex(collection.hostKey, collection.dbKey, collection.key, key); if (success) { await getIndexes(); + activeKey = ''; } } @@ -35,14 +36,17 @@
- - +
- openJson(e.detail)} /> + ({ + ...idx, + menu: [ { label: 'Drop this index…', fn: () => drop(idx.name) } ], + }))} bind:activeKey on:trigger={e => openJson(e.detail)} />