2021-08-07 14:49:14 +00:00
|
|
|
//
|
2022-04-16 02:59:50 +00:00
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
2021-08-07 14:49:14 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2023-08-04 18:06:21 +00:00
|
|
|
import type { Employee, Person } from '@hcengineering/contact'
|
2022-09-21 08:08:25 +00:00
|
|
|
import contact from '@hcengineering/contact'
|
2023-10-27 05:22:43 +00:00
|
|
|
import {
|
2023-12-14 16:26:02 +00:00
|
|
|
ClassifierKind,
|
2023-10-27 05:22:43 +00:00
|
|
|
DOMAIN_MODEL,
|
2023-12-14 16:26:02 +00:00
|
|
|
DOMAIN_STATUS,
|
|
|
|
DOMAIN_TX,
|
|
|
|
IndexKind,
|
|
|
|
generateId,
|
|
|
|
type Class,
|
|
|
|
type Data,
|
2023-11-20 10:01:43 +00:00
|
|
|
type Doc,
|
|
|
|
type Domain,
|
|
|
|
type Ref,
|
|
|
|
type Status,
|
|
|
|
type StatusCategory,
|
2023-12-14 16:26:02 +00:00
|
|
|
type Timestamp,
|
|
|
|
type TxCreateDoc,
|
|
|
|
type TxMixin
|
2023-10-27 05:22:43 +00:00
|
|
|
} from '@hcengineering/core'
|
2022-01-18 10:21:32 +00:00
|
|
|
import {
|
2023-12-14 16:26:02 +00:00
|
|
|
ArrOf,
|
2022-04-16 02:59:50 +00:00
|
|
|
Collection,
|
|
|
|
Hidden,
|
2022-02-08 09:02:35 +00:00
|
|
|
Index,
|
2022-01-18 10:21:32 +00:00
|
|
|
Mixin,
|
|
|
|
Model,
|
2022-04-16 02:59:50 +00:00
|
|
|
Prop,
|
|
|
|
TypeBoolean,
|
2022-01-18 10:21:32 +00:00
|
|
|
TypeDate,
|
2022-02-07 09:21:32 +00:00
|
|
|
TypeMarkup,
|
2023-12-14 16:26:02 +00:00
|
|
|
TypeRecord,
|
2022-01-18 10:21:32 +00:00
|
|
|
TypeRef,
|
|
|
|
TypeString,
|
2023-12-14 16:26:02 +00:00
|
|
|
UX,
|
|
|
|
type Builder,
|
2023-12-29 07:05:27 +00:00
|
|
|
type MigrationClient,
|
|
|
|
ReadOnly
|
2022-09-21 08:08:25 +00:00
|
|
|
} from '@hcengineering/model'
|
2023-09-04 17:06:34 +00:00
|
|
|
import attachment from '@hcengineering/model-attachment'
|
2023-12-14 16:26:02 +00:00
|
|
|
import chunter from '@hcengineering/model-chunter'
|
|
|
|
import core, { DOMAIN_SPACE, TAttachedDoc, TClass, TDoc, TSpace } from '@hcengineering/model-core'
|
|
|
|
import view, {
|
|
|
|
classPresenter,
|
|
|
|
createAction,
|
|
|
|
template,
|
|
|
|
actionTemplates as viewTemplates
|
|
|
|
} from '@hcengineering/model-view'
|
2024-01-04 17:54:58 +00:00
|
|
|
import { getEmbeddedLabel, type Asset, type IntlString, type Resource } from '@hcengineering/platform'
|
2023-12-14 16:26:02 +00:00
|
|
|
import setting from '@hcengineering/setting'
|
2022-09-21 08:08:25 +00:00
|
|
|
import tags from '@hcengineering/tags'
|
2022-05-06 17:48:43 +00:00
|
|
|
import {
|
2023-12-20 06:29:31 +00:00
|
|
|
type TaskStatusFactory,
|
2023-12-14 16:26:02 +00:00
|
|
|
calculateStatuses,
|
|
|
|
findStatusAttr,
|
2023-11-20 10:01:43 +00:00
|
|
|
type KanbanCard,
|
|
|
|
type Project,
|
|
|
|
type ProjectStatus,
|
|
|
|
type ProjectType,
|
2023-12-14 16:26:02 +00:00
|
|
|
type ProjectTypeClass,
|
|
|
|
type ProjectTypeDescriptor,
|
2023-11-20 10:01:43 +00:00
|
|
|
type Sequence,
|
|
|
|
type Task,
|
2023-12-14 16:26:02 +00:00
|
|
|
type TaskType,
|
|
|
|
type TaskTypeClass,
|
|
|
|
type TaskTypeDescriptor,
|
|
|
|
type TaskTypeKind,
|
2023-11-20 10:01:43 +00:00
|
|
|
type TodoItem
|
2022-09-21 08:08:25 +00:00
|
|
|
} from '@hcengineering/task'
|
2023-12-14 16:26:02 +00:00
|
|
|
import type { AnyComponent } from '@hcengineering/ui'
|
|
|
|
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
|
2023-11-20 10:01:43 +00:00
|
|
|
import { type ViewAction } from '@hcengineering/view'
|
2023-12-13 15:59:11 +00:00
|
|
|
|
2022-01-21 09:05:55 +00:00
|
|
|
import task from './plugin'
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
export { createProjectType, taskId } from '@hcengineering/task'
|
|
|
|
export { createSequence, taskOperation } from './migration'
|
2021-12-15 09:04:43 +00:00
|
|
|
export { default } from './plugin'
|
|
|
|
|
|
|
|
export const DOMAIN_TASK = 'task' as Domain
|
|
|
|
export const DOMAIN_KANBAN = 'kanban' as Domain
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2023-04-04 06:11:49 +00:00
|
|
|
@Model(task.class.Task, core.class.AttachedDoc, DOMAIN_TASK)
|
2022-03-22 09:09:58 +00:00
|
|
|
@UX(task.string.Task, task.icon.Task, task.string.Task)
|
2021-12-15 09:04:43 +00:00
|
|
|
export class TTask extends TAttachedDoc implements Task {
|
2023-07-13 13:33:23 +00:00
|
|
|
@Prop(TypeRef(core.class.Status), task.string.TaskState, { _id: task.attribute.State })
|
2023-10-17 08:21:59 +00:00
|
|
|
@Index(IndexKind.Indexed)
|
2023-07-13 13:33:23 +00:00
|
|
|
status!: Ref<Status>
|
2021-12-15 09:04:43 +00:00
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
@Prop(TypeRef(task.class.TaskType), task.string.TaskType)
|
|
|
|
@Index(IndexKind.Indexed)
|
2023-12-29 07:05:27 +00:00
|
|
|
@ReadOnly()
|
2023-12-14 16:26:02 +00:00
|
|
|
kind!: Ref<TaskType>
|
|
|
|
|
2022-01-19 09:09:08 +00:00
|
|
|
@Prop(TypeString(), task.string.TaskNumber)
|
2023-01-24 13:42:47 +00:00
|
|
|
@Index(IndexKind.FullText)
|
2023-01-31 17:18:07 +00:00
|
|
|
@Hidden()
|
2022-11-02 08:50:14 +00:00
|
|
|
number!: number
|
2021-12-15 09:04:43 +00:00
|
|
|
|
2023-11-27 06:58:14 +00:00
|
|
|
@Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee)
|
|
|
|
assignee!: Ref<Person> | null
|
2021-12-17 09:08:37 +00:00
|
|
|
|
2023-05-12 05:42:15 +00:00
|
|
|
@Prop(TypeDate(), task.string.DueDate, { editor: task.component.DueDateEditor })
|
2022-11-02 08:50:14 +00:00
|
|
|
dueDate!: Timestamp | null
|
2022-05-23 07:28:41 +00:00
|
|
|
|
2021-12-17 09:08:37 +00:00
|
|
|
declare rank: string
|
2021-12-20 10:18:29 +00:00
|
|
|
|
2022-05-27 16:43:11 +00:00
|
|
|
@Prop(Collection(tags.class.TagReference, task.string.TaskLabels), task.string.TaskLabels)
|
2023-07-13 13:33:23 +00:00
|
|
|
labels?: number
|
|
|
|
|
2023-12-13 15:59:11 +00:00
|
|
|
@Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments)
|
2023-07-13 13:33:23 +00:00
|
|
|
comments?: number
|
|
|
|
|
|
|
|
@Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files })
|
|
|
|
attachments?: number
|
2023-10-27 05:22:43 +00:00
|
|
|
|
|
|
|
isDone?: boolean
|
2021-12-20 10:18:29 +00:00
|
|
|
}
|
|
|
|
|
2023-04-04 06:11:49 +00:00
|
|
|
@Model(task.class.TodoItem, core.class.AttachedDoc, DOMAIN_TASK)
|
2022-01-19 09:09:08 +00:00
|
|
|
@UX(task.string.Todo)
|
2021-12-20 10:18:29 +00:00
|
|
|
export class TTodoItem extends TAttachedDoc implements TodoItem {
|
2022-05-04 13:52:31 +00:00
|
|
|
@Prop(TypeMarkup(), task.string.TodoName, task.icon.Task)
|
2022-02-08 09:02:35 +00:00
|
|
|
@Index(IndexKind.FullText)
|
2022-11-02 08:50:14 +00:00
|
|
|
name!: string
|
2021-12-20 10:18:29 +00:00
|
|
|
|
2023-08-04 18:06:21 +00:00
|
|
|
@Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee)
|
2022-11-02 08:50:14 +00:00
|
|
|
assignee!: Ref<Employee> | null
|
2022-05-04 13:52:31 +00:00
|
|
|
|
2022-01-19 09:09:08 +00:00
|
|
|
@Prop(TypeBoolean(), task.string.TaskDone)
|
2022-11-02 08:50:14 +00:00
|
|
|
done!: boolean
|
2021-12-20 10:18:29 +00:00
|
|
|
|
2022-01-19 09:09:08 +00:00
|
|
|
@Prop(TypeDate(), task.string.TaskDueTo)
|
2022-11-02 08:50:14 +00:00
|
|
|
dueTo!: Timestamp | null
|
2022-05-04 13:52:31 +00:00
|
|
|
|
|
|
|
@Prop(Collection(task.class.TodoItem), task.string.Todos)
|
2022-11-02 08:50:14 +00:00
|
|
|
items!: number
|
2022-05-26 09:36:44 +00:00
|
|
|
|
|
|
|
declare rank: string
|
2021-12-15 09:04:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Mixin(task.mixin.KanbanCard, core.class.Class)
|
|
|
|
export class TKanbanCard extends TClass implements KanbanCard {
|
|
|
|
card!: AnyComponent
|
|
|
|
}
|
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
@Model(task.class.TaskTypeDescriptor, core.class.Doc, DOMAIN_MODEL)
|
|
|
|
export class TTaskTypeDescriptor extends TDoc implements TaskTypeDescriptor {
|
|
|
|
name!: IntlString
|
|
|
|
description!: IntlString
|
|
|
|
icon!: Asset
|
|
|
|
baseClass!: Ref<Class<Task>>
|
|
|
|
|
|
|
|
// If specified, will allow to be created by users, system type overwize
|
|
|
|
allowCreate!: boolean
|
2024-01-04 17:54:58 +00:00
|
|
|
statusCategoriesFunc?: Resource<(project: ProjectType) => Ref<StatusCategory>[]>
|
2023-12-14 16:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Mixin(task.mixin.TaskTypeClass, core.class.Class)
|
|
|
|
export class TTaskTypeClass extends TClass implements TaskTypeClass {
|
|
|
|
taskType!: Ref<TaskType>
|
|
|
|
projectType!: Ref<ProjectType>
|
|
|
|
}
|
|
|
|
|
|
|
|
@Mixin(task.mixin.ProjectTypeClass, core.class.Class)
|
|
|
|
export class TProjectTypeClass extends TClass implements ProjectTypeClass {
|
|
|
|
projectType!: Ref<ProjectType>
|
|
|
|
}
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
@Model(task.class.Project, core.class.Space)
|
|
|
|
export class TProject extends TSpace implements Project {
|
2023-12-14 16:26:02 +00:00
|
|
|
@Prop(TypeRef(task.class.ProjectType), task.string.ProjectType)
|
|
|
|
type!: Ref<ProjectType>
|
2023-07-13 04:01:28 +00:00
|
|
|
}
|
2023-04-04 06:11:49 +00:00
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
@Model(task.class.ProjectType, core.class.Space)
|
|
|
|
export class TProjectType extends TSpace implements ProjectType {
|
|
|
|
shortDescription?: string
|
2023-12-14 16:26:02 +00:00
|
|
|
|
|
|
|
@Prop(TypeRef(task.class.ProjectTypeDescriptor), getEmbeddedLabel('Descriptor'))
|
|
|
|
descriptor!: Ref<ProjectTypeDescriptor>
|
|
|
|
|
|
|
|
@Prop(ArrOf(TypeRef(task.class.TaskType)), getEmbeddedLabel('Tasks'))
|
|
|
|
tasks!: Ref<TaskType>[]
|
|
|
|
|
|
|
|
@Prop(ArrOf(TypeRecord()), getEmbeddedLabel('Project statuses'))
|
|
|
|
statuses!: ProjectStatus[]
|
|
|
|
|
|
|
|
@Prop(TypeRef(core.class.Class), getEmbeddedLabel('Target Class'))
|
|
|
|
targetClass!: Ref<Class<Project>>
|
2023-12-29 07:05:27 +00:00
|
|
|
|
|
|
|
@Prop(TypeBoolean(), getEmbeddedLabel('Classic'))
|
|
|
|
classic!: boolean
|
2021-12-15 09:04:43 +00:00
|
|
|
}
|
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
@Model(task.class.TaskType, core.class.Doc, DOMAIN_TASK)
|
|
|
|
export class TTaskType extends TDoc implements TaskType {
|
|
|
|
@Prop(TypeString(), getEmbeddedLabel('Name'))
|
|
|
|
name!: string
|
|
|
|
|
|
|
|
@Prop(TypeRef(task.class.TaskTypeDescriptor), getEmbeddedLabel('Descriptor'))
|
|
|
|
descriptor!: Ref<TaskTypeDescriptor>
|
|
|
|
|
|
|
|
@Prop(TypeRef(task.class.ProjectType), getEmbeddedLabel('Task class'))
|
|
|
|
parent!: Ref<ProjectType> // Base class for task
|
|
|
|
|
|
|
|
@Prop(TypeString(), getEmbeddedLabel('Kind'))
|
|
|
|
kind!: TaskTypeKind
|
|
|
|
|
|
|
|
@Prop(ArrOf(TypeRef(task.class.TaskType)), getEmbeddedLabel('Parent'))
|
|
|
|
allowedAsChildOf!: Ref<TaskType>[] // In case of specified, task type is for sub-tasks
|
|
|
|
|
|
|
|
@Prop(TypeRef(core.class.Class), getEmbeddedLabel('Task class'))
|
|
|
|
ofClass!: Ref<Class<Task>> // Base class for task
|
|
|
|
|
|
|
|
@Prop(TypeRef(core.class.Class), getEmbeddedLabel('Task target class'))
|
|
|
|
targetClass!: Ref<Class<Task>> // Class or Mixin mixin to hold all user defined attributes.
|
|
|
|
|
|
|
|
@Prop(ArrOf(TypeRef(core.class.Status)), getEmbeddedLabel('Task statuses'))
|
|
|
|
statuses!: Ref<Status>[]
|
|
|
|
|
|
|
|
@Prop(TypeRef(core.class.Class), getEmbeddedLabel('Task status class'))
|
|
|
|
statusClass!: Ref<Class<Status>>
|
|
|
|
|
|
|
|
@Prop(TypeRef(core.class.StatusCategory), getEmbeddedLabel('Task status categories'))
|
|
|
|
statusCategories!: Ref<StatusCategory>[]
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.ProjectTypeDescriptor, core.class.Doc, DOMAIN_MODEL)
|
|
|
|
export class TProjectTypeDescriptor extends TDoc implements ProjectTypeDescriptor {
|
2023-10-27 05:22:43 +00:00
|
|
|
name!: IntlString
|
|
|
|
description!: IntlString
|
|
|
|
icon!: AnyComponent
|
|
|
|
editor?: AnyComponent
|
2023-12-14 16:26:02 +00:00
|
|
|
baseClass!: Ref<Class<Task>>
|
2021-12-15 09:04:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.Sequence, core.class.Doc, DOMAIN_KANBAN)
|
|
|
|
export class TSequence extends TDoc implements Sequence {
|
|
|
|
attachedTo!: Ref<Class<Doc>>
|
|
|
|
sequence!: number
|
2021-08-07 14:49:14 +00:00
|
|
|
}
|
|
|
|
|
2022-05-04 08:08:12 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const actionTemplates = template({
|
|
|
|
editStatus: {
|
|
|
|
label: task.string.EditStates,
|
|
|
|
icon: view.icon.Statuses,
|
|
|
|
action: task.actionImpl.EditStatuses,
|
|
|
|
input: 'focus',
|
|
|
|
category: task.category.Task
|
|
|
|
},
|
|
|
|
archiveSpace: {
|
|
|
|
label: task.string.Archive,
|
|
|
|
icon: view.icon.Archive,
|
|
|
|
action: view.actionImpl.UpdateDocument as ViewAction,
|
|
|
|
actionProps: {
|
|
|
|
key: 'archived',
|
|
|
|
value: true,
|
|
|
|
ask: true,
|
|
|
|
label: task.string.Archive,
|
|
|
|
message: task.string.ArchiveConfirm
|
|
|
|
},
|
2022-06-30 03:36:15 +00:00
|
|
|
input: 'any',
|
2022-05-04 08:08:12 +00:00
|
|
|
category: task.category.Task,
|
|
|
|
query: {
|
|
|
|
archived: false
|
|
|
|
},
|
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'tools'
|
2023-05-10 11:41:21 +00:00
|
|
|
},
|
|
|
|
override: [view.action.Archive, view.action.Delete]
|
2022-05-04 08:08:12 +00:00
|
|
|
},
|
|
|
|
unarchiveSpace: {
|
|
|
|
label: task.string.Unarchive,
|
|
|
|
icon: view.icon.Archive,
|
|
|
|
action: view.actionImpl.UpdateDocument as ViewAction,
|
|
|
|
actionProps: {
|
|
|
|
key: 'archived',
|
|
|
|
ask: true,
|
|
|
|
value: false,
|
|
|
|
label: task.string.Unarchive,
|
|
|
|
message: task.string.UnarchiveConfirm
|
|
|
|
},
|
2022-06-30 03:36:15 +00:00
|
|
|
input: 'any',
|
2022-05-04 08:08:12 +00:00
|
|
|
category: task.category.Task,
|
|
|
|
query: {
|
|
|
|
archived: true
|
|
|
|
},
|
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'tools'
|
2022-05-04 08:08:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-08-07 14:49:14 +00:00
|
|
|
export function createModel (builder: Builder): void {
|
2023-12-14 16:26:02 +00:00
|
|
|
builder.createModel(
|
|
|
|
TKanbanCard,
|
|
|
|
TSequence,
|
|
|
|
TTask,
|
|
|
|
TTodoItem,
|
|
|
|
TProject,
|
|
|
|
TProjectType,
|
|
|
|
TTaskType,
|
|
|
|
TProjectTypeDescriptor,
|
|
|
|
TTaskTypeDescriptor,
|
|
|
|
TTaskTypeClass,
|
|
|
|
TProjectTypeClass
|
|
|
|
)
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2021-12-21 09:36:50 +00:00
|
|
|
builder.createDoc(
|
|
|
|
view.class.ViewletDescriptor,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
2022-01-19 09:09:08 +00:00
|
|
|
label: task.string.States,
|
2022-11-09 11:24:02 +00:00
|
|
|
icon: task.icon.ManageTemplates,
|
2021-12-21 09:36:50 +00:00
|
|
|
component: task.component.StatusTableView
|
|
|
|
},
|
|
|
|
task.viewlet.StatusTable
|
|
|
|
)
|
|
|
|
|
2023-01-14 10:54:54 +00:00
|
|
|
builder.mixin(task.class.Task, core.class.Class, view.mixin.ObjectPresenter, {
|
2022-03-22 09:09:58 +00:00
|
|
|
presenter: view.component.ObjectPresenter
|
|
|
|
})
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(task.class.ProjectType, core.class.Class, view.mixin.ObjectPresenter, {
|
2022-11-09 11:24:02 +00:00
|
|
|
presenter: task.component.KanbanTemplatePresenter
|
|
|
|
})
|
|
|
|
|
2022-01-18 10:21:32 +00:00
|
|
|
builder.mixin(task.class.Task, core.class.Class, view.mixin.ObjectEditorHeader, {
|
|
|
|
editor: task.component.TaskHeader
|
|
|
|
})
|
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
builder.mixin(task.class.ProjectType, core.class.Class, view.mixin.IgnoreActions, {
|
|
|
|
actions: [view.action.Open]
|
|
|
|
})
|
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
2022-05-04 08:08:12 +00:00
|
|
|
view.class.ActionCategory,
|
2021-12-17 09:04:49 +00:00
|
|
|
core.space.Model,
|
2022-05-04 08:08:12 +00:00
|
|
|
{ label: task.string.Task, visible: true },
|
|
|
|
task.category.Task
|
2021-12-17 09:04:49 +00:00
|
|
|
)
|
|
|
|
|
2022-05-04 08:08:12 +00:00
|
|
|
createAction(
|
|
|
|
builder,
|
2021-12-17 09:04:49 +00:00
|
|
|
{
|
2022-05-04 08:08:12 +00:00
|
|
|
...actionTemplates.editStatus,
|
2023-10-27 05:22:43 +00:00
|
|
|
target: task.class.Project,
|
2022-05-04 08:08:12 +00:00
|
|
|
query: {
|
|
|
|
archived: false
|
|
|
|
},
|
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'edit'
|
2022-05-04 08:08:12 +00:00
|
|
|
}
|
2021-12-17 09:04:49 +00:00
|
|
|
},
|
|
|
|
task.action.EditStatuses
|
|
|
|
)
|
2021-12-15 09:04:43 +00:00
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.AttributeEditor, {
|
2022-06-15 17:25:58 +00:00
|
|
|
inlineEditor: task.component.StateEditor
|
2021-12-15 09:04:43 +00:00
|
|
|
})
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.ObjectPresenter, {
|
2021-12-15 09:04:43 +00:00
|
|
|
presenter: task.component.StatePresenter
|
|
|
|
})
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.AttributePresenter, {
|
2023-01-14 10:54:54 +00:00
|
|
|
presenter: task.component.StateRefPresenter
|
|
|
|
})
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.IgnoreActions, {
|
2022-06-15 09:44:27 +00:00
|
|
|
actions: [view.action.Delete]
|
|
|
|
})
|
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
|
|
|
view.class.ViewletDescriptor,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
2022-01-19 09:09:08 +00:00
|
|
|
label: task.string.Kanban,
|
2021-12-17 09:04:49 +00:00
|
|
|
icon: task.icon.Kanban,
|
|
|
|
component: task.component.KanbanView
|
|
|
|
},
|
|
|
|
task.viewlet.Kanban
|
|
|
|
)
|
|
|
|
|
2022-07-05 05:38:19 +00:00
|
|
|
builder.createDoc(
|
|
|
|
view.class.ViewletDescriptor,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
label: task.string.Dashboard,
|
|
|
|
icon: task.icon.Dashboard,
|
|
|
|
component: task.component.Dashboard
|
|
|
|
},
|
|
|
|
task.viewlet.Dashboard
|
|
|
|
)
|
|
|
|
|
2022-05-06 17:48:43 +00:00
|
|
|
builder.mixin(task.class.TodoItem, core.class.Class, view.mixin.CollectionEditor, {
|
2021-12-20 10:18:29 +00:00
|
|
|
editor: task.component.Todos
|
|
|
|
})
|
|
|
|
|
2023-01-14 10:54:54 +00:00
|
|
|
builder.mixin(task.class.TodoItem, core.class.Class, view.mixin.ObjectPresenter, {
|
2021-12-20 10:18:29 +00:00
|
|
|
presenter: task.component.TodoItemPresenter
|
|
|
|
})
|
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
builder.mixin(task.class.TaskType, core.class.Class, view.mixin.ObjectPresenter, {
|
|
|
|
presenter: task.component.TaskTypePresenter
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.ProjectType, core.class.Class, view.mixin.ObjectPresenter, {
|
|
|
|
presenter: task.component.ProjectTypePresenter
|
|
|
|
})
|
|
|
|
|
|
|
|
classPresenter(builder, task.class.TaskType, task.component.TaskTypePresenter, task.component.TaskTypePresenter)
|
|
|
|
|
2022-05-04 08:08:12 +00:00
|
|
|
createAction(builder, {
|
|
|
|
label: task.string.MarkAsDone,
|
|
|
|
icon: task.icon.TodoCheck,
|
|
|
|
action: view.actionImpl.UpdateDocument,
|
|
|
|
actionProps: {
|
|
|
|
key: 'done',
|
|
|
|
value: true
|
2021-12-20 10:18:29 +00:00
|
|
|
},
|
2022-05-04 08:08:12 +00:00
|
|
|
input: 'focus',
|
|
|
|
category: task.category.Task,
|
2021-12-20 10:18:29 +00:00
|
|
|
query: {
|
|
|
|
done: false
|
2022-04-19 09:38:31 +00:00
|
|
|
},
|
2022-05-04 08:08:12 +00:00
|
|
|
target: task.class.TodoItem,
|
2022-04-19 09:38:31 +00:00
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'edit'
|
2021-12-20 10:18:29 +00:00
|
|
|
}
|
|
|
|
})
|
2022-05-04 08:08:12 +00:00
|
|
|
|
|
|
|
createAction(builder, {
|
|
|
|
label: task.string.MarkAsUndone,
|
|
|
|
icon: task.icon.TodoUnCheck,
|
|
|
|
action: view.actionImpl.UpdateDocument,
|
|
|
|
actionProps: {
|
|
|
|
key: 'done',
|
|
|
|
value: false
|
|
|
|
},
|
|
|
|
input: 'focus',
|
|
|
|
category: task.category.Task,
|
2021-12-20 10:18:29 +00:00
|
|
|
query: {
|
|
|
|
done: true
|
2022-04-19 09:38:31 +00:00
|
|
|
},
|
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'edit'
|
2022-05-04 08:08:12 +00:00
|
|
|
},
|
|
|
|
target: task.class.TodoItem
|
2021-12-20 10:18:29 +00:00
|
|
|
})
|
2021-12-07 18:45:11 +00:00
|
|
|
|
2022-05-17 08:36:11 +00:00
|
|
|
createAction(
|
|
|
|
builder,
|
|
|
|
{
|
|
|
|
...viewTemplates.move,
|
|
|
|
target: task.class.Task,
|
|
|
|
context: {
|
2022-06-24 12:36:08 +00:00
|
|
|
mode: ['context', 'browser'],
|
|
|
|
group: 'tools'
|
2022-05-17 08:36:11 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
task.action.Move
|
|
|
|
)
|
2022-05-20 19:41:26 +00:00
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.createDoc(
|
|
|
|
core.class.StatusCategory,
|
|
|
|
core.space.Model,
|
2022-05-20 19:41:26 +00:00
|
|
|
{
|
2023-10-27 05:22:43 +00:00
|
|
|
ofAttribute: task.attribute.State,
|
2023-12-14 16:26:02 +00:00
|
|
|
label: task.string.StateBacklog,
|
|
|
|
icon: task.icon.TaskState,
|
2023-12-20 06:29:31 +00:00
|
|
|
color: PaletteColorIndexes.Cloud,
|
2023-12-14 16:26:02 +00:00
|
|
|
defaultStatusName: 'Backlog',
|
|
|
|
order: 0
|
|
|
|
},
|
|
|
|
task.statusCategory.UnStarted
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
core.class.StatusCategory,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
ofAttribute: task.attribute.State,
|
2024-01-04 17:54:58 +00:00
|
|
|
label: task.string.StateUnstarted,
|
2023-10-27 05:22:43 +00:00
|
|
|
icon: task.icon.TaskState,
|
2023-12-20 06:29:31 +00:00
|
|
|
color: PaletteColorIndexes.Porpoise,
|
2024-01-04 17:54:58 +00:00
|
|
|
defaultStatusName: 'Todo',
|
2023-12-29 07:05:27 +00:00
|
|
|
order: 1
|
2023-10-27 05:22:43 +00:00
|
|
|
},
|
2024-01-04 17:54:58 +00:00
|
|
|
task.statusCategory.ToDo
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
core.class.StatusCategory,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
ofAttribute: task.attribute.State,
|
|
|
|
label: task.string.StateActive,
|
|
|
|
icon: task.icon.TaskState,
|
|
|
|
color: PaletteColorIndexes.Cerulean,
|
|
|
|
defaultStatusName: 'New state',
|
|
|
|
order: 2
|
|
|
|
},
|
2023-10-27 05:22:43 +00:00
|
|
|
task.statusCategory.Active
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
core.class.StatusCategory,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
ofAttribute: task.attribute.State,
|
|
|
|
label: task.string.DoneStatesWon,
|
|
|
|
icon: task.icon.TaskState,
|
2023-12-20 06:29:31 +00:00
|
|
|
color: PaletteColorIndexes.Grass,
|
2023-10-27 05:22:43 +00:00
|
|
|
defaultStatusName: 'Won',
|
2024-01-04 17:54:58 +00:00
|
|
|
order: 3
|
2023-10-27 05:22:43 +00:00
|
|
|
},
|
|
|
|
task.statusCategory.Won
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
core.class.StatusCategory,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
ofAttribute: task.attribute.State,
|
|
|
|
label: task.string.DoneStatesLost,
|
|
|
|
icon: task.icon.TaskState,
|
2023-12-20 06:29:31 +00:00
|
|
|
color: PaletteColorIndexes.Coin,
|
2023-10-27 05:22:43 +00:00
|
|
|
defaultStatusName: 'Lost',
|
2024-01-04 17:54:58 +00:00
|
|
|
order: 4
|
2022-05-20 19:41:26 +00:00
|
|
|
},
|
2023-10-27 05:22:43 +00:00
|
|
|
task.statusCategory.Lost
|
2022-05-20 19:41:26 +00:00
|
|
|
)
|
2022-09-16 02:57:32 +00:00
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.SortFuncs, {
|
2023-09-19 19:43:18 +00:00
|
|
|
func: task.function.StatusSort
|
|
|
|
})
|
|
|
|
|
2023-11-03 15:31:19 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.AttributeFilter, {
|
|
|
|
component: task.component.StatusFilter
|
|
|
|
})
|
|
|
|
|
2023-10-27 05:22:43 +00:00
|
|
|
builder.mixin(core.class.Status, core.class.Class, view.mixin.AllValuesFunc, {
|
2023-09-19 19:43:18 +00:00
|
|
|
func: task.function.GetAllStates
|
|
|
|
})
|
|
|
|
|
2023-04-25 08:34:38 +00:00
|
|
|
// builder.createDoc(
|
|
|
|
// notification.class.NotificationType,
|
|
|
|
// core.space.Model,
|
|
|
|
// {
|
|
|
|
// label: task.string.Assigned,
|
|
|
|
// hidden: false,
|
|
|
|
// textTemplate: '{doc} was assigned to you by {sender}',
|
|
|
|
// htmlTemplate: '<p>{doc} was assigned to you by {sender}</p>',
|
|
|
|
// subjectTemplate: '{doc} was assigned to you'
|
|
|
|
// },
|
|
|
|
// task.ids.AssigneedNotification
|
|
|
|
// )
|
2023-12-14 16:26:02 +00:00
|
|
|
|
|
|
|
builder.mixin(task.mixin.TaskTypeClass, core.class.Class, view.mixin.ObjectPresenter, {
|
|
|
|
presenter: task.component.TaskTypeClassPresenter
|
|
|
|
})
|
|
|
|
builder.mixin(task.mixin.ProjectTypeClass, core.class.Class, view.mixin.ObjectPresenter, {
|
|
|
|
presenter: task.component.ProjectTypeClassPresenter
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.Task, core.class.Class, setting.mixin.Editable, {
|
|
|
|
value: true
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.Project, core.class.Class, setting.mixin.Editable, {
|
|
|
|
value: true
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
setting.class.SettingsCategory,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
name: 'statuses',
|
|
|
|
label: task.string.ManageProjects,
|
|
|
|
icon: task.icon.ManageTemplates,
|
|
|
|
component: task.component.ManageProjectsContent,
|
|
|
|
extraComponents: {
|
|
|
|
navigation: task.component.ManageProjects,
|
|
|
|
tools: task.component.ManageProjectsTools
|
|
|
|
},
|
|
|
|
group: 'settings-editor',
|
|
|
|
secured: false,
|
|
|
|
order: 6000,
|
|
|
|
expandable: true
|
|
|
|
},
|
|
|
|
task.ids.ManageProjects
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
2023-12-20 06:29:31 +00:00
|
|
|
export type FixTaskData = Omit<Data<TaskType>, 'space' | 'statuses' | 'statusCategories' | 'parent'> & {
|
|
|
|
_id?: TaskType['_id']
|
|
|
|
statusCategories: TaskType['statusCategories'] | TaskStatusFactory[]
|
|
|
|
}
|
2023-12-14 16:26:02 +00:00
|
|
|
export interface FixTaskResult {
|
|
|
|
taskTypes: TaskType[]
|
|
|
|
projectTypes: ProjectType[]
|
|
|
|
projects: Project[]
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export async function fixTaskTypes (
|
|
|
|
client: MigrationClient,
|
|
|
|
descriptor: Ref<ProjectTypeDescriptor>,
|
2024-01-08 14:19:23 +00:00
|
|
|
dataFactory: (t: ProjectType) => Promise<FixTaskData[]>,
|
|
|
|
migrateTasks?: (projects: Project[], taskType: TaskType) => Promise<void>
|
2023-12-14 16:26:02 +00:00
|
|
|
): Promise<FixTaskResult> {
|
|
|
|
const categoryObj = client.model.findObject(descriptor)
|
|
|
|
if (categoryObj === undefined) {
|
|
|
|
throw new Error('category is not found in model')
|
|
|
|
}
|
|
|
|
|
|
|
|
const projectTypes = await client.find<ProjectType>(DOMAIN_SPACE, {
|
|
|
|
_class: task.class.ProjectType,
|
|
|
|
descriptor
|
|
|
|
})
|
|
|
|
const baseClassClass = client.hierarchy.getClass(categoryObj.baseClass)
|
|
|
|
|
|
|
|
const resultTaskTypes: TaskType[] = []
|
|
|
|
const resultProjects: Project[] = []
|
|
|
|
|
|
|
|
for (const t of projectTypes) {
|
|
|
|
t.tasks = [...(t.tasks ?? [])]
|
|
|
|
if (t.targetClass === undefined) {
|
|
|
|
const targetProjectClassId: Ref<Class<Doc>> = generateId()
|
|
|
|
t.targetClass = targetProjectClassId
|
|
|
|
|
|
|
|
await client.create<TxCreateDoc<Doc>>(DOMAIN_TX, {
|
|
|
|
_id: generateId(),
|
|
|
|
objectId: targetProjectClassId,
|
|
|
|
_class: core.class.TxCreateDoc,
|
|
|
|
objectClass: core.class.Class,
|
|
|
|
objectSpace: core.space.Model,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
space: core.space.Model,
|
|
|
|
attributes: {
|
|
|
|
extends: categoryObj.baseClass,
|
|
|
|
kind: ClassifierKind.MIXIN,
|
|
|
|
label: baseClassClass.label,
|
|
|
|
icon: baseClassClass.icon
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
await client.create<TxMixin<Class<ProjectType>, ProjectTypeClass>>(DOMAIN_TX, {
|
|
|
|
_class: core.class.TxMixin,
|
|
|
|
_id: generateId(),
|
|
|
|
space: core.space.Model,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
objectId: targetProjectClassId,
|
|
|
|
objectClass: core.class.Class,
|
|
|
|
objectSpace: core.space.Model,
|
|
|
|
mixin: task.mixin.ProjectTypeClass,
|
|
|
|
attributes: {
|
|
|
|
projectType: t._id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
await client.update(
|
|
|
|
DOMAIN_SPACE,
|
|
|
|
{
|
|
|
|
_id: t._id
|
|
|
|
},
|
|
|
|
{ $set: { targetClass: targetProjectClassId } }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-01-08 14:19:23 +00:00
|
|
|
const newTaskTypes = await dataFactory(t)
|
2023-12-14 16:26:02 +00:00
|
|
|
|
|
|
|
const projects = await client.find<Project>(DOMAIN_SPACE, { type: t._id })
|
|
|
|
resultProjects.push(...projects)
|
|
|
|
|
2024-01-08 14:19:23 +00:00
|
|
|
for (const data of newTaskTypes) {
|
|
|
|
// Check and skip if already had task type for same class
|
|
|
|
const tt = await client.find<TaskType>(DOMAIN_TASK, {
|
|
|
|
_class: task.class.TaskType,
|
|
|
|
ofClass: data.ofClass,
|
|
|
|
parent: t._id
|
|
|
|
})
|
|
|
|
if (tt.length > 0) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-12-14 16:26:02 +00:00
|
|
|
const taskTypeId: Ref<TaskType> = data._id ?? generateId()
|
|
|
|
const descr = client.model.getObject(data.descriptor)
|
|
|
|
|
|
|
|
const statuses = await client.find<Status>(DOMAIN_STATUS, {
|
|
|
|
_id: { $in: t.statuses.map((it) => it._id) },
|
|
|
|
_class: data.statusClass
|
|
|
|
})
|
|
|
|
|
2024-01-08 14:19:23 +00:00
|
|
|
const dStatuses: Ref<Status>[] = []
|
2023-12-14 16:26:02 +00:00
|
|
|
const statusAttr = findStatusAttr(client.hierarchy, data.ofClass)
|
|
|
|
// Ensure we have at leas't one item in every category.
|
|
|
|
for (const c of data.statusCategories) {
|
2023-12-20 06:29:31 +00:00
|
|
|
const category = typeof c === 'string' ? c : c.category
|
|
|
|
const cat = await client.model.findOne(core.class.StatusCategory, { _id: category })
|
|
|
|
|
2024-01-08 14:19:23 +00:00
|
|
|
const st = statuses.filter((it) => it.category === category)
|
2023-12-20 06:29:31 +00:00
|
|
|
const newStatuses: Ref<Status>[] = []
|
2024-01-08 14:19:23 +00:00
|
|
|
if (st.length === 0 || typeof c === 'object') {
|
2023-12-20 06:29:31 +00:00
|
|
|
if (typeof c === 'string') {
|
|
|
|
// We need to add new status into missing category
|
|
|
|
const statusId: Ref<Status> = generateId()
|
|
|
|
await client.create<Status>(DOMAIN_STATUS, {
|
|
|
|
_id: statusId,
|
|
|
|
_class: data.statusClass,
|
|
|
|
category,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
name: cat?.defaultStatusName ?? 'New state',
|
|
|
|
space: task.space.Statuses,
|
|
|
|
ofAttribute: statusAttr._id
|
|
|
|
})
|
|
|
|
newStatuses.push(statusId)
|
|
|
|
dStatuses.push(statusId)
|
|
|
|
|
|
|
|
await client.update(
|
|
|
|
DOMAIN_SPACE,
|
|
|
|
{
|
|
|
|
_id: t._id
|
|
|
|
},
|
|
|
|
{ $push: { statuses: newStatuses.map((it) => ({ _id: it })) } }
|
|
|
|
)
|
|
|
|
t.statuses.push(...newStatuses.map((it) => ({ _id: it, taskType: taskTypeId })))
|
|
|
|
} else {
|
|
|
|
for (const sts of c.statuses) {
|
|
|
|
const stsName = Array.isArray(sts) ? sts[0] : sts
|
|
|
|
const color = Array.isArray(sts) ? sts[1] : undefined
|
|
|
|
const st = statuses.find((it) => it.name.toLowerCase() === stsName.toLowerCase())
|
|
|
|
if (st === undefined) {
|
|
|
|
// We need to add new status into missing category
|
|
|
|
const statusId: Ref<Status> = generateId()
|
|
|
|
await client.create<Status>(DOMAIN_STATUS, {
|
|
|
|
_id: statusId,
|
|
|
|
_class: data.statusClass,
|
|
|
|
category,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
name: stsName,
|
|
|
|
color,
|
|
|
|
space: task.space.Statuses,
|
|
|
|
ofAttribute: statusAttr._id
|
|
|
|
})
|
|
|
|
newStatuses.push(statusId)
|
|
|
|
dStatuses.push(statusId)
|
2024-01-08 14:19:23 +00:00
|
|
|
} else {
|
|
|
|
dStatuses.push(st._id)
|
2023-12-20 06:29:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await client.update(
|
|
|
|
DOMAIN_SPACE,
|
|
|
|
{
|
|
|
|
_id: t._id
|
|
|
|
},
|
|
|
|
{ $push: { statuses: newStatuses.map((it) => ({ _id: it })) } }
|
|
|
|
)
|
|
|
|
t.statuses.push(...newStatuses.map((it) => ({ _id: it, taskType: taskTypeId })))
|
|
|
|
}
|
|
|
|
}
|
2024-01-08 14:19:23 +00:00
|
|
|
} else {
|
|
|
|
for (const sss of st.map((it) => it._id)) {
|
|
|
|
if (!dStatuses.includes(sss)) {
|
|
|
|
dStatuses.push(sss)
|
|
|
|
}
|
|
|
|
}
|
2023-12-14 16:26:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const taskType: TaskType = {
|
|
|
|
...data,
|
2023-12-20 06:29:31 +00:00
|
|
|
statusCategories: data.statusCategories.map((it) => (typeof it === 'string' ? it : it.category)),
|
2023-12-14 16:26:02 +00:00
|
|
|
parent: t._id,
|
|
|
|
_id: taskTypeId,
|
|
|
|
_class: task.class.TaskType,
|
|
|
|
space: t._id,
|
|
|
|
statuses: dStatuses,
|
|
|
|
modifiedBy: core.account.System,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
kind: 'both',
|
|
|
|
icon: data.icon ?? descr.icon
|
|
|
|
}
|
|
|
|
|
|
|
|
const ofClassClass = client.hierarchy.getClass(data.ofClass)
|
|
|
|
|
|
|
|
taskType.icon = ofClassClass.icon
|
|
|
|
|
|
|
|
// Create target class for custom field.
|
|
|
|
const targetClassId: Ref<Class<Doc>> = generateId()
|
|
|
|
taskType.targetClass = targetClassId
|
|
|
|
|
|
|
|
await client.create<TxCreateDoc<Doc>>(DOMAIN_TX, {
|
|
|
|
_id: generateId(),
|
|
|
|
objectId: targetClassId,
|
|
|
|
_class: core.class.TxCreateDoc,
|
|
|
|
objectClass: core.class.Class,
|
|
|
|
objectSpace: core.space.Model,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
space: core.space.Model,
|
|
|
|
attributes: {
|
|
|
|
extends: data.ofClass,
|
|
|
|
kind: ClassifierKind.MIXIN,
|
|
|
|
label: getEmbeddedLabel(data.name),
|
|
|
|
icon: ofClassClass.icon
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
await client.create<TxMixin<Class<TaskType>, TaskTypeClass>>(DOMAIN_TX, {
|
|
|
|
_class: core.class.TxMixin,
|
|
|
|
_id: generateId(),
|
|
|
|
space: core.space.Model,
|
|
|
|
modifiedBy: core.account.ConfigUser,
|
|
|
|
modifiedOn: Date.now(),
|
|
|
|
objectId: targetClassId,
|
|
|
|
objectClass: core.class.Class,
|
|
|
|
objectSpace: core.space.Model,
|
|
|
|
mixin: task.mixin.TaskTypeClass,
|
|
|
|
attributes: {
|
|
|
|
taskType: taskTypeId,
|
|
|
|
projectType: t._id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
await client.create(DOMAIN_TASK, taskType)
|
|
|
|
resultTaskTypes.push(taskType)
|
|
|
|
|
|
|
|
await client.update(
|
|
|
|
DOMAIN_SPACE,
|
|
|
|
{
|
|
|
|
_id: t._id
|
|
|
|
},
|
|
|
|
{ $push: { tasks: taskTypeId } }
|
|
|
|
)
|
|
|
|
t.tasks.push(taskTypeId)
|
|
|
|
// Update kind and target classId
|
2024-01-08 14:19:23 +00:00
|
|
|
const projectsToUpdate = projects.filter((it) => it.type === t._id)
|
2023-12-14 16:26:02 +00:00
|
|
|
await client.update(
|
|
|
|
DOMAIN_TASK,
|
2024-01-08 14:19:23 +00:00
|
|
|
{ space: { $in: projectsToUpdate.map((it) => it._id) }, _class: data.ofClass },
|
2023-12-14 16:26:02 +00:00
|
|
|
{ $set: { kind: taskTypeId } }
|
|
|
|
)
|
2024-01-08 14:19:23 +00:00
|
|
|
await migrateTasks?.(projectsToUpdate, taskType)
|
2023-12-14 16:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to fix project statuses field, for proper icon calculation.
|
|
|
|
}
|
|
|
|
for (const t of projectTypes) {
|
|
|
|
const ttypes = await client.find<TaskType>(DOMAIN_TASK, { _id: { $in: t.tasks } })
|
|
|
|
const newStatuses = calculateStatuses(t, new Map(ttypes.map((it) => [it._id, it])), [])
|
|
|
|
await client.update(
|
|
|
|
DOMAIN_SPACE,
|
|
|
|
{ _id: t._id },
|
|
|
|
{
|
|
|
|
$set: {
|
|
|
|
statuses: newStatuses
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return { taskTypes: resultTaskTypes, projectTypes, projects: resultProjects }
|
2022-01-21 09:05:55 +00:00
|
|
|
}
|