diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 3322e38e5c..71fa50acaa 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -58,7 +58,7 @@ export const getBackendUiStore = () => { state.tabs.SETUP_PANEL = "SETUP" return state }), - save: async ({ instanceId, model }) => { + save: async ({ model }) => { const updatedModel = cloneDeep(model) // TODO: refactor @@ -70,7 +70,7 @@ export const getBackendUiStore = () => { } } - const SAVE_MODEL_URL = `/api/${instanceId}/models` + const SAVE_MODEL_URL = `/api/models` const response = await api.post(SAVE_MODEL_URL, updatedModel) const savedModel = await response.json() @@ -86,6 +86,8 @@ export const getBackendUiStore = () => { state.models = state.models } + // TODO: fetch models + store.actions.models.select(savedModel) return state }) diff --git a/packages/builder/src/components/common/LinkedRecordSelector.svelte b/packages/builder/src/components/common/LinkedRecordSelector.svelte index 22fa383ec6..8bb64ca2e8 100644 --- a/packages/builder/src/components/common/LinkedRecordSelector.svelte +++ b/packages/builder/src/components/common/LinkedRecordSelector.svelte @@ -9,8 +9,13 @@ let records = [] + let linkedRecords = new Set(linked) + + $: linked = [...linkedRecords] + $: FIELDS_TO_HIDE = ["modelId", "type", "_id", "_rev", $backendUiStore.selectedModel.name] + async function fetchRecords() { - const FETCH_RECORDS_URL = `/api/${$backendUiStore.selectedDatabase._id}/${modelId}/records` + const FETCH_RECORDS_URL = `/api/${modelId}/records` const response = await api.get(FETCH_RECORDS_URL) records = await response.json() } @@ -19,17 +24,25 @@ fetchRecords() }) - function linkRecord(record) { - linked.push(record._id) + function linkRecord(id) { + if (linkedRecords.has(id)) { + linkedRecords.delete(id); + } else { + linkedRecords.add(id) + } + + linkedRecords = linkedRecords }
-

{linkName}

+
+

{linkName}

+
{#each records as record} -
linkRecord(record)}> -
- {#each Object.keys(record).slice(0, 2) as key} +
linkRecord(record._id)}> +
+ {#each Object.keys(record).filter(key => !FIELDS_TO_HIDE.includes(key)) as key}
{key}

{record[key]}

@@ -41,8 +54,15 @@
\ No newline at end of file diff --git a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte index 5f7275e0e5..40b12d527e 100644 --- a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte +++ b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte @@ -40,7 +40,7 @@ return } - const DELETE_MODEL_URL = `/api/${instanceId}/models/${model._id}/${model._rev}` + const DELETE_MODEL_URL = `/api/models/${model._id}/${model._rev}` const response = await api.delete(DELETE_MODEL_URL) backendUiStore.update(state => { state.selectedView = null diff --git a/packages/builder/src/components/nav/SchemaManagementDrawer.svelte b/packages/builder/src/components/nav/SchemaManagementDrawer.svelte deleted file mode 100644 index 9465c85140..0000000000 --- a/packages/builder/src/components/nav/SchemaManagementDrawer.svelte +++ /dev/null @@ -1,143 +0,0 @@ - - -
-
-
- -
- -
- {#each $backendUiStore.models as model} - - {/each} -
-
- -
-
- -
- -
- {#each $backendUiStore.views as view} - - {/each} -
-
-
- - diff --git a/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte b/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte index 0bd68404f6..4e61b65902 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte @@ -85,42 +85,10 @@ dimensions = {top, left} } - }) - function openColorpicker(event) { - if (colorPreview) { - const { - top: spaceAbove, - width, - bottom, - right, - left: spaceLeft, - } = colorPreview.getBoundingClientRect() - const { innerHeight, innerWidth } = window - - const { offsetLeft, offsetTop } = colorPreview - //get the scrollTop value for all scrollable parent elements - let scrollTop = parentNodes.reduce( - (scrollAcc, el) => (scrollAcc += el.scrollTop), - 0 - ) - - const spaceBelow = innerHeight - spaceAbove - previewHeight - const top = - spaceAbove > spaceBelow - ? offsetTop - pickerHeight - scrollTop - : offsetTop + previewHeight - scrollTop - - //TOO: Testing and Scroll Awareness for x Scroll - const spaceRight = innerWidth - spaceLeft + previewWidth - const left = - spaceRight > spaceLeft - ? offsetLeft + previewWidth + pickerWidth - : offsetLeft - pickerWidth - - dimensions = { top, left } - - open = true + function onColorChange(color) { + value = color.detail; + dispatch("change", color.detail) } @@ -142,13 +110,9 @@ × {/if} - {:else} -
- × -
- {/if} +