Skip to content

Commit

Permalink
UBERF-4248: Task type
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo committed Dec 6, 2023
1 parent 7b5fdb6 commit edf63ec
Show file tree
Hide file tree
Showing 129 changed files with 3,948 additions and 2,337 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,8 @@ dev/tool/report*.csv
tests/db_dump
.build
.format
tools/apm/apm.js
<<<<<<< HEAD
tools/apm/apm.js
=======
tools/apm/apm.js
>>>>>>> 23d5e46d9 (UBERF-4248: Task type)
6 changes: 4 additions & 2 deletions dev/generator/src/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const object: AttachedData<Issue> = {
remainingTime: 0,
estimation: 0,
reports: 0,
childInfo: []
childInfo: [],
kind: tracker.taskTypes.Issue
}

export interface IssueOptions {
Expand Down Expand Up @@ -100,7 +101,8 @@ async function genIssue (client: TxOperations, statuses: Ref<IssueStatus>[]): Pr
estimation: object.estimation,
reports: 0,
relations: [],
childInfo: []
childInfo: [],
kind: tracker.taskTypes.Issue
}
await client.addCollection(
tracker.class.Issue,
Expand Down
12 changes: 8 additions & 4 deletions dev/generator/src/recruit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import core, {
import { MinioService } from '@hcengineering/minio'
import recruit from '@hcengineering/model-recruit'
import { Applicant, Candidate, Vacancy } from '@hcengineering/recruit'
import task, { ProjectType, genRanks } from '@hcengineering/task'
import task, { ProjectType, TaskType, genRanks } from '@hcengineering/task'
import faker from 'faker'
import jpeg, { BufferRet } from 'jpeg-js'
import { AttachmentOptions, addAttachments } from './attachments'
Expand Down Expand Up @@ -101,9 +101,12 @@ async function genVacansyApplicants (
private: false,
members: [],
archived: false,
tasks: [],
// TODO: Fix me.
statuses: states.map((s) => {
return { _id: s }
})
return { _id: s, taskType: '' as Ref<TaskType> }
}),
targetClass: recruit.class.Vacancy
}

await ctx.with('update', {}, (ctx) =>
Expand Down Expand Up @@ -180,7 +183,8 @@ async function genApplicant (
status: faker.random.arrayElement(states),
rank,
startDate: null,
dueDate: null
dueDate: null,
kind: recruit.taskTypes.Applicant
}

// Update or create candidate
Expand Down
6 changes: 2 additions & 4 deletions models/board/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,10 @@ export function createModel (builder: Builder): void {
task.class.ProjectTypeCategory,
core.space.Model,
{
name: board.string.Boards,
name: board.string.BoardApplication,
description: board.string.ManageBoardStatuses,
icon: board.component.TemplatesIcon,
attachedToClass: board.class.Board,
statusClass: core.class.Status,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost]
baseClass: board.class.Board
},
board.category.BoardType
)
Expand Down
78 changes: 51 additions & 27 deletions models/board/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@
// limitations under the License.
//

import { boardId } from '@hcengineering/board'
import { type Ref, TxOperations } from '@hcengineering/core'
import {
type MigrateOperation,
type MigrationClient,
type MigrationUpgradeClient,
createOrUpdate
} from '@hcengineering/model'
import { type MigrateOperation, type MigrationClient, type MigrationUpgradeClient, createOrUpdate, tryMigrate } from '@hcengineering/model'
import core from '@hcengineering/model-core'
import { createProjectType, createSequence } from '@hcengineering/model-task'
import tags from '@hcengineering/model-tags'
import { createProjectType, createSequence, fixTaskTypes } from '@hcengineering/model-task'
import tags from '@hcengineering/tags'
import task, { type ProjectType } from '@hcengineering/task'
import board from './plugin'
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
import board from './plugin'

