diff --git a/dev/generator/src/recruit.ts b/dev/generator/src/recruit.ts index 322bc2208f..900a669bb4 100644 --- a/dev/generator/src/recruit.ts +++ b/dev/generator/src/recruit.ts @@ -102,6 +102,7 @@ async function genVacansyApplicants ( members: [], archived: false, tasks: [], + classic: true, // TODO: Fix me. statuses: states.map((s) => { return { _id: s, taskType: '' as Ref } diff --git a/models/board/src/migration.ts b/models/board/src/migration.ts index 31d462d5cb..84eb3807bb 100644 --- a/models/board/src/migration.ts +++ b/models/board/src/migration.ts @@ -58,7 +58,8 @@ async function createDefaultProjectType (tx: TxOperations): Promise { name: 'Default funnel', descriptor: lead.descriptors.FunnelType, description: '', - tasks: [] + tasks: [], + classic: true }, [ { diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index 2e93a63717..078d55e421 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -136,7 +136,8 @@ async function createDefaultKanbanTemplate (tx: TxOperations): Promise @Prop(TypeString(), task.string.TaskNumber) @@ -203,6 +205,9 @@ export class TProjectType extends TSpace implements ProjectType { @Prop(TypeRef(core.class.Class), getEmbeddedLabel('Target Class')) targetClass!: Ref> + + @Prop(TypeBoolean(), getEmbeddedLabel('Classic')) + classic!: boolean } @Model(task.class.TaskType, core.class.Doc, DOMAIN_TASK) @@ -506,7 +511,7 @@ export function createModel (builder: Builder): void { icon: task.icon.TaskState, color: PaletteColorIndexes.Porpoise, defaultStatusName: 'New state', - order: 0 + order: 1 }, task.statusCategory.Active ) @@ -520,7 +525,7 @@ export function createModel (builder: Builder): void { icon: task.icon.TaskState, color: PaletteColorIndexes.Grass, defaultStatusName: 'Won', - order: 0 + order: 2 }, task.statusCategory.Won ) @@ -534,7 +539,7 @@ export function createModel (builder: Builder): void { icon: task.icon.TaskState, color: PaletteColorIndexes.Coin, defaultStatusName: 'Lost', - order: 0 + order: 3 }, task.statusCategory.Lost ) diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index d8500e281f..0029ffc394 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { TxOperations, type Class, type Doc, type Ref } from '@hcengineering/core' +import { TxOperations, type Class, type Doc, type Ref, toIdMap } from '@hcengineering/core' import { createOrUpdate, tryMigrate, @@ -39,6 +39,26 @@ export async function createSequence (tx: TxOperations, _class: Ref>) } } +async function reorderStates (_client: MigrationUpgradeClient): Promise { + const client = new TxOperations(_client, core.account.System) + const states = toIdMap(await client.findAll(core.class.Status, {})) + const order = [ + task.statusCategory.UnStarted, + task.statusCategory.Active, + task.statusCategory.Won, + task.statusCategory.Lost + ] + const taskTypes = await client.findAll(task.class.TaskType, {}) + for (const taskType of taskTypes) { + const statuses = [...taskType.statuses].sort((a, b) => { + const aIndex = order.indexOf(states.get(a)?.category ?? task.statusCategory.UnStarted) + const bIndex = order.indexOf(states.get(b)?.category ?? task.statusCategory.UnStarted) + return aIndex - bIndex + }) + await client.diffUpdate(taskType, { statuses }) + } +} + async function createDefaultSequence (tx: TxOperations): Promise { const current = await tx.findOne(core.class.Space, { _id: task.space.Sequence @@ -92,6 +112,18 @@ export const taskOperation: MigrateOperation = { func: async (client) => { await client.update(DOMAIN_SPACE, { space: core.space.Model }, { space: core.space.Space }) } + }, + { + state: 'classicProjectTypes', + func: async (client) => { + await client.update( + DOMAIN_SPACE, + { _class: task.class.ProjectType, classic: { $exists: false } }, + { + classic: true + } + ) + } } ]) }, @@ -113,6 +145,11 @@ export const taskOperation: MigrateOperation = { task.category.TaskTag ) - await tryUpgrade(client, taskId, []) + await tryUpgrade(client, taskId, [ + { + state: 'reorderStates', + func: reorderStates + } + ]) } } diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index 4a83c7fcc3..cec63c0230 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -58,7 +58,8 @@ async function createDefaultProject (tx: TxOperations): Promise { name: 'Classic project', descriptor: tracker.descriptors.ProjectType, description: '', - tasks: [] + tasks: [], + classic: true }, [ { @@ -88,7 +89,8 @@ async function createDefaultProject (tx: TxOperations): Promise { name: 'Base project', descriptor: tracker.descriptors.ProjectType, description: '', - tasks: [] + tasks: [], + classic: false }, [ { diff --git a/plugins/task-assets/lang/en.json b/plugins/task-assets/lang/en.json index facb08d0e5..1b19600890 100644 --- a/plugins/task-assets/lang/en.json +++ b/plugins/task-assets/lang/en.json @@ -81,6 +81,8 @@ "StatusChange": "Status changed", "TaskCreated": "Task created", "TaskType": "Task type", - "ManageProjects": "Project types" + "ManageProjects": "Project types", + "CreateProjectType": "Create project type", + "ClassicProject": "Classic project" } } \ No newline at end of file diff --git a/plugins/task-assets/lang/ru.json b/plugins/task-assets/lang/ru.json index 0433302131..73a96e2a06 100644 --- a/plugins/task-assets/lang/ru.json +++ b/plugins/task-assets/lang/ru.json @@ -81,6 +81,8 @@ "StatusChange": "Статус изменен", "TaskCreated": "Создана задача", "TaskType": "Тип задачи", - "ManageProjects": "Управление проектами" + "ManageProjects": "Управление проектами", + "CreateProjectType": "Создать тип проекта", + "ClassicProject": "Классический проект" } } \ No newline at end of file diff --git a/plugins/task-resources/src/components/StatusSelector.svelte b/plugins/task-resources/src/components/StatusSelector.svelte index 275035e214..c75dbb092d 100644 --- a/plugins/task-resources/src/components/StatusSelector.svelte +++ b/plugins/task-resources/src/components/StatusSelector.svelte @@ -1,17 +1,15 @@ diff --git a/plugins/task-resources/src/components/projectTypes/CreateProjectType.svelte b/plugins/task-resources/src/components/projectTypes/CreateProjectType.svelte new file mode 100644 index 0000000000..501bd440c1 --- /dev/null +++ b/plugins/task-resources/src/components/projectTypes/CreateProjectType.svelte @@ -0,0 +1,77 @@ + + + + + 0 && descriptor !== undefined} + okAction={createType} + on:close={() => { + dispatch('close') + }} + on:changeContent +> +
+ + + +
+
diff --git a/plugins/task-resources/src/components/projectTypes/ManageProjectsTools.svelte b/plugins/task-resources/src/components/projectTypes/ManageProjectsTools.svelte index c50b8b1e2c..d4756ce020 100644 --- a/plugins/task-resources/src/components/projectTypes/ManageProjectsTools.svelte +++ b/plugins/task-resources/src/components/projectTypes/ManageProjectsTools.svelte @@ -14,46 +14,12 @@ // limitations under the License. --> -