From c73c77448c91168a51d9dcd498e57f28387e23b2 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 25 Feb 2021 16:21:41 +0000 Subject: [PATCH] bugfixes --- .../DataTable/modals/CreateEditRow.svelte | 6 ++---- .../DataTable/modals/CreateEditUser.svelte | 2 +- .../common/LinkedRowSelector.svelte | 20 +++++++++---------- .../src/db/linkedRows/LinkController.js | 13 ++++++++++++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte index 790a74df53..cda1ee2e26 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte @@ -28,10 +28,8 @@ .flat() // Prevent modal closing if there were errors return false - } - - if (rowResponse.status === 500) { - notifier.danger(rowResponse.message) + } else if (rowResponse.status === 400 || rowResponse.status === 500) { + errors = [{ message: rowResponse.message }] return false } diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte index d5b242cc46..db92abc065 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte @@ -60,7 +60,7 @@ .flat() } return false - } else if (rowResponse.status === 400 && rowResponse.message) { + } else if (rowResponse.status === 400 || rowResponse.status === 500) { errors = [{ message: rowResponse.message }] return false } diff --git a/packages/builder/src/components/common/LinkedRowSelector.svelte b/packages/builder/src/components/common/LinkedRowSelector.svelte index d470aa74de..5ac1efbc54 100644 --- a/packages/builder/src/components/common/LinkedRowSelector.svelte +++ b/packages/builder/src/components/common/LinkedRowSelector.svelte @@ -43,16 +43,6 @@ {:else} {#if schema.relationshipType === 'one-to-many'} - - {#each rows as row} - - {/each} - - {:else} + {:else} + + {#each rows as row} + + {/each} + {/if} {/if} diff --git a/packages/server/src/db/linkedRows/LinkController.js b/packages/server/src/db/linkedRows/LinkController.js index b629c4b1f0..a5404709f2 100644 --- a/packages/server/src/db/linkedRows/LinkController.js +++ b/packages/server/src/db/linkedRows/LinkController.js @@ -322,9 +322,22 @@ class LinkController { tableId: table._id, fieldName: fieldName, } + if (field.autocolumn) { linkConfig.autocolumn = field.autocolumn } + + if (field.relationshipType) { + // Ensure that the other side of the relationship is locked to one record + linkConfig.relationshipType = field.relationshipType + + // Update this table to be the many + table.schema[field.name].relationshipType = + RelationshipTypes.MANY_TO_MANY + const response = await this._db.put(table) + table._rev = response.rev + } + // check the linked table to make sure we aren't overwriting an existing column const existingSchema = linkedTable.schema[field.fieldName] if (