From 9841aab689d8a898be9c8eb7e8948137066d76e4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 12 Oct 2020 14:31:17 +0100 Subject: [PATCH] Fixes the link doc ID so that they do not start with automation ID and fixes an error that was occurring when creating tables. --- packages/builder/src/builderStore/storeUtils.js | 3 ++- .../ModelNavigator/modals/CreateTableModal.svelte | 1 - packages/server/src/db/utils.js | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/builderStore/storeUtils.js b/packages/builder/src/builderStore/storeUtils.js index aeff3f2528..9111f06bd5 100644 --- a/packages/builder/src/builderStore/storeUtils.js +++ b/packages/builder/src/builderStore/storeUtils.js @@ -36,7 +36,8 @@ export const saveCurrentPreviewItem = s => : saveScreenApi(s.currentPreviewItem, s) export const savePage = async s => { - const page = s.pages[s.currentPageName] + const pageName = s.currentPageName || "main" + const page = s.pages[pageName] await api.post(`/_builder/api/${s.appId}/pages/${s.currentPageName}`, { page: { componentLibraries: s.pages.componentLibraries, ...page }, uiFunctions: s.currentPageFunctions, diff --git a/packages/builder/src/components/backend/ModelNavigator/modals/CreateTableModal.svelte b/packages/builder/src/components/backend/ModelNavigator/modals/CreateTableModal.svelte index c4b62d6cec..ed369f45d3 100644 --- a/packages/builder/src/components/backend/ModelNavigator/modals/CreateTableModal.svelte +++ b/packages/builder/src/components/backend/ModelNavigator/modals/CreateTableModal.svelte @@ -41,7 +41,6 @@ .map(template => template.create()) for (let screen of screens) { - console.log(JSON.stringify(screen)) try { await store.createScreen(screen) } catch (_) { diff --git a/packages/server/src/db/utils.js b/packages/server/src/db/utils.js index f63d1fa4cb..a167966a4e 100644 --- a/packages/server/src/db/utils.js +++ b/packages/server/src/db/utils.js @@ -124,7 +124,14 @@ exports.generateAutomationID = () => { * @returns {string} The new link doc ID which the automation doc can be stored under. */ exports.generateLinkID = (modelId1, modelId2, recordId1, recordId2) => { - return `${DocumentTypes.AUTOMATION}${SEPARATOR}${modelId1}${SEPARATOR}${modelId2}${SEPARATOR}${recordId1}${SEPARATOR}${recordId2}` + return `${DocumentTypes.LINK}${SEPARATOR}${modelId1}${SEPARATOR}${modelId2}${SEPARATOR}${recordId1}${SEPARATOR}${recordId2}` +} + +/** + * Gets parameters for retrieving link docs, this is a utility function for the getDocParams function. + */ +exports.getLinkParams = (otherProps = {}) => { + return getDocParams(DocumentTypes.LINK, null, otherProps) } /**