From 0e13bff89959c7f6aa971c25f7e0743219f92a1b Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 20 Mar 2024 17:50:52 +0530 Subject: [PATCH] Nc feat/one to one (#7915) * feat: one-to-one relation - wip * feat: one-to-one relation * feat: one-to-one relation - link, unlink, list, excluded list, single query * fix: pass proper fk value * feat: add non-single-query support * feat: filter, sort and delete * fix: ui - keep only one as linked record in ui - similar to bt * fix: initial column name correction * fix: field modal related fixes * fix: nested insert related bugs * fix: nested insert corrections * fix: formula support * fix: delete cell data * fix: invalid offset issue * fix: form submit issue * fix: return first element - oo relation * fix: Lookup column rendering * fix: add link api correction * fix: sort and group by menu correction * chore: lint * refactor: spacing between radio buttons * fix: undo/redo support with delete key * fix: formula related issues * fix: duplicate related issues * fix: ui label and icon color * chore: lint * chore: reset page if offset is beyond offset(temporary solution) * refactor: suggested review changes * refactor: suggested review changes * chore: lint * fix: missing await Signed-off-by: Pranav C * refactor: add comments Signed-off-by: Pranav C --------- Signed-off-by: Pranav C --- packages/nc-gui/assets/nc-icons/onetoone.svg | 6 +- .../components/smartsheet/VirtualCell.vue | 2 + .../column/LinkedToAnotherRecordOptions.vue | 13 +- .../smartsheet/column/RollupOptions.vue | 4 +- .../components/smartsheet/grid/Table.vue | 9 +- .../smartsheet/header/VirtualCell.vue | 6 +- .../smartsheet/header/VirtualCellIcon.ts | 2 + .../smartsheet/toolbar/CreateGroupBy.vue | 7 +- .../smartsheet/toolbar/CreateSort.vue | 7 +- .../smartsheet/toolbar/SortListMenu.vue | 5 +- .../components/virtual-cell/BelongsTo.vue | 18 +- .../nc-gui/components/virtual-cell/Lookup.vue | 12 +- .../components/virtual-cell/OneToOne.vue | 150 ++++++ packages/nc-gui/composables/useLTARStore.ts | 27 +- .../useMultiSelect/convertCellData.ts | 4 +- .../composables/useMultiSelect/index.ts | 7 +- .../composables/useSmartsheetRowStore.ts | 11 +- packages/nc-gui/lang/en.json | 1 + packages/nc-gui/utils/iconUtils.ts | 2 + packages/nc-gui/utils/virtualCell.ts | 3 + packages/nocodb-sdk/src/lib/globals.ts | 1 + .../data-alias-nested.controller.ts | 20 + packages/nocodb/src/db/BaseModelSqlv2.ts | 428 +++++++++++++++++- packages/nocodb/src/db/conditionV2.ts | 31 +- .../src/db/formulav2/formulaQueryBuilderv2.ts | 95 ++-- packages/nocodb/src/db/genRollupSelectv2.ts | 21 + .../src/db/generateLookupSelectQuery.ts | 35 +- .../db/sql-client/lib/mysql/MysqlClient.ts | 1 + .../src/db/sql-client/lib/pg/PgClient.ts | 2 + .../db/sql-client/lib/sqlite/SqliteClient.ts | 5 + packages/nocodb/src/helpers/columnHelpers.ts | 108 ++++- packages/nocodb/src/helpers/getAst.ts | 12 +- .../src/models/LinkToAnotherRecordColumn.ts | 2 +- .../jobs/export-import/duplicate.processor.ts | 16 +- .../jobs/jobs/export-import/export.service.ts | 5 +- .../jobs/jobs/export-import/import.service.ts | 29 +- packages/nocodb/src/schema/swagger-v2.json | 6 +- packages/nocodb/src/schema/swagger.json | 15 +- .../api-docs/swaggerV2/templates/paths.ts | 5 + .../nocodb/src/services/columns.service.ts | 268 ++++++++++- .../src/services/data-alias-nested.service.ts | 41 ++ packages/nocodb/src/utils/acl.ts | 2 + 42 files changed, 1306 insertions(+), 138 deletions(-) create mode 100644 packages/nc-gui/components/virtual-cell/OneToOne.vue diff --git a/packages/nc-gui/assets/nc-icons/onetoone.svg b/packages/nc-gui/assets/nc-icons/onetoone.svg index e95ce0646f..9e9e41e5ba 100644 --- a/packages/nc-gui/assets/nc-icons/onetoone.svg +++ b/packages/nc-gui/assets/nc-icons/onetoone.svg @@ -1,5 +1,5 @@ - - - + + + diff --git a/packages/nc-gui/components/smartsheet/VirtualCell.vue b/packages/nc-gui/components/smartsheet/VirtualCell.vue index 6a34c88dbb..68d8a0b361 100644 --- a/packages/nc-gui/components/smartsheet/VirtualCell.vue +++ b/packages/nc-gui/components/smartsheet/VirtualCell.vue @@ -20,6 +20,7 @@ import { isLink, isLookup, isMm, + isOo, isPrimary, isQrCode, isRollup, @@ -111,6 +112,7 @@ onUnmounted(() => { + diff --git a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue index cf18a7d5f7..a99d40b31f 100644 --- a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue @@ -1,5 +1,5 @@