From 1df1d76d7a77338eafe69f8322c4f40e065db446 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 1 Jun 2020 22:55:44 +0100 Subject: [PATCH] Record selector --- .../ParamInputs/ModelSelector.svelte | 1 + .../ParamInputs/RecordSelector.svelte | 33 +++++++++++++++++++ .../SetupPanel/WorkflowBlockSetup.svelte | 3 ++ .../BlockList/WorkflowBlock.svelte | 2 +- .../WorkflowPanel/blockDefinitions.js | 15 ++++++--- packages/client/src/state/setState.js | 2 +- packages/client/src/state/stateManager.js | 4 +-- 7 files changed, 52 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte index 1c39e19505..29babefcd9 100644 --- a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte @@ -5,6 +5,7 @@
+
+ {#each $backendUiStore.models as model} + + {/each} + +
+
+ +{#if value.model} +
+ + {#each Object.keys(value.model.schema) as field} +
+ + +
+ {/each} +
+{/if} + + diff --git a/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte b/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte index d629630099..08bf2d72db 100644 --- a/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte @@ -2,6 +2,7 @@ import { backendUiStore, store } from "builderStore" import ComponentSelector from "./ParamInputs/ComponentSelector.svelte" import ModelSelector from "./ParamInputs/ModelSelector.svelte" + import RecordSelector from "./ParamInputs/RecordSelector.svelte" export let workflowBlock @@ -51,6 +52,8 @@ bind:value={workflowBlock.args[parameter]} /> {:else if type === 'model'} + {:else if type === 'record'} + {:else if type === 'string'} {{model.name}} record", + tagline: "Save a {{record.model.name}} record", icon: "ri-save-3-fill", description: "Save a record to your database.", environment: "SERVER", params: { - model: "model", + record: "record", + }, + args: { + record: {}, }, }, DELETE_RECORD: { description: "Delete a record from your database.", icon: "ri-delete-bin-line", name: "Delete Record", - tagline: "Delete a {{model.name}} record", + tagline: "Delete a {{record.model.name}} record", environment: "SERVER", params: { - record: "string", + record: "record", + }, + args: { + record: {}, }, }, FIND_RECORD: { description: "Find a record in your database.", + tagline: "Find a {{record.model.name}} record", icon: "ri-search-line", name: "Find Record", environment: "SERVER", diff --git a/packages/client/src/state/setState.js b/packages/client/src/state/setState.js index ad25b631d5..ac17b1a681 100644 --- a/packages/client/src/state/setState.js +++ b/packages/client/src/state/setState.js @@ -8,4 +8,4 @@ export const setState = (path, value) => { state = set(path, value, state) return state }) -} \ No newline at end of file +} diff --git a/packages/client/src/state/stateManager.js b/packages/client/src/state/stateManager.js index 5d32f5a486..5dd0d9957d 100644 --- a/packages/client/src/state/stateManager.js +++ b/packages/client/src/state/stateManager.js @@ -33,7 +33,7 @@ export const createStateManager = ({ const getCurrentState = () => currentState const bb = bbFactory({ - store: appStore, + store: appStore, getCurrentState, frontendDefinition, componentLibraries, @@ -65,7 +65,7 @@ const _setup = ({ handlerTypes, getCurrentState, bb, store }) => node => { const isBound = typeof propValue === "string" && propValue.startsWith("{{") if (isBound) { - console.log("NODE IS BOUND", node); + console.log("NODE IS BOUND", node) initialProps[propName] = mustache.render(propValue, { state: currentStoreState, context,