Create record position field (#3739)
* Create record field on non syst standard objects + on custom objects * Create workspace migration * Fix naming and add seed --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -17,6 +17,7 @@ export const seedOpportunity = async (
|
||||
'closeDate',
|
||||
'probability',
|
||||
'stage',
|
||||
'recordPosition',
|
||||
'pipelineStepId',
|
||||
'pointOfContactId',
|
||||
'companyId',
|
||||
@ -31,6 +32,7 @@ export const seedOpportunity = async (
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
stage: 'new',
|
||||
recordPosition: 0,
|
||||
pipelineStepId: '6edf4ead-006a-46e1-9c6d-228f1d0143c9',
|
||||
pointOfContactId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
@ -43,6 +45,7 @@ export const seedOpportunity = async (
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
stage: 'meeting',
|
||||
recordPosition: 0,
|
||||
pipelineStepId: 'd8361722-03fb-4e65-bd4f-ec9e52e5ec0a',
|
||||
pointOfContactId: '93c72d2e-f517-42fd-80ae-14173b3b70ae',
|
||||
companyId: '118995f3-5d81-46d6-bf83-f7fd33ea6102',
|
||||
@ -55,6 +58,7 @@ export const seedOpportunity = async (
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
stage: 'proposal',
|
||||
recordPosition: 0,
|
||||
pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02',
|
||||
pointOfContactId: '9b324a88-6784-4449-afdf-dc62cb8702f2',
|
||||
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
|
||||
@ -67,6 +71,7 @@ export const seedOpportunity = async (
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
stage: 'proposal',
|
||||
recordPosition: 1,
|
||||
pipelineStepId: '30b14887-d592-427d-bd97-6e670158db02',
|
||||
pointOfContactId: '98406e26-80f1-4dff-b570-a74942528de3',
|
||||
companyId: '460b6fb1-ed89-413a-b31a-962986e67bb4',
|
||||
|
||||
@ -291,6 +291,22 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
workspaceId: objectMetadataInput.workspaceId,
|
||||
defaultValue: { type: 'now' },
|
||||
},
|
||||
{
|
||||
type: FieldMetadataType.NUMBER,
|
||||
name: 'recordPosition',
|
||||
label: 'Record position',
|
||||
targetColumnMap: {
|
||||
value: 'recordPosition',
|
||||
},
|
||||
icon: 'IconHierarchy2',
|
||||
description: 'Record position',
|
||||
isNullable: true,
|
||||
isActive: true,
|
||||
isCustom: false,
|
||||
isSystem: true,
|
||||
workspaceId: objectMetadataInput.workspaceId,
|
||||
defaultValue: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@ -375,6 +391,18 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: computeObjectTargetTable(createdObjectMetadata),
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
columnName: 'recordPosition',
|
||||
columnType: 'float',
|
||||
isNullable: true,
|
||||
} satisfies WorkspaceMigrationColumnCreate,
|
||||
],
|
||||
} satisfies WorkspaceMigrationTableAction,
|
||||
// This is temporary until we implement mainIdentifier
|
||||
{
|
||||
name: computeObjectTargetTable(createdObjectMetadata),
|
||||
|
||||
@ -38,6 +38,7 @@ const generateOpportunities = (
|
||||
amountCurrencyCode: 'USD',
|
||||
closeDate: new Date(),
|
||||
stage: getRandomStage(),
|
||||
recordPosition: null,
|
||||
probability: getRandomProbability(),
|
||||
pipelineStepId: getRandomPipelineStepId(pipelineStepIds),
|
||||
pointOfContactId: company.personId,
|
||||
@ -73,6 +74,7 @@ export const seedDemoOpportunity = async (
|
||||
'amountCurrencyCode',
|
||||
'closeDate',
|
||||
'stage',
|
||||
'recordPosition',
|
||||
'probability',
|
||||
'pipelineStepId',
|
||||
'pointOfContactId',
|
||||
|
||||
@ -19,6 +19,7 @@ export const personPrefillData = async (
|
||||
jobTitle: person.jobTitle,
|
||||
city: person.city,
|
||||
avatarUrl: person.avatarUrl,
|
||||
recordPosition: null,
|
||||
companyId: companies[Math.floor(index / 2)].id,
|
||||
}));
|
||||
|
||||
@ -33,6 +34,7 @@ export const personPrefillData = async (
|
||||
'jobTitle',
|
||||
'city',
|
||||
'avatarUrl',
|
||||
'recordPosition',
|
||||
'companyId',
|
||||
])
|
||||
.orIgnore()
|
||||
|
||||
@ -4,6 +4,7 @@ import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.en
|
||||
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
|
||||
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
|
||||
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
|
||||
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
|
||||
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
|
||||
import { ActivityTargetObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity-target.object-metadata';
|
||||
@ -94,6 +95,16 @@ export class CompanyObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
idealCustomerProfile: boolean;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'RecordPosition',
|
||||
description: 'Record Position',
|
||||
icon: 'IconHierarchy2',
|
||||
})
|
||||
@IsSystem()
|
||||
@IsNullable()
|
||||
recordPosition: number;
|
||||
|
||||
// Relations
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
|
||||
@ -3,6 +3,7 @@ import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.en
|
||||
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
import { FieldMetadata } from 'src/workspace/workspace-sync-metadata/decorators/field-metadata.decorator';
|
||||
import { IsNullable } from 'src/workspace/workspace-sync-metadata/decorators/is-nullable.decorator';
|
||||
import { IsSystem } from 'src/workspace/workspace-sync-metadata/decorators/is-system.decorator';
|
||||
import { ObjectMetadata } from 'src/workspace/workspace-sync-metadata/decorators/object-metadata.decorator';
|
||||
import { RelationMetadata } from 'src/workspace/workspace-sync-metadata/decorators/relation-metadata.decorator';
|
||||
import { ActivityTargetObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity-target.object-metadata';
|
||||
@ -76,6 +77,16 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
})
|
||||
stage: string;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'RecordPosition',
|
||||
description: 'Record Position',
|
||||
icon: 'IconHierarchy2',
|
||||
})
|
||||
@IsSystem()
|
||||
@IsNullable()
|
||||
recordPosition: number;
|
||||
|
||||
// Relations
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
|
||||
@ -92,6 +92,16 @@ export class PersonObjectMetadata extends BaseObjectMetadata {
|
||||
@IsSystem()
|
||||
avatarUrl: string;
|
||||
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.NUMBER,
|
||||
label: 'RecordPosition',
|
||||
description: 'Record Position',
|
||||
icon: 'IconHierarchy2',
|
||||
})
|
||||
@IsSystem()
|
||||
@IsNullable()
|
||||
recordPosition: number;
|
||||
|
||||
// Relations
|
||||
@FieldMetadata({
|
||||
type: FieldMetadataType.RELATION,
|
||||
|
||||
Reference in New Issue
Block a user