From 9ec0baec9aa7636a38b78b7805aa9c80bce7c968 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 16 Oct 2024 10:30:45 +0000 Subject: [PATCH] refactor: make only title as required --- packages/nc-gui/utils/columnUtils.ts | 2 +- .../jobs/export-import/duplicate.controller.ts | 3 ++- packages/nocodb/src/schema/swagger-v2.json | 8 ++++++-- packages/nocodb/src/schema/swagger.json | 9 +++++++-- packages/nocodb/src/services/tables.service.ts | 16 ++++------------ 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/nc-gui/utils/columnUtils.ts b/packages/nc-gui/utils/columnUtils.ts index e8f802c48e..9a4299d843 100644 --- a/packages/nc-gui/utils/columnUtils.ts +++ b/packages/nc-gui/utils/columnUtils.ts @@ -289,7 +289,7 @@ const checkboxIconList = [ }, ] -export const ratingIconList = [ +const ratingIconList = [ { full: 'mdi-star', empty: 'mdi-star-outline', diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts index 05f4cdc987..98718cdce3 100644 --- a/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts +++ b/packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts @@ -194,6 +194,7 @@ export class DuplicateController { @Param('modelId') modelId?: string, @Body() body?: { + title?: string; options?: { excludeData?: boolean; excludeViews?: boolean; @@ -226,7 +227,7 @@ export class DuplicateController { const models = await source.getModels(context); const uniqueTitle = generateUniqueName( - `${model.title} copy`, + body.title || `${model.title} copy`, models.map((p) => p.title), ); diff --git a/packages/nocodb/src/schema/swagger-v2.json b/packages/nocodb/src/schema/swagger-v2.json index 98a5b646b9..949235a7e3 100644 --- a/packages/nocodb/src/schema/swagger-v2.json +++ b/packages/nocodb/src/schema/swagger-v2.json @@ -3883,6 +3883,11 @@ "excludeHooks": { "type": "boolean", "required": false + }, + "title": { + "type": "string", + "required": false, + "description": "New table title" } } } @@ -20568,7 +20573,6 @@ } }, "required": [ - "table_name", "title" ], "x-stoplight": { @@ -20839,7 +20843,7 @@ }, "required": [ "columns", - "table_name" + "title" ], "title": "Table Request Model", "type": "object", diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index 4b68b1d215..d29b9feede 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -4489,6 +4489,11 @@ "excludeHooks": { "type": "boolean", "required": false + }, + "title": { + "type": "string", + "required": false, + "description": "New table title" } } } @@ -25625,7 +25630,7 @@ } }, "required": [ - "table_name", + "title", "title" ], "x-stoplight": { @@ -25905,7 +25910,7 @@ }, "required": [ "columns", - "table_name" + "title" ], "title": "Table Request Model", "type": "object", diff --git a/packages/nocodb/src/services/tables.service.ts b/packages/nocodb/src/services/tables.service.ts index 090d9f5e89..af54c9366c 100644 --- a/packages/nocodb/src/services/tables.service.ts +++ b/packages/nocodb/src/services/tables.service.ts @@ -558,18 +558,12 @@ export class TablesService { } } - - - if ( - !tableCreatePayLoad.title - ) { - NcError.badRequest( - 'Missing table `title` property in request body', - ); + if (!tableCreatePayLoad.title) { + NcError.badRequest('Missing table `title` property in request body'); } - if(!tableCreatePayLoad.table_name) { - + if (!tableCreatePayLoad.table_name) { + tableCreatePayLoad.table_name = tableCreatePayLoad.title; } if ( @@ -623,8 +617,6 @@ export class TablesService { ); } - - const sqlMgr = await ProjectMgrv2.getSqlMgr(context, base); const sqlClient = await NcConnectionMgrv2.getSqlClient(source);