mirror of
https://github.com/garraflavatra/rolens.git
synced 2024-12-01 13:20:54 +00:00
Indexes: context menu
This commit is contained in:
parent
9262c92591
commit
1571eaa897
@ -19,10 +19,11 @@
|
|||||||
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
for (const item of data) {
|
for (const item of data) {
|
||||||
const _item = {};
|
const newItem = {};
|
||||||
_item.key = item[key];
|
newItem.key = item[key];
|
||||||
_item.children = dissectObject(item);
|
newItem.children = dissectObject(item);
|
||||||
items = [ ...items, _item ];
|
newItem.menu = item.menu;
|
||||||
|
items = [ ...items, newItem ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -57,7 +58,7 @@
|
|||||||
return entries.map(([ key, value ]) => {
|
return entries.map(([ key, value ]) => {
|
||||||
key = key + '';
|
key = key + '';
|
||||||
const type = getType(value);
|
const type = getType(value);
|
||||||
const child = { key, value, type };
|
const child = { key, value, type, menu: value.menu };
|
||||||
|
|
||||||
if (type.startsWith('object') || type.startsWith('array')) {
|
if (type.startsWith('object') || type.startsWith('array')) {
|
||||||
child.children = dissectObject(value);
|
child.children = dissectObject(value);
|
||||||
|
@ -16,13 +16,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dropActive() {
|
async function drop(key = activeKey) {
|
||||||
if (!activeKey) {
|
if (!key) {
|
||||||
return;
|
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) {
|
if (success) {
|
||||||
await getIndexes();
|
await getIndexes();
|
||||||
|
activeKey = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,14 +36,17 @@
|
|||||||
<div class="indexes">
|
<div class="indexes">
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="btn" on:click={getIndexes}>Get indexes</button>
|
<button class="btn" on:click={getIndexes}>Get indexes</button>
|
||||||
<button class="btn danger" on:click={dropActive} disabled={!indexes?.length || !activeKey}>
|
<button class="btn danger" on:click={drop} disabled={!indexes?.length || !activeKey}>
|
||||||
Drop selected
|
Drop selected
|
||||||
</button>
|
</button>
|
||||||
<button class="btn">Create…</button>
|
<button class="btn">Create…</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<ObjectGrid key="name" data={indexes} bind:activeKey on:trigger={e => openJson(e.detail)} />
|
<ObjectGrid key="name" data={indexes.map(idx => ({
|
||||||
|
...idx,
|
||||||
|
menu: [ { label: 'Drop this index…', fn: () => drop(idx.name) } ],
|
||||||
|
}))} bind:activeKey on:trigger={e => openJson(e.detail)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user