Set opportunity stage as editable (#3838)
* Set opportunity stage as editable * Fix comments * Add command for migration * Fixes --------- Co-authored-by: Thomas Trompette <thomast@twenty.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -13,7 +13,7 @@ const getRandomPipelineStepId = (pipelineStepIds: { id: string }[]) =>
|
||||
pipelineStepIds[Math.floor(Math.random() * pipelineStepIds.length)].id;
|
||||
|
||||
const getRandomStage = () => {
|
||||
const stages = ['new', 'screening', 'meeting', 'proposal', 'customer'];
|
||||
const stages = ['NEW', 'SCREENING', 'MEETING', 'PROPOSAL', 'CUSTOMER'];
|
||||
|
||||
return stages[Math.floor(Math.random() * stages.length)];
|
||||
};
|
||||
|
||||
@ -11,27 +11,27 @@ export const pipelineStepPrefillData = async (
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
name: 'New',
|
||||
name: 'NEW',
|
||||
color: 'red',
|
||||
position: 0,
|
||||
},
|
||||
{
|
||||
name: 'Screening',
|
||||
name: 'SCREENING',
|
||||
color: 'purple',
|
||||
position: 1,
|
||||
},
|
||||
{
|
||||
name: 'Meeting',
|
||||
name: 'MEETING',
|
||||
color: 'sky',
|
||||
position: 2,
|
||||
},
|
||||
{
|
||||
name: 'Proposal',
|
||||
name: 'PROPOSAL',
|
||||
color: 'turquoise',
|
||||
position: 3,
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
name: 'CUSTOMER',
|
||||
color: 'yellow',
|
||||
position: 4,
|
||||
},
|
||||
|
||||
@ -11,27 +11,27 @@ export const pipelineStepPrefillData = async (
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
name: 'New',
|
||||
name: 'NEW',
|
||||
color: 'red',
|
||||
position: 0,
|
||||
},
|
||||
{
|
||||
name: 'Screening',
|
||||
name: 'SCREENING',
|
||||
color: 'purple',
|
||||
position: 1,
|
||||
},
|
||||
{
|
||||
name: 'Meeting',
|
||||
name: 'MEETING',
|
||||
color: 'sky',
|
||||
position: 2,
|
||||
},
|
||||
{
|
||||
name: 'Proposal',
|
||||
name: 'PROPOSAL',
|
||||
color: 'turquoise',
|
||||
position: 3,
|
||||
},
|
||||
{
|
||||
name: 'Customer',
|
||||
name: 'CUSTOMER',
|
||||
color: 'yellow',
|
||||
position: 4,
|
||||
},
|
||||
|
||||
@ -138,13 +138,13 @@ export class WorkspaceMigrationEnumService {
|
||||
.map((e) => `'${e}'`)
|
||||
.join(', ')}]`;
|
||||
} else {
|
||||
defaultValue = `'${columnDefinition.defaultValue}'`;
|
||||
defaultValue = this.getStringifyValue(columnDefinition.defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
await queryRunner.query(`
|
||||
UPDATE "${schemaName}"."${tableName}"
|
||||
SET "${columnDefinition.columnName}" = ${defaultValue}
|
||||
SET "${columnDefinition.columnName}" = '${defaultValue}'
|
||||
WHERE "${columnDefinition.columnName}" NOT IN (${enumValues
|
||||
.map((e) => `'${e}'`)
|
||||
.join(', ')})
|
||||
@ -159,7 +159,7 @@ export class WorkspaceMigrationEnumService {
|
||||
newEnumTypeName: string,
|
||||
) {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "${schemaName}"."${tableName}" ALTER COLUMN "${columnName}" TYPE "${schemaName}"."${newEnumTypeName}" USING ("${columnName}"::text::"${schemaName}"."${newEnumTypeName}")`,
|
||||
`ALTER TABLE "${schemaName}"."${tableName}" ALTER COLUMN "${columnName}" DROP DEFAULT, ALTER COLUMN "${columnName}" TYPE "${schemaName}"."${newEnumTypeName}" USING ("${columnName}"::text::"${schemaName}"."${newEnumTypeName}")`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -184,4 +184,8 @@ export class WorkspaceMigrationEnumService {
|
||||
RENAME TO "${oldEnumTypeName}"
|
||||
`);
|
||||
}
|
||||
|
||||
private getStringifyValue(value: any) {
|
||||
return typeof value === 'string' ? value : `'${value}'`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,6 +275,8 @@ export class WorkspaceMigrationRunnerService {
|
||||
tableName,
|
||||
migrationColumn,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@ -63,18 +63,18 @@ export class OpportunityObjectMetadata extends BaseObjectMetadata {
|
||||
description: 'Opportunity stage',
|
||||
icon: 'IconProgressCheck',
|
||||
options: [
|
||||
{ value: 'new', label: 'New', position: 0, color: 'red' },
|
||||
{ value: 'screening', label: 'Screening', position: 1, color: 'purple' },
|
||||
{ value: 'meeting', label: 'Meeting', position: 2, color: 'sky' },
|
||||
{ value: 'NEW', label: 'New', position: 0, color: 'red' },
|
||||
{ value: 'SCREENING', label: 'Screening', position: 1, color: 'purple' },
|
||||
{ value: 'MEETING', label: 'Meeting', position: 2, color: 'sky' },
|
||||
{
|
||||
value: 'proposal',
|
||||
value: 'PROPOSAL',
|
||||
label: 'Proposal',
|
||||
position: 3,
|
||||
color: 'turquoise',
|
||||
},
|
||||
{ value: 'customer', label: 'Customer', position: 4, color: 'yellow' },
|
||||
{ value: 'CUSTOMER', label: 'Customer', position: 4, color: 'yellow' },
|
||||
],
|
||||
defaultValue: { value: 'new' },
|
||||
defaultValue: { value: 'NEW' },
|
||||
})
|
||||
stage: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user