Add delete button

This commit is contained in:
Mel O'Hagan 2022-08-25 17:40:09 +01:00
parent 52c8fda064
commit f2881fc714
2 changed files with 17 additions and 8 deletions

View File

@ -67,7 +67,7 @@
{/if} {/if}
{:else if schema.type === QueryTypes.FLOW} {:else if schema.type === QueryTypes.FLOW}
<br /> <br />
{#if !query.fields.steps} {#if query.fields.steps?.length == 0}
<div class="controls"> <div class="controls">
<Button <Button
secondary secondary
@ -91,7 +91,14 @@
<div class="blockSection"> <div class="blockSection">
<div class="block-options"> <div class="block-options">
Stage {index + 1} Stage {index + 1}
<ActionButton on:click={() => {}} icon="DeleteOutline" /> <ActionButton
on:click={() => {
query.fields.steps = [
...query.fields.steps.splice(index, 1),
]
}}
icon="DeleteOutline"
/>
</div> </div>
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<div class="fields"> <div class="fields">

View File

@ -52,7 +52,7 @@ module MongoDBModule {
}, },
aggregate: { aggregate: {
type: QueryType.FLOW, type: QueryType.FLOW,
} },
}, },
extra: { extra: {
collection: { collection: {
@ -327,11 +327,13 @@ module MongoDBModule {
const db = this.client.db(this.config.db) const db = this.client.db(this.config.db)
const collection = db.collection(query.extra.collection) const collection = db.collection(query.extra.collection)
let response = {} let response = {}
for await (const doc of collection.aggregate(query.steps.map(({ key, value }) => { for await (const doc of collection.aggregate(
query.steps.map(({ key, value }) => {
let temp: any = {} let temp: any = {}
temp[key] = JSON.parse(value.value) temp[key] = JSON.parse(value.value)
return temp return temp
}))) { })
)) {
response = doc response = doc
} }
return response return response