Browse Source

fix: use pluralised name of ref table as column name

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
1e79467ac5
  1. 1
      packages/nc-gui/components/dlg/AirtableImport.vue
  2. 2
      packages/nocodb/src/helpers/columnHelpers.ts
  3. 6
      packages/nocodb/src/helpers/populateMeta.ts
  4. 4
      packages/nocodb/src/services/columns.service.ts
  5. 8
      packages/nocodb/src/services/meta-diffs.service.ts

1
packages/nc-gui/components/dlg/AirtableImport.vue

@ -1,3 +1,4 @@
<script setup lang="ts">
import type { Card as AntCard } from 'ant-design-vue'
import {

2
packages/nocodb/src/helpers/columnHelpers.ts

@ -65,7 +65,7 @@ export async function createHmAndBtColumn(
{
const title = getUniqueColumnAliasName(
await parent.getColumns(),
(type === 'hm' && alias) || `${child.title}`,
(type === 'hm' && alias) || pluralize(child.title),
);
const meta = {
plural: columnMeta?.plural || pluralize(child.title),

6
packages/nocodb/src/helpers/populateMeta.ts

@ -114,7 +114,7 @@ export async function extractAndGenerateManyToManyRelations(
await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName(
modelA.columns,
`${modelB.title} List`,
pluralize(modelB.title),
),
fk_model_id: modelA.id,
fk_related_model_id: modelB.id,
@ -136,7 +136,7 @@ export async function extractAndGenerateManyToManyRelations(
await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName(
modelB.columns,
`${modelA.title} List`,
pluralize(modelA.title),
),
fk_model_id: modelB.id,
fk_related_model_id: modelA.id,
@ -268,7 +268,7 @@ export async function populateMeta(base: Base, project: Project): Promise<any> {
uidt: UITypes.Links,
type: 'hm',
hm,
title: `${hm.title} List`,
title: pluralize(hm.title),
meta: {
plural: pluralize(hm.title),
singular: singularize(hm.title),

4
packages/nocodb/src/services/columns.service.ts

@ -1780,7 +1780,7 @@ export class ColumnsService {
await Column.insert({
title: getUniqueColumnAliasName(
await child.getColumns(),
`${parent.title} List`,
pluralize(parent.title),
),
uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord,
type: 'mm',
@ -1807,7 +1807,7 @@ export class ColumnsService {
await Column.insert({
title: getUniqueColumnAliasName(
await parent.getColumns(),
param.column.title ?? `${child.title} List`,
param.column.title ?? pluralize(child.title),
),
uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord,

8
packages/nocodb/src/services/meta-diffs.service.ts

@ -746,7 +746,7 @@ export class MetaDiffsService {
} else if (change.relationType === RelationTypes.HAS_MANY) {
const title = getUniqueColumnAliasName(
childModel.columns,
`${childModel.title || childModel.table_name} List`,
pluralize(childModel.title || childModel.table_name),
);
await Column.insert<LinkToAnotherRecordColumn>({
uidt: UITypes.Links,
@ -945,7 +945,7 @@ export class MetaDiffsService {
} else if (change.relationType === RelationTypes.HAS_MANY) {
const title = getUniqueColumnAliasName(
childModel.columns,
`${childModel.title || childModel.table_name} List`,
pluralize(childModel.title || childModel.table_name),
);
await Column.insert<LinkToAnotherRecordColumn>({
uidt: UITypes.Links,
@ -1046,7 +1046,7 @@ export class MetaDiffsService {
await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName(
modelA.columns,
`${modelB.title} List`,
pluralize(modelB.title),
),
fk_model_id: modelA.id,
fk_related_model_id: modelB.id,
@ -1070,7 +1070,7 @@ export class MetaDiffsService {
await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName(
modelB.columns,
`${modelA.title} List`,
pluralize(modelA.title),
),
fk_model_id: modelB.id,
fk_related_model_id: modelA.id,

Loading…
Cancel
Save