async function createSpace (tx: TxOperations): Promise<void> {
const current = await tx.findOne(core.class.Space, {
Expand Down Expand Up @@ -55,26 +51,38 @@ async function createDefaultProjectType (tx: TxOperations): Promise<Ref<ProjectT
{
name: 'Default board',
category: board.category.BoardType,
description: ''
description: '',
tasks: []
},
[
{
color: PaletteColorIndexes.Blueberry,
name: 'To do',
category: task.statusCategory.Active,
ofAttribute: board.attribute.State
},
{
color: PaletteColorIndexes.Arctic,
name: 'Done',
category: task.statusCategory.Active,
ofAttribute: board.attribute.State
},
{
color: PaletteColorIndexes.Grass,
name: 'Completed',
category: board.statusCategory.Completed,
ofAttribute: board.attribute.State
_id: board.taskType.Card,
name: 'Card',
ofClass: board.class.Card,
targetClass: board.class.Card,
statusClass: core.class.Status,
kind: 'task',
factory: [
{
color: PaletteColorIndexes.Blueberry,
name: 'To do',
category: task.statusCategory.Active,
ofAttribute: board.attribute.State
},
{
color: PaletteColorIndexes.Arctic,
name: 'Done',
category: task.statusCategory.Active,
ofAttribute: board.attribute.State
},
{
color: PaletteColorIndexes.Grass,
name: 'Completed',
category: board.statusCategory.Completed,
ofAttribute: board.attribute.State
}
],
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost]
}
],
board.template.DefaultBoard
Expand All @@ -100,7 +108,23 @@ async function createDefaults (tx: TxOperations): Promise<void> {
}

export const boardOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {},
async migrate (client: MigrationClient): Promise<void> {
await tryMigrate(client, boardId, [
{
state: 'fixTaskStatus',
func: async (client): Promise<void> => {
await fixTaskTypes(client, board.category.BoardType, async () => ([{
name: 'Card',
ofClass: board.class.Card,
targetClass: board.class.Card,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost],
statusClass: core.class.Status,
kind: 'task'
}]))
}
}
])
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const ops = new TxOperations(client, core.account.System)
await createDefaults(ops)
Expand Down
6 changes: 2 additions & 4 deletions models/lead/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,10 @@ export function createModel (builder: Builder): void {
task.class.ProjectTypeCategory,
core.space.Model,
{
name: lead.string.Funnels,
name: lead.string.LeadApplication,
description: lead.string.ManageFunnelStatuses,
icon: lead.component.TemplatesIcon,
attachedToClass: lead.class.Funnel,
statusClass: core.class.Status,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost]
baseClass: lead.class.Funnel
},
lead.category.FunnelTypeCategory
)
Expand Down
118 changes: 63 additions & 55 deletions models/lead/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@

import { TxOperations } from '@hcengineering/core'
import { leadId } from '@hcengineering/lead'
import {
type MigrateOperation,
type MigrationClient,
type MigrationUpgradeClient,
tryUpgrade
} from '@hcengineering/model'
import { tryMigrate, tryUpgrade, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model'
import core from '@hcengineering/model-core'
import { createProjectType, createSequence } from '@hcengineering/model-task'
import tracker from '@hcengineering/model-tracker'
import task from '@hcengineering/task'
import task, { createProjectType, createSequence, fixTaskTypes } from '@hcengineering/model-task'
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
import lead from './plugin'

Expand All @@ -38,41 +31,53 @@ async function createSpace (tx: TxOperations): Promise<void> {
{
name: 'Default funnel',
category: lead.category.FunnelTypeCategory,
description: ''
description: '',
tasks: []
},
[
{
color: PaletteColorIndexes.Coin,
name: 'Incoming',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Arctic,
name: 'Negotation',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Watermelon,
name: 'Offer preparing',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Orange,
name: 'Make a decision',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Ocean,
name: 'Contract conclusion',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{ name: 'Won', ofAttribute: lead.attribute.State, category: task.statusCategory.Won },
{ name: 'Lost', ofAttribute: lead.attribute.State, category: task.statusCategory.Lost }
_id: lead.taskType.Lead,
name: 'Lead',
ofClass: lead.class.Lead,
targetClass: lead.class.Lead,
statusClass: core.class.Status,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost],
kind: 'task',
factory: [
{
color: PaletteColorIndexes.Coin,
name: 'Incoming',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Arctic,
name: 'Negotation',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Watermelon,
name: 'Offer preparing',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Orange,
name: 'Make a decision',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{
color: PaletteColorIndexes.Ocean,
name: 'Contract conclusion',
ofAttribute: lead.attribute.State,
category: task.statusCategory.Active
},
{ name: 'Won', ofAttribute: lead.attribute.State, category: task.statusCategory.Won },
{ name: 'Lost', ofAttribute: lead.attribute.State, category: task.statusCategory.Lost }
]
}
],
lead.template.DefaultFunnel
)
Expand All @@ -98,24 +103,27 @@ async function createDefaults (tx: TxOperations): Promise<void> {
}

export const leadOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const ops = new TxOperations(client, core.account.System)
await createDefaults(ops)

await tryUpgrade(client, leadId, [
async migrate (client: MigrationClient): Promise<void> {
await tryMigrate(client, leadId, [
{
state: 'related-targets',
state: 'fixTaskStatus',
func: async (client): Promise<void> => {
const ops = new TxOperations(client, core.account.ConfigUser)
await ops.createDoc(tracker.class.RelatedIssueTarget, core.space.Configuration, {
rule: {
kind: 'classRule',
ofClass: lead.class.Lead
}
})
await fixTaskTypes(client, lead.category.FunnelTypeCategory, async () => ([{
name: 'Lead',
ofClass: lead.class.Lead,
targetClass: lead.class.Lead,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost],
statusClass: core.class.Status,
kind: 'task'
}]))
}
}
])
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const ops = new TxOperations(client, core.account.System)
await createDefaults(ops)

await tryUpgrade(client, leadId, [])
}
}
4 changes: 2 additions & 2 deletions models/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ export function createModel (builder: Builder): void {
label: notification.string.Notifications,
icon: notification.icon.Notifications,
component: notification.component.NotificationSettings,
group: 'settings',
group: 'settings-account',
secured: false,
order: 2500
order: 1500
},
notification.ids.NotificationSettings
)
Expand Down
6 changes: 2 additions & 4 deletions models/recruit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,13 +1712,11 @@ export function createModel (builder: Builder): void {
task.class.ProjectTypeCategory,
core.space.Model,
{
name: recruit.string.Vacancies,
name: recruit.string.RecruitApplication,
description: recruit.string.ManageVacancyStatuses,
icon: recruit.component.TemplatesIcon,
editor: recruit.component.VacancyTemplateEditor,
attachedToClass: recruit.class.Vacancy,
statusClass: core.class.Status,
statusCategories: [task.statusCategory.Active, task.statusCategory.Won, task.statusCategory.Lost]
baseClass: recruit.class.Vacancy
},
recruit.category.VacancyTypeCategories
)
Expand Down
Loading

0 comments on commit edf63ec

Please sign in to comment.