From 2cf5eb5219bc013e810b1c326aa2f02357394878 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:30:12 +0800 Subject: [PATCH 1/8] docs: rename to display-value --- .../{primary-value.md => display-value.md} | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) rename packages/noco-docs/content/en/setup-and-usages/{primary-value.md => display-value.md} (51%) diff --git a/packages/noco-docs/content/en/setup-and-usages/primary-value.md b/packages/noco-docs/content/en/setup-and-usages/display-value.md similarity index 51% rename from packages/noco-docs/content/en/setup-and-usages/primary-value.md rename to packages/noco-docs/content/en/setup-and-usages/display-value.md index bd297bf2b4..9ea19a61ce 100644 --- a/packages/noco-docs/content/en/setup-and-usages/primary-value.md +++ b/packages/noco-docs/content/en/setup-and-usages/display-value.md @@ -1,40 +1,41 @@ --- -title: "Primary Value" -description: "Understanding Primary Value in NocoDB!" +title: "Display Value" +description: "Understanding Display Value in NocoDB!" position: 580 category: "Product" -menuTitle: "Primary Value" +menuTitle: "Display Value" --- -## What is a Primary Value ? -- Primary value as the name stands is the primary or main value within a row of a table that you generally associate that row with. +## What is a Display Value ? + +- Display Value as the name stands is the primary or main value within a row of a table that you generally associate that row with. - It should be usually associated with a column which is uniquely identifiable. However, this uniqueness is not enforced at the database level. -## What is the use of Primary Value ? -- Within a spreadsheet, primary value are always highlighted so that it is easier to recognise what row we are in. -- And when LinkToAnotherRecord is created between two tables - it is the primary value that appears in LinkToAnotheRecord column. +## What is the use of Display Value ? +- Within a spreadsheet, Display Value are always highlighted so that it is easier to recognise what row we are in. +- And when LinkToAnotherRecord is created between two tables - it is the Display Value that appears in LinkToAnotheRecord column. -#### Example : Primary Value highlighted in Actor table +#### Example : Display Value highlighted in Actor table image -#### Example : Primary Value highlighted in Film table +#### Example : Display Value highlighted in Film table image -#### Example : Primary Value associated when LinkToAnotherRecord is created +#### Example : Display Value associated when LinkToAnotherRecord is created image -## How to set Primary Value ? +## How to set Display Value ? -Click down arrow in the target column. Click `Set as Primary Value`. +Click down arrow in the target column. Click `Set as Display Value`. -image +![image](https://user-images.githubusercontent.com/35857179/219339727-dee5fdea-6db7-4a06-9e48-df7113cc63b1.png) -## How is Primary Value identfied for existing database tables ? +## How is Display Value identfied for existing database tables ? - It is usually the first column after the primary key which is not a number. - If there is no column which is not a number then the column adjacent to primary key is chosen. -## Can I change the Primary Value to another column within tables ? +## Can I change the Display Value to another column within tables ? -- Yes, you can use the same way mentioned above to set Primary Value. +- Yes, you can use the same way mentioned above to set Display Value. From 7b22e941d62d115870af3243b4996d3b1f29658a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:30:33 +0800 Subject: [PATCH 2/8] chore(nc-gui): primary value -> display value --- packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue | 2 +- packages/nc-gui/components/template/Editor.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue index 8567956e6f..13df77d451 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue @@ -228,7 +228,7 @@ useMenuCloseOnEsc(open) > diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index 7a077e045e..6d1092bb5e 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -516,7 +516,7 @@ async function importTemplate() { tab.title = createdTable.title as string } - // set primary value + // set display value if (createdTable?.columns?.[0]?.id) { await $api.dbTableColumn.primaryColumnSet(createdTable.columns[0].id as string) } From 39503a6178379ebc821f939ae0aaf5c9678c2cc3 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:30:52 +0800 Subject: [PATCH 3/8] docs: update link and rename primary value to display value --- .../noco-docs/content/en/setup-and-usages/table-operations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/noco-docs/content/en/setup-and-usages/table-operations.md b/packages/noco-docs/content/en/setup-and-usages/table-operations.md index 533e31180d..2aeeae8c43 100644 --- a/packages/noco-docs/content/en/setup-and-usages/table-operations.md +++ b/packages/noco-docs/content/en/setup-and-usages/table-operations.md @@ -159,7 +159,7 @@ You can use Quick Import when you have data from external sources such as Airtab - **Use First Row as Headers**: If it is checked, the first row will be treated as header row. - **Import Data**: If it is checked, all data will be imported. Otherwise, only table will be created. ![image](https://user-images.githubusercontent.com/35857179/197454479-1ed18dce-1d0b-4ee3-88b3-9b6a132dea2a.png) -- You can revise the table name by double clicking it, column name and column type. By default, the first column will be chosen as Primary Value and cannot be deleted. +- You can revise the table name by double clicking it, column name and column type. By default, the first column will be chosen as Display Value and cannot be deleted. ![image](https://user-images.githubusercontent.com/35857179/197454633-5b30323e-2b13-4c55-843a-948c093d373e.png) - Click `Import` to start importing process. The table will be created and the data will be imported. ![image](https://user-images.githubusercontent.com/35857179/197455547-2d93df5e-a7f0-4c88-af53-990067625967.png) @@ -172,7 +172,7 @@ You can use Quick Import when you have data from external sources such as Airtab - **Use First Row as Headers**: If it is checked, the first row will be treated as header row. - **Import Data**: If it is checked, all data will be imported. Otherwise, only table will be created. ![image](https://user-images.githubusercontent.com/35857179/197455788-8dd8a7d1-38f3-48c3-a05e-6ab0cf25045c.png) -- You can revise the table name, column name and column type. By default, the first column will be chosen as Primary Value and cannot be deleted. +- You can revise the table name, column name and column type. By default, the first column will be chosen as Display Value and cannot be deleted. Note: If your Excel file contains multiple sheets, each sheet will be stored in a separate table. From 746359401915477f5bf9a20bf0938a303095f3ff Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:31:04 +0800 Subject: [PATCH 4/8] chore(nocodb): primary value -> display value --- packages/nocodb/src/lib/meta/api/sync/helpers/job.ts | 8 ++++---- packages/nocodb/src/lib/models/View.ts | 6 +++--- packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts | 2 +- .../src/lib/version-upgrader/ncStickyColumnUpgrader.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts index e5dbe142b5..7af6200039 100644 --- a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts +++ b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts @@ -1292,7 +1292,7 @@ export default async ( async function nocoSetPrimary(aTblSchema) { for (let idx = 0; idx < aTblSchema.length; idx++) { logDetailed( - `[${idx + 1}/${aTblSchema.length}] Configuring Primary value : ${ + `[${idx + 1}/${aTblSchema.length}] Configuring Display value : ${ aTblSchema[idx].name }` ); @@ -2225,10 +2225,10 @@ export default async ( logDetailed('Migrating Lookup form Rollup columns completed'); } } - logDetailed('Configuring Primary value column'); - // configure primary values + logDetailed('Configuring Display Value column'); + // configure Display Value await nocoSetPrimary(aTblSchema); - logDetailed('Configuring primary value column completed'); + logDetailed('Configuring Display Value column completed'); logBasic('Configuring User(s)'); // add users diff --git a/packages/nocodb/src/lib/models/View.ts b/packages/nocodb/src/lib/models/View.ts index 875be37e27..64a2df528c 100644 --- a/packages/nocodb/src/lib/models/View.ts +++ b/packages/nocodb/src/lib/models/View.ts @@ -375,10 +375,10 @@ export default class View implements ViewType { let kanbanShowLimit = 0; if (view.type === ViewTypes.KANBAN && !copyFromView) { - // sort by primary value & attachment first, then by singleLineText & Number + // sort by display value & attachment first, then by singleLineText & Number // so that later we can handle control `show` easily columns.sort((a, b) => { - const primaryValueOrder = b.pv - a.pv; + const displayValueOrder = b.pv - a.pv; const attachmentOrder = +(b.uidt === UITypes.Attachment) - +(a.uidt === UITypes.Attachment); const singleLineTextOrder = @@ -388,7 +388,7 @@ export default class View implements ViewType { +(b.uidt === UITypes.Number) - +(a.uidt === UITypes.Number); const defaultOrder = b.order - a.order; return ( - primaryValueOrder || + displayValueOrder || attachmentOrder || singleLineTextOrder || numberOrder || diff --git a/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts b/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts index 5af521950e..da70378737 100644 --- a/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts +++ b/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts @@ -2511,7 +2511,7 @@ export default abstract class BaseApiBuilder ctx, filename: '', }).getVitualColumns(); - // set default primary values + // set default display values ModelXcMetaFactory.create( this.connectionConfig, {} diff --git a/packages/nocodb/src/lib/version-upgrader/ncStickyColumnUpgrader.ts b/packages/nocodb/src/lib/version-upgrader/ncStickyColumnUpgrader.ts index 60ebe6647e..67b02ce842 100644 --- a/packages/nocodb/src/lib/version-upgrader/ncStickyColumnUpgrader.ts +++ b/packages/nocodb/src/lib/version-upgrader/ncStickyColumnUpgrader.ts @@ -1,9 +1,9 @@ import { NcUpgraderCtx } from './NcUpgrader'; import { MetaTable } from '../utils/globals'; -// before 0.104.3, primary value column can be in any position in table +// before 0.104.3, display value column can be in any position in table // with this upgrade we introduced sticky primary column feature -// this upgrader will make primary value column first column in grid views +// this upgrader will make display value column first column in grid views export default async function ({ ncMeta }: NcUpgraderCtx) { const grid_columns = await ncMeta.metaList2( From 48f153e5dfedd3255a8b813d1120b88e65c1e04a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:33:43 +0800 Subject: [PATCH 5/8] docs: update display value content --- packages/noco-docs/content/en/setup-and-usages/display-value.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/noco-docs/content/en/setup-and-usages/display-value.md b/packages/noco-docs/content/en/setup-and-usages/display-value.md index 9ea19a61ce..28fd6fd5ab 100644 --- a/packages/noco-docs/content/en/setup-and-usages/display-value.md +++ b/packages/noco-docs/content/en/setup-and-usages/display-value.md @@ -10,6 +10,7 @@ menuTitle: "Display Value" - Display Value as the name stands is the primary or main value within a row of a table that you generally associate that row with. - It should be usually associated with a column which is uniquely identifiable. However, this uniqueness is not enforced at the database level. +- Before v0.105.0, Display Value was known as Primary Value. ## What is the use of Display Value ? - Within a spreadsheet, Display Value are always highlighted so that it is easier to recognise what row we are in. From 99e45839bb40ab913dc8483acef00ccd82babe53 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:36:28 +0800 Subject: [PATCH 6/8] chore(nocodb): rename primary value to display value --- .../lib/db/sql-data-mapper/lib/sql/conditionV2.ts | 12 ++++++------ .../lib/sql/formulav2/formulaQueryBuilderv2.ts | 12 ++++++------ .../lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts | 2 +- .../src/lib/db/sql-data-mapper/lib/sql/sortV2.ts | 4 ++-- .../lib/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts | 8 ++++---- .../db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts | 2 +- .../db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts | 2 +- .../db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts | 2 +- .../lib/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts | 2 +- .../sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts | 2 +- .../db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts | 2 +- packages/nocodb/src/lib/meta/api/columnApis.ts | 10 +++++----- packages/nocodb/src/lib/meta/api/dataApis/helpers.ts | 2 +- .../nocodb/src/lib/meta/api/helpers/populateMeta.ts | 4 ++-- packages/nocodb/src/lib/meta/api/metaDiffApis.ts | 10 +++++----- .../lib/meta/api/publicApis/publicDataExportApis.ts | 2 +- packages/nocodb/src/lib/meta/api/tableApis.ts | 4 ++-- ...aultPrimaryValue.ts => mapDefaultDisplayValue.ts} | 2 +- packages/nocodb/src/lib/models/Model.ts | 4 ++-- .../nocodb/src/lib/utils/common/BaseApiBuilder.ts | 2 +- 20 files changed, 45 insertions(+), 45 deletions(-) rename packages/nocodb/src/lib/meta/helpers/{mapDefaultPrimaryValue.ts => mapDefaultDisplayValue.ts} (91%) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index 54ad7faaea..60fccf230c 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -119,7 +119,7 @@ const parseConditionV2 = async ( ? negatedMapping[filter.comparison_op] : {}), fk_model_id: childModel.id, - fk_column_id: childModel?.primaryValue?.id, + fk_column_id: childModel?.displayValue?.id, }), knex, aliasCount @@ -154,7 +154,7 @@ const parseConditionV2 = async ( ? negatedMapping[filter.comparison_op] : {}), fk_model_id: parentModel.id, - fk_column_id: parentModel?.primaryValue?.id, + fk_column_id: parentModel?.displayValue?.id, }), knex, aliasCount @@ -209,7 +209,7 @@ const parseConditionV2 = async ( ? negatedMapping[filter.comparison_op] : {}), fk_model_id: parentModel.id, - fk_column_id: parentModel?.primaryValue?.id, + fk_column_id: parentModel?.displayValue?.id, }), knex, aliasCount @@ -650,7 +650,7 @@ async function nestedConditionJoin( new Filter({ ...filter, fk_model_id: childModel.id, - fk_column_id: childModel.primaryValue?.id, + fk_column_id: childModel.displayValue?.id, }), knex, aliasCount, @@ -666,7 +666,7 @@ async function nestedConditionJoin( new Filter({ ...filter, fk_model_id: parentModel.id, - fk_column_id: parentModel?.primaryValue?.id, + fk_column_id: parentModel?.displayValue?.id, }), knex, aliasCount, @@ -682,7 +682,7 @@ async function nestedConditionJoin( new Filter({ ...filter, fk_model_id: parentModel.id, - fk_column_id: parentModel.primaryValue?.id, + fk_column_id: parentModel.displayValue?.id, }), knex, aliasCount, diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts index 99652cec1c..c7c2b37197 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/formulav2/formulaQueryBuilderv2.ts @@ -269,7 +269,7 @@ async function _formulaQueryBuilder( ); cn = knex.raw('??.??', [ nestedAlias, - parentModel?.primaryValue?.column_name, + parentModel?.displayValue?.column_name, ]); } break; @@ -283,7 +283,7 @@ async function _formulaQueryBuilder( ); cn = knex.raw('??.??', [ nestedAlias, - childModel?.primaryValue?.column_name, + childModel?.displayValue?.column_name, ]); } break; @@ -311,7 +311,7 @@ async function _formulaQueryBuilder( } cn = knex.raw('??.??', [ nestedAlias, - parentModel?.primaryValue?.column_name, + parentModel?.displayValue?.column_name, ]); } @@ -424,7 +424,7 @@ async function _formulaQueryBuilder( let selectQb; if (relation.type === 'bt') { selectQb = knex(parentModel.table_name) - .select(parentModel?.primaryValue?.column_name) + .select(parentModel?.displayValue?.column_name) .where( `${parentModel.table_name}.${parentColumn.column_name}`, knex.raw(`??`, [ @@ -447,7 +447,7 @@ async function _formulaQueryBuilder( getAggregateFn(fn)({ qb, knex, - cn: childModel?.primaryValue?.column_name, + cn: childModel?.displayValue?.column_name, }) ) .wrap('(', ')'); @@ -499,7 +499,7 @@ async function _formulaQueryBuilder( getAggregateFn(fn)({ qb, knex, - cn: parentModel?.primaryValue?.column_name, + cn: parentModel?.displayValue?.column_name, }) ) .wrap('(', ')'); diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts index 9e6af05f6e..8b8c3def97 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/getAst.ts @@ -24,7 +24,7 @@ const getAst = async ({ ...(model.primaryKeys ? model.primaryKeys.reduce((o, pk) => ({ ...o, [pk.title]: 1 }), {}) : {}), - ...(model.primaryValue ? { [model.primaryValue.title]: 1 } : {}), + ...(model.displayValue ? { [model.displayValue.title]: 1 } : {}), }; } diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts index 1e2e5e27ce..9baac9bfd7 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts @@ -153,7 +153,7 @@ export default async function sortV2( `${nestedAlias}.${parentColumn.column_name}`, `${prevAlias}.${childColumn.column_name}` ) - .select(parentModel?.primaryValue?.column_name); + .select(parentModel?.displayValue?.column_name); } break; case UITypes.Formula: @@ -201,7 +201,7 @@ export default async function sortV2( await parentModel.getColumns(); const selectQb = knex(parentModel.table_name) - .select(parentModel?.primaryValue?.column_name) + .select(parentModel?.displayValue?.column_name) .where( `${parentModel.table_name}.${parentColumn.column_name}`, knex.raw(`??`, [ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts index dc13f6f8df..6548fa7e0c 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts @@ -1,5 +1,5 @@ import BaseRender from '../../BaseRender'; -import mapDefaultPrimaryValue from '../../../../../meta/helpers/mapDefaultPrimaryValue'; +import mapDefaultDisplayValue from '../../../../../meta/helpers/mapDefaultDisplayValue'; import { UITypes } from 'nocodb-sdk'; abstract class BaseModelXcMeta extends BaseRender { @@ -79,7 +79,7 @@ abstract class BaseModelXcMeta extends BaseRender { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; } @@ -127,8 +127,8 @@ abstract class BaseModelXcMeta extends BaseRender { return virtualColumns; } - public mapDefaultPrimaryValue(columnsArr: any[]): void { - mapDefaultPrimaryValue(columnsArr); + public mapDefaultDisplayValue(columnsArr: any[]): void { + mapDefaultDisplayValue(columnsArr); } } diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts index 4e861e14bf..d9180c812f 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts @@ -544,7 +544,7 @@ class ModelXcMetaMssql extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; }*/ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts index dfb493fcdf..84d478c6d2 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts @@ -163,7 +163,7 @@ class ModelXcMetaMysql extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; } */ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts index 5d7f973ebf..997d886de4 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts @@ -163,7 +163,7 @@ class ModelXcMetaOracle extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; } */ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts index 3fd6a4a0aa..edc8254221 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts @@ -953,7 +953,7 @@ class ModelXcMetaPg extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; }*/ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts index 07ef5edd72..bcfe3f7a49 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts @@ -953,7 +953,7 @@ class ModelXcMetaSnowflake extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; }*/ diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts index 99c5761b69..f3ae40b1db 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts @@ -504,7 +504,7 @@ class ModelXcMetaSqlite extends BaseModelXcMeta { columnsArr.push(columnObj); } - this.mapDefaultPrimaryValue(columnsArr); + this.mapDefaultDisplayValue(columnsArr); return columnsArr; } */ diff --git a/packages/nocodb/src/lib/meta/api/columnApis.ts b/packages/nocodb/src/lib/meta/api/columnApis.ts index 0617b01e48..97fbb68c06 100644 --- a/packages/nocodb/src/lib/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/meta/api/columnApis.ts @@ -31,7 +31,7 @@ import NcMetaIO from '../NcMetaIO'; import ncMetaAclMw from '../helpers/ncMetaAclMw'; import { NcError } from '../helpers/catchError'; import getColumnPropsFromUIDT from '../helpers/getColumnPropsFromUIDT'; -import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; +import mapDefaultDisplayValue from '../helpers/mapDefaultDisplayValue'; import NcConnectionMgrv2 from '../../utils/common/NcConnectionMgrv2'; import { metaApiMetrics } from '../helpers/apiMetrics'; import FormulaColumn from '../../models/FormulaColumn'; @@ -1592,11 +1592,11 @@ export async function columnDelete(req: Request, res: Response) { await table.getColumns(); - const primaryValueColumn = mapDefaultPrimaryValue(table.columns); - if (primaryValueColumn) { + const displayValueColumn = mapDefaultDisplayValue(table.columns); + if (displayValueColumn) { await Model.updatePrimaryColumn( - primaryValueColumn.fk_model_id, - primaryValueColumn.id + displayValueColumn.fk_model_id, + displayValueColumn.id ); } diff --git a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts index a6ec17ea5a..aec0e4216e 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts @@ -225,7 +225,7 @@ export async function serializeCellValue({ await relatedModel.getColumns(); return [...(Array.isArray(value) ? value : [value])] .map((v) => { - return v[relatedModel.primaryValue?.title]; + return v[relatedModel.displayValue?.title]; }) .join(', '); } diff --git a/packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts b/packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts index 8e5f9d2928..ff7861a529 100644 --- a/packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts +++ b/packages/nocodb/src/lib/meta/api/helpers/populateMeta.ts @@ -10,7 +10,7 @@ import getTableNameAlias, { } from '../../helpers/getTableName'; import LinkToAnotherRecordColumn from '../../../models/LinkToAnotherRecordColumn'; import getColumnUiType from '../../helpers/getColumnUiType'; -import mapDefaultPrimaryValue from '../../helpers/mapDefaultPrimaryValue'; +import mapDefaultDisplayValue from '../../helpers/mapDefaultDisplayValue'; import { extractAndGenerateManyToManyRelations } from '../metaDiffApis'; import { ModelTypes, UITypes, ViewTypes } from 'nocodb-sdk'; import { IGNORE_TABLES } from '../../../utils/common/BaseApiBuilder'; @@ -90,7 +90,7 @@ export async function populateMeta(base: Base, project: Project): Promise { ? [] : tableRelations.filter((r) => r.tn === table.tn); - mapDefaultPrimaryValue(columns); + mapDefaultDisplayValue(columns); // add vitual columns const virtualColumns = [ diff --git a/packages/nocodb/src/lib/meta/api/metaDiffApis.ts b/packages/nocodb/src/lib/meta/api/metaDiffApis.ts index e9a0fdff93..35f8118e21 100644 --- a/packages/nocodb/src/lib/meta/api/metaDiffApis.ts +++ b/packages/nocodb/src/lib/meta/api/metaDiffApis.ts @@ -14,7 +14,7 @@ import LinkToAnotherRecordColumn from '../../models/LinkToAnotherRecordColumn'; import { getUniqueColumnAliasName } from '../helpers/getUniqueName'; import NcHelp from '../../utils/NcHelp'; import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName'; -import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; +import mapDefaultDisplayValue from '../helpers/mapDefaultDisplayValue'; import getColumnUiType from '../helpers/getColumnUiType'; import { metaApiMetrics } from '../helpers/apiMetrics'; @@ -602,7 +602,7 @@ export async function metaDiffSync(req, res) { await sqlClient.columnList({ tn: table_name }) )?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); - mapDefaultPrimaryValue(columns); + mapDefaultDisplayValue(columns); const model = await Model.insert(project.id, base.id, { table_name: table_name, @@ -630,7 +630,7 @@ export async function metaDiffSync(req, res) { await sqlClient.columnList({ tn: table_name }) )?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); - mapDefaultPrimaryValue(columns); + mapDefaultDisplayValue(columns); const model = await Model.insert(project.id, base.id, { table_name: table_name, @@ -798,7 +798,7 @@ export async function baseMetaDiffSync(req, res) { await sqlClient.columnList({ tn: table_name }) )?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); - mapDefaultPrimaryValue(columns); + mapDefaultDisplayValue(columns); const model = await Model.insert(project.id, base.id, { table_name: table_name, @@ -826,7 +826,7 @@ export async function baseMetaDiffSync(req, res) { await sqlClient.columnList({ tn: table_name }) )?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); - mapDefaultPrimaryValue(columns); + mapDefaultDisplayValue(columns); const model = await Model.insert(project.id, base.id, { table_name: table_name, diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts index 6141d9ce67..ee6b053cd1 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts @@ -237,7 +237,7 @@ async function serializeCellValue({ await relatedModel.getColumns(); return [...(Array.isArray(value) ? value : [value])] .map((v) => { - return v[relatedModel.primaryValue?.title]; + return v[relatedModel.displayValue?.title]; }) .join(', '); } diff --git a/packages/nocodb/src/lib/meta/api/tableApis.ts b/packages/nocodb/src/lib/meta/api/tableApis.ts index 67019bc5cd..8eb3d6a10e 100644 --- a/packages/nocodb/src/lib/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/meta/api/tableApis.ts @@ -20,7 +20,7 @@ import ncMetaAclMw from '../helpers/ncMetaAclMw'; import { xcVisibilityMetaGet } from './modelVisibilityApis'; import View from '../../models/View'; import getColumnPropsFromUIDT from '../helpers/getColumnPropsFromUIDT'; -import mapDefaultPrimaryValue from '../helpers/mapDefaultPrimaryValue'; +import mapDefaultDisplayValue from '../helpers/mapDefaultDisplayValue'; import { NcError } from '../helpers/catchError'; import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName'; import Column from '../../models/Column'; @@ -195,7 +195,7 @@ export async function tableCreate(req: Request, res) { ip: (req as any).clientIp, }).then(() => {}); - mapDefaultPrimaryValue(req.body.columns); + mapDefaultDisplayValue(req.body.columns); Tele.emit('evt', { evt_type: 'table:created' }); diff --git a/packages/nocodb/src/lib/meta/helpers/mapDefaultPrimaryValue.ts b/packages/nocodb/src/lib/meta/helpers/mapDefaultDisplayValue.ts similarity index 91% rename from packages/nocodb/src/lib/meta/helpers/mapDefaultPrimaryValue.ts rename to packages/nocodb/src/lib/meta/helpers/mapDefaultDisplayValue.ts index 67c7f38a79..8f12d40d13 100644 --- a/packages/nocodb/src/lib/meta/helpers/mapDefaultPrimaryValue.ts +++ b/packages/nocodb/src/lib/meta/helpers/mapDefaultDisplayValue.ts @@ -1,6 +1,6 @@ import { ColumnType } from 'nocodb-sdk'; -export default function mapDefaultPrimaryValue( +export default function mapDefaultDisplayValue( columnsArr: Array ): void | T { if (!columnsArr.some((column) => column.pv)) { diff --git a/packages/nocodb/src/lib/models/Model.ts b/packages/nocodb/src/lib/models/Model.ts index 3708b2e38f..c22c115d02 100644 --- a/packages/nocodb/src/lib/models/Model.ts +++ b/packages/nocodb/src/lib/models/Model.ts @@ -84,7 +84,7 @@ export default class Model implements TableType { return this.columns?.filter((c) => c.pk); } - public get primaryValue(): Column { + public get displayValue(): Column { if (!this.columns) return null; const pCol = this.columns?.find((c) => c.pv); if (pCol) return pCol; @@ -561,7 +561,7 @@ export default class Model implements TableType { ncMeta = Noco.ncMeta ) { const model = await this.getWithInfo({ id: tableId }); - const currentPvCol = model.primaryValue; + const currentPvCol = model.displayValue; const newPvCol = model.columns.find((c) => c.id === columnId); if (!newPvCol) NcError.badRequest('Column not found'); diff --git a/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts b/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts index da70378737..210eb61a32 100644 --- a/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts +++ b/packages/nocodb/src/lib/utils/common/BaseApiBuilder.ts @@ -2515,7 +2515,7 @@ export default abstract class BaseApiBuilder ModelXcMetaFactory.create( this.connectionConfig, {} - ).mapDefaultPrimaryValue(meta.columns); + ).mapDefaultDisplayValue(meta.columns); // update meta await this.xcMeta.metaUpdate( this.projectId, From 304502d5384b9c6b7e90f0a72daf945e11aab856 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 16 Feb 2023 18:36:53 +0800 Subject: [PATCH 7/8] chore(nc-gui): rename primary value to display value --- .../smartsheet/expanded-form/Header.vue | 4 ++-- .../components/smartsheet/header/Menu.vue | 4 ++-- .../smartsheet/toolbar/FieldsMenu.vue | 10 ++++----- .../components/virtual-cell/BelongsTo.vue | 6 ++--- .../components/virtual-cell/HasMany.vue | 6 ++--- .../components/virtual-cell/ManyToMany.vue | 6 ++--- .../components/ListChildItems.vue | 4 ++-- .../virtual-cell/components/ListItems.vue | 4 ++-- .../composables/useExpandedFormStore.ts | 6 ++--- packages/nc-gui/composables/useLTARStore.ts | 22 +++++++++---------- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index c22057348a..c0852fda05 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -18,7 +18,7 @@ const route = useRoute() const { meta, isSqlView } = useSmartsheetStoreOrThrow() -const { commentsDrawer, primaryValue, primaryKey, save: _save, loadRow } = useExpandedFormStoreOrThrow() +const { commentsDrawer, displayValue, primaryKey, save: _save, loadRow } = useExpandedFormStoreOrThrow() const { isNew, syncLTARRefs, state } = useSmartsheetRowStoreOrThrow() @@ -99,7 +99,7 @@ const onConfirmDeleteRowClick = async () => { {{ meta.title }} - +
diff --git a/packages/nc-gui/components/smartsheet/header/Menu.vue b/packages/nc-gui/components/smartsheet/header/Menu.vue index 3a98197be4..bb6fb31c31 100644 --- a/packages/nc-gui/components/smartsheet/header/Menu.vue +++ b/packages/nc-gui/components/smartsheet/header/Menu.vue @@ -68,7 +68,7 @@ const deleteColumn = () => }, }) -const setAsPrimaryValue = async () => { +const setAsDisplayValue = async () => { try { await $api.dbTableColumn.primaryColumnSet(column?.value?.id as string) @@ -280,7 +280,7 @@ const hideField = async () => { - +
diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue index 13df77d451..b045826452 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue @@ -68,7 +68,7 @@ watch( const numberOfHiddenFields = computed(() => filteredFieldList.value?.filter((field) => !field.show)?.length) -const gridPrimaryValueField = computed(() => { +const gridDisplayValueField = computed(() => { if (activeView.value?.type !== ViewTypes.GRID) return null const pvCol = Object.values(metaColumnById.value)?.find((col) => col?.pv) return filteredFieldList.value?.find((field) => field.fk_column_id === pvCol?.id) @@ -194,7 +194,7 @@ useMenuCloseOnEsc(open)