diff --git a/frontend/src/components/grid-items.svelte b/frontend/src/components/grid-items.svelte
index 330fb8e..1119a9c 100644
--- a/frontend/src/components/grid-items.svelte
+++ b/frontend/src/components/grid-items.svelte
@@ -6,8 +6,9 @@
export let items = [];
export let columns = [];
export let key = '';
+ export let path = [];
export let activeKey = '';
- export let activeChildKey = '';
+ export let activePath = [];
export let level = 0;
export let striped = true;
@@ -33,8 +34,13 @@
function select(itemKey) {
activeKey = itemKey;
- activeChildKey = '';
- dispatch('select', itemKey);
+ if (level === 0) {
+ activePath = [ itemKey ];
+ }
+ else {
+ activePath = [ ...path, itemKey ];
+ }
+ dispatch('select', { level, itemKey });
}
function closeAll() {
@@ -42,12 +48,6 @@
dispatch('closeAll');
}
- function selectChild(itemKey, childKey) {
- select(itemKey);
- activeChildKey = childKey;
- dispatch('selectChild', childKey);
- }
-
function toggleChildren(itemKey, shift) {
childrenOpen[itemKey] = !childrenOpen[itemKey];
if (shift) {
@@ -57,7 +57,7 @@
function doubleClick(itemKey) {
toggleChildren(itemKey, false);
- dispatch('trigger', itemKey);
+ dispatch('trigger', { level, itemKey });
}
function showContextMenu(evt, item) {
@@ -85,12 +85,12 @@
}
-{#each _items as item (item[key])}
+{#each _items as item}
select(item[key])}
on:dblclick={() => doubleClick(item[key])}
on:contextmenu|preventDefault={evt => showContextMenu(evt, item)}
- class:selected={activeKey === item[key] && !activeChildKey}
+ class:selected={!activePath[level + 1] && activePath.every(k => path.includes(k) || k === item[key]) && (activePath[level] === item[key])}
class:striped
>
@@ -120,12 +120,13 @@
{columns}
{key}
{striped}
- bind:activeKey={activeChildKey}
- showHeaders={false}
+ path={[ ...path, item[key] ]}
items={item.children}
level={level + 1}
- on:select={e => selectChild(item[key], e.detail)}
+ bind:activePath
on:closeAll={closeAll}
+ on:select
+ on:trigger
/>
{/if}
{/each}
diff --git a/frontend/src/components/grid.svelte b/frontend/src/components/grid.svelte
index 53d14df..4533a7b 100644
--- a/frontend/src/components/grid.svelte
+++ b/frontend/src/components/grid.svelte
@@ -6,9 +6,7 @@
export let items = [];
export let actions = [];
export let key = 'id';
- export let activeKey = '';
- export let activeChildKey = '';
- export let showHeaders = true;
+ export let activePath = [];
export let striped = true;
@@ -25,19 +23,8 @@
{/if}
- {#if showHeaders && columns.some(col => col.title)}
-
-
- |
- {#each columns as column}
- {column.title || ''} |
- {/each}
-
-
- {/if}
-
-
+
@@ -63,22 +50,4 @@
width: 100%;
background-color: #fff;
}
-
- table thead {
- border-bottom: 2px solid #ccc;
- }
-
- th {
- font-weight: 600;
- text-align: left;
- }
-
- tr {
- cursor: pointer;
- }
-
- th {
- padding: 0.3rem;
- text-overflow: ellipsis;
- }
diff --git a/frontend/src/components/icon.svelte b/frontend/src/components/icon.svelte
index 2308d8e..05b851e 100644
--- a/frontend/src/components/icon.svelte
+++ b/frontend/src/components/icon.svelte
@@ -24,4 +24,6 @@
{:else if name === 'edit'}
+{:else if name === 'check'}
+
{/if}
diff --git a/frontend/src/components/objectgrid.svelte b/frontend/src/components/objectgrid.svelte
index 6fec75b..eadf499 100644
--- a/frontend/src/components/objectgrid.svelte
+++ b/frontend/src/components/objectgrid.svelte
@@ -3,8 +3,7 @@
export let data = [];
export let key = '_id';
- export let showHeaders = false;
- export let activeKey = '';
+ export let activePath = [];
const columns = [
{ key: 'key', label: 'Key' },
@@ -20,10 +19,9 @@
if (Array.isArray(data)) {
for (const item of data) {
const newItem = {};
- newItem.key = key;
- newItem.value = item[key];
+ newItem.key = item[key];
newItem.type = getType(item[key]);
- newItem.children = dissectObject(item, key);
+ newItem.children = dissectObject(item);
newItem.menu = item.menu;
items = [ ...items, newItem ];
}
@@ -55,12 +53,12 @@
}
}
- function dissectObject(object, exclude) {
+ function dissectObject(object) {
const entries = [ ...Array.isArray(object) ? object.entries() : Object.entries(object) ];
- return entries.filter(([ key ]) => key != exclude).map(([ key, value ]) => {
+ return entries.map(([ key, value ]) => {
key = key + '';
const type = getType(value);
- const child = { key, value, type, menu: value.menu };
+ const child = { key, value, type, menu: value?.menu };
if (type.startsWith('object') || type.startsWith('array')) {
child.children = dissectObject(value);
@@ -74,10 +72,8 @@
diff --git a/frontend/src/organisms/connection/collection/find.svelte b/frontend/src/organisms/connection/collection/find.svelte
index db4c777..86039b5 100644
--- a/frontend/src/organisms/connection/collection/find.svelte
+++ b/frontend/src/organisms/connection/collection/find.svelte
@@ -20,12 +20,12 @@
let result = {};
let submittedForm = {};
let queryField;
- let activeKey = '';
+ let activePath = '';
let json = '';
$: 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})` : ''};`;
async function submitQuery() {
- activeKey = '';
+ activePath = [];
result = await FindItems(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(form));
if (result) {
submittedForm = JSON.parse(JSON.stringify(form));
@@ -47,8 +47,7 @@
}
function remove() {
- // eslint-disable-next-line no-alert
- alert('yet to be implemented');
+ // todo
}
function resetFocus() {
@@ -57,13 +56,15 @@
}
function openJson(itemId) {
- const item = result?.results?.filter(i => i._id == itemId);
+ const item = result?.results?.find(i => i._id == itemId);
+ if (!item) {
+ return;
+ }
json = JSON.stringify(item, undefined, 2);
}
export function performQuery(q) {
form = { ...defaults, ...q };
- console.log(form);
submitQuery();
}
@@ -107,7 +108,7 @@
{#key result}
- openJson(e.detail)} />
+ openJson(e.detail?.itemKey)} />
{/key}
@@ -118,7 +119,7 @@
{/key}
- |