V2 opportunities (#2565)
* changed isSystem to false * wip * wip * wip * add amount viewfield seed * seed other viewFields * upate tenant seeds * Remove calls to old pipelines --------- Co-authored-by: Charles Bochet <charles@twenty.com> Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
@ -8,6 +8,8 @@ import { seedViewFields } from 'src/database/typeorm-seeds/workspace/view-fields
|
||||
import { seedViews } from 'src/database/typeorm-seeds/workspace/views';
|
||||
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||
import { seedMetadataSchema } from 'src/database/typeorm-seeds/metadata';
|
||||
import { seedOpportunity } from 'src/database/typeorm-seeds/workspace/opportunity';
|
||||
import { seedPipelineStep } from 'src/database/typeorm-seeds/workspace/pipeline-step';
|
||||
import { seedWorkspaceMember } from 'src/database/typeorm-seeds/workspace/workspaceMember';
|
||||
import { seedPeople } from 'src/database/typeorm-seeds/workspace/people';
|
||||
|
||||
@ -55,6 +57,8 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
|
||||
|
||||
await seedCompanies(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedPeople(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedPipelineStep(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedOpportunity(workspaceDataSource, dataSourceMetadata.schema);
|
||||
|
||||
await seedViews(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViewFields(workspaceDataSource, dataSourceMetadata.schema);
|
||||
|
||||
@ -86,7 +86,7 @@ export const seedObjectMetadata = async (
|
||||
dataSourceId: SeedDataSourceId,
|
||||
workspaceId: SeedWorkspaceId,
|
||||
isActive: true,
|
||||
isSystem: true,
|
||||
isSystem: false,
|
||||
},
|
||||
{
|
||||
id: SeedObjectMetadataIds.PipelineStep,
|
||||
|
||||
38
server/src/database/typeorm-seeds/workspace/opportunity.ts
Normal file
38
server/src/database/typeorm-seeds/workspace/opportunity.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'opportunity';
|
||||
|
||||
export const seedOpportunity = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'amountAmountMicros',
|
||||
'amountCurrencyCode',
|
||||
'closeDate',
|
||||
'probability',
|
||||
'pipelineStepId',
|
||||
'pointOfContactId',
|
||||
'personId',
|
||||
'companyId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: '7c887ee3-be10-412b-a663-16bd3c2228e1',
|
||||
amountAmountMicros: 100000,
|
||||
amountCurrencyCode: 'USD',
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
pipelineStepId: '6edf4ead-006a-46e1-9c6d-228f1d0143c9',
|
||||
pointOfContactId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
personId: '86083141-1c0e-494c-a1b6-85b1c6fefaa5',
|
||||
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
47
server/src/database/typeorm-seeds/workspace/pipeline-step.ts
Normal file
47
server/src/database/typeorm-seeds/workspace/pipeline-step.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'pipelineStep';
|
||||
|
||||
export const seedPipelineStep = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, ['id', 'name', 'color', 'position'])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: '6edf4ead-006a-46e1-9c6d-228f1d0143c9',
|
||||
name: 'New',
|
||||
color: 'red',
|
||||
position: 0,
|
||||
},
|
||||
{
|
||||
id: 'd8361722-03fb-4e65-bd4f-ec9e52e5ec0a',
|
||||
name: 'Screening',
|
||||
color: 'purple',
|
||||
position: 1,
|
||||
},
|
||||
{
|
||||
id: '30b14887-d592-427d-bd97-6e670158db02',
|
||||
name: 'Meeting',
|
||||
color: 'sky',
|
||||
position: 2,
|
||||
},
|
||||
{
|
||||
id: 'db5a6648-d80d-4020-af64-4817ab4a12e8',
|
||||
name: 'Proposal',
|
||||
color: 'turquoise',
|
||||
position: 3,
|
||||
},
|
||||
{
|
||||
id: 'bea8bb7b-5467-48a6-9a8a-a8fa500123fe',
|
||||
name: 'Customer',
|
||||
color: 'yellow',
|
||||
position: 4,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -1,7 +1,6 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
import { SeedViewIds } from 'src/database/typeorm-seeds/workspace/views';
|
||||
import { SeedCompanyFieldMetadataIds } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
|
||||
|
||||
const tableName = 'viewField';
|
||||
|
||||
@ -23,130 +22,144 @@ export const seedViewFields = async (
|
||||
.values([
|
||||
{
|
||||
fieldMetadataId: 'name',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 0,
|
||||
isVisible: true,
|
||||
size: 180,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'domainName',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 1,
|
||||
isVisible: true,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'accountOwner',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 2,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'createdAt',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 3,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'employees',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 4,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'linkedin',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 5,
|
||||
isVisible: true,
|
||||
size: 170,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'address',
|
||||
viewId: SeedViewIds.PrismaCompany,
|
||||
viewId: SeedViewIds.Company,
|
||||
position: 6,
|
||||
isVisible: true,
|
||||
size: 170,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'displayName',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 0,
|
||||
isVisible: true,
|
||||
size: 210,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'email',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 1,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'company',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 2,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'phone',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 3,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'createdAt',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 4,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'city',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 5,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'jobTitle',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 6,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'linkedin',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 7,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'x',
|
||||
viewId: SeedViewIds.PrismaPerson,
|
||||
viewId: SeedViewIds.Person,
|
||||
position: 8,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
|
||||
{
|
||||
fieldMetadataId: SeedCompanyFieldMetadataIds.Name,
|
||||
viewId: SeedViewIds.Company,
|
||||
fieldMetadataId: 'amount',
|
||||
viewId: SeedViewIds.Opportunity,
|
||||
position: 0,
|
||||
isVisible: true,
|
||||
size: 180,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: SeedCompanyFieldMetadataIds.DomainName,
|
||||
viewId: SeedViewIds.Company,
|
||||
fieldMetadataId: 'closeDate',
|
||||
viewId: SeedViewIds.Opportunity,
|
||||
position: 1,
|
||||
isVisible: true,
|
||||
size: 100,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'probability',
|
||||
viewId: SeedViewIds.Opportunity,
|
||||
position: 2,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
fieldMetadataId: 'pointOfContact',
|
||||
viewId: SeedViewIds.Opportunity,
|
||||
position: 3,
|
||||
isVisible: true,
|
||||
size: 150,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
|
||||
@ -5,9 +5,6 @@ import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/objec
|
||||
const tableName = 'view';
|
||||
|
||||
export const enum SeedViewIds {
|
||||
PrismaCompany = '20202020-1ad3-4d1b-81f3-d7ecba29f8d3',
|
||||
PrismaPerson = '20202020-9adf-4768-bd9c-27a82fa141f1',
|
||||
PrismaOpportunity = '20202020-ffc7-4c81-bb41-d4baed4ed685',
|
||||
Company = '20202020-2441-4424-8163-4002c523d415',
|
||||
Person = '20202020-1979-447d-8115-593744eb4ead',
|
||||
Opportunity = '20202020-b2b3-48a5-96ce-0936d6af21f7',
|
||||
@ -28,24 +25,6 @@ export const seedViews = async (
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
id: SeedViewIds.PrismaCompany,
|
||||
name: 'All companies',
|
||||
objectMetadataId: 'company',
|
||||
type: 'table',
|
||||
},
|
||||
{
|
||||
id: SeedViewIds.PrismaPerson,
|
||||
name: 'All people',
|
||||
objectMetadataId: 'person',
|
||||
type: 'table',
|
||||
},
|
||||
{
|
||||
id: SeedViewIds.PrismaOpportunity,
|
||||
name: 'All opportunities',
|
||||
objectMetadataId: 'company',
|
||||
type: 'kanban',
|
||||
},
|
||||
{
|
||||
id: SeedViewIds.Company,
|
||||
name: 'All Companies',
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
export const opportunityPrefillData = async (
|
||||
entityManager: EntityManager,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await entityManager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.opportunity`, [
|
||||
'amount',
|
||||
'closeDate',
|
||||
'probability',
|
||||
'pipelineStepId',
|
||||
'pointOfContactId',
|
||||
'personId',
|
||||
'companyId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
amount: 100000,
|
||||
closeDate: new Date(),
|
||||
probability: 0.5,
|
||||
pipelineStepId: '73ac09c6-2b90-4874-9e5d-553ea76912ee',
|
||||
pointOfContactId: 'bb757987-ae38-4d16-96ec-b25b595e7bd8',
|
||||
personId: 'a4a2b8e9-7a2b-4b6a-8c8b-7e9a0a0a0a0a',
|
||||
companyId: 'fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
])
|
||||
.returning('*')
|
||||
.execute();
|
||||
};
|
||||
@ -5,6 +5,7 @@ import { viewPrefillData } from 'src/workspace/workspace-manager/standard-object
|
||||
import { companyPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/company';
|
||||
import { personPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/person';
|
||||
import { pipelineStepPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/pipeline-step';
|
||||
import { opportunityPrefillData } from 'src/workspace/workspace-manager/standard-objects-prefill-data/opportunity';
|
||||
|
||||
export const standardObjectsPrefillData = async (
|
||||
workspaceDataSource: DataSource,
|
||||
@ -27,5 +28,6 @@ export const standardObjectsPrefillData = async (
|
||||
await personPrefillData(entityManager, schemaName);
|
||||
await viewPrefillData(entityManager, schemaName, objectMetadataMap);
|
||||
await pipelineStepPrefillData(entityManager, schemaName);
|
||||
await opportunityPrefillData(entityManager, schemaName);
|
||||
});
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ const opportunityMetadata = {
|
||||
description: 'An opportunity',
|
||||
icon: 'IconTargetArrow',
|
||||
isActive: true,
|
||||
isSystem: true,
|
||||
isSystem: false,
|
||||
fields: [
|
||||
{
|
||||
isCustom: false,
|
||||
|
||||
Reference in New Issue
Block a user