Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBERF-4248: Task type #4042

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ dev/tool/report*.csv
tests/db_dump
.build
.format
tools/apm/apm.js
tools/apm/apm.js
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
14 changes: 9 additions & 5 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 @@ -97,13 +97,16 @@ async function genVacansyApplicants (
name: faker.name.title(),
description: faker.lorem.sentences(2),
shortDescription: faker.lorem.sentences(1),
category: recruit.category.VacancyTypeCategories,
descriptor: recruit.descriptors.VacancyType,
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
22 changes: 16 additions & 6 deletions models/board/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,26 @@ export function createModel (builder: Builder): void {
})

builder.createDoc(
task.class.ProjectTypeCategory,
task.class.ProjectTypeDescriptor,
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
board.descriptors.BoardType
)
builder.createDoc(
task.class.TaskTypeDescriptor,
core.space.Model,
{
baseClass: board.class.Card,
allowCreate: true,
description: board.string.Card,
icon: board.icon.Card,
name: board.string.Card
},
board.descriptors.Card
)
}
111 changes: 87 additions & 24 deletions models/board/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
// limitations under the License.
//

import { boardId } from '@hcengineering/board'
import { type Ref, TxOperations } from '@hcengineering/core'
import {
type MigrateOperation,
type MigrationClient,
type MigrationUpgradeClient,
createOrUpdate
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 core, { DOMAIN_SPACE } from '@hcengineering/model-core'
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 @@ -54,27 +56,51 @@ async function createDefaultProjectType (tx: TxOperations): Promise<Ref<ProjectT
tx,
{
name: 'Default board',
category: board.category.BoardType,
description: ''
descriptor: board.descriptors.BoardType,
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,
descriptor: board.descriptors.Card,
name: 'Card',
ofClass: board.class.Card,
targetClass: board.class.Card,
statusClass: core.class.Status,
kind: 'task',
factory: [
{
color: PaletteColorIndexes.Coin,
name: 'Unstarted',
category: task.statusCategory.UnStarted,
ofAttribute: board.attribute.State
},
{
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.UnStarted,
task.statusCategory.Active,
task.statusCategory.Won,
task.statusCategory.Lost
]
}
],
board.template.DefaultBoard
Expand All @@ -100,7 +126,44 @@ 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: 'fix-category-descriptors',
func: async (client) => {
await client.update(
DOMAIN_SPACE,
{ _class: task.class.ProjectType, category: 'board:category:BoardType' },
{
$set: { descriptor: board.descriptors.BoardType },
$unset: { category: 1 }
}
)
}
},
{
state: 'fixTaskStatus',
func: async (client): Promise<void> => {
await fixTaskTypes(client, board.descriptors.BoardType, async () => [
{
name: 'Card',
descriptor: board.descriptors.Card,
ofClass: board.class.Card,
targetClass: board.class.Card,
statusCategories: [
task.statusCategory.UnStarted,
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
5 changes: 4 additions & 1 deletion models/board/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type Board, boardId } from '@hcengineering/board'
import board from '@hcengineering/board-resources/src/plugin'
import type { Ref } from '@hcengineering/core'
import { type IntlString, mergeIds } from '@hcengineering/platform'
import { type ProjectType, type Sequence } from '@hcengineering/task'
import { type TaskTypeDescriptor, type ProjectType, type Sequence } from '@hcengineering/task'
import type { AnyComponent } from '@hcengineering/ui/src/types'
import { type Action, type ViewAction, type Viewlet, type ViewletDescriptor } from '@hcengineering/view'

Expand Down Expand Up @@ -67,5 +67,8 @@ export default mergeIds(boardId, board, {
},
actionImpl: {
ConvertToCard: '' as ViewAction
},
descriptors: {
Card: '' as Ref<TaskTypeDescriptor>
}
})
1 change: 0 additions & 1 deletion models/contact/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default mergeIds(contactId, contact, {
ContactArrayEditor: '' as AnyComponent,
EmployeeEditor: '' as AnyComponent,
CreateEmployee: '' as AnyComponent,
AccountArrayEditor: '' as AnyComponent,
ChannelFilter: '' as AnyComponent,
MergePersons: '' as AnyComponent,
ChannelPanel: '' as AnyComponent,
Expand Down
22 changes: 16 additions & 6 deletions models/lead/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,16 +689,26 @@ export function createModel (builder: Builder): void {
})

builder.createDoc(
task.class.ProjectTypeCategory,
task.class.ProjectTypeDescriptor,
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
lead.descriptors.FunnelType
)
builder.createDoc(
task.class.TaskTypeDescriptor,
core.space.Model,
{
baseClass: lead.class.Lead,
allowCreate: true,
description: lead.string.Lead,
icon: lead.icon.Lead,
name: lead.string.Lead
},
lead.descriptors.Lead
)
}
Loading