2021-08-07 14:49:14 +00:00
|
|
|
//
|
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2021-12-06 10:07:08 +00:00
|
|
|
import attachment from '@anticrm/model-attachment'
|
2021-08-07 14:49:14 +00:00
|
|
|
import type { Employee } from '@anticrm/contact'
|
2021-11-30 15:39:08 +00:00
|
|
|
import contact from '@anticrm/contact'
|
2021-12-02 13:12:16 +00:00
|
|
|
import type { Doc, DocWithState, Domain, FindOptions, Ref } from '@anticrm/core'
|
2021-12-03 10:16:16 +00:00
|
|
|
import { Builder, Model, Prop, TypeRef, TypeString, UX } from '@anticrm/model'
|
2021-11-30 15:39:08 +00:00
|
|
|
import chunter from '@anticrm/model-chunter'
|
2021-12-02 13:12:16 +00:00
|
|
|
import core, { TDoc, TSpaceWithStates } from '@anticrm/model-core'
|
2021-08-07 14:49:14 +00:00
|
|
|
import view from '@anticrm/model-view'
|
2021-11-30 15:39:08 +00:00
|
|
|
import workbench from '@anticrm/model-workbench'
|
|
|
|
import type { IntlString } from '@anticrm/platform'
|
|
|
|
import type { Project, Task } from '@anticrm/task'
|
2021-12-03 05:49:00 +00:00
|
|
|
import { createProjectKanban } from '@anticrm/task'
|
2021-08-07 14:49:14 +00:00
|
|
|
import task from './plugin'
|
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
@Model(task.class.Project, core.class.SpaceWithStates)
|
2021-08-07 14:49:14 +00:00
|
|
|
@UX('Project' as IntlString, task.icon.Task)
|
2021-12-02 13:12:16 +00:00
|
|
|
export class TProject extends TSpaceWithStates implements Project {}
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
@Model(task.class.Task, core.class.Doc, 'task' as Domain, [core.interface.DocWithState])
|
2021-11-30 15:39:08 +00:00
|
|
|
@UX('Task' as IntlString, task.icon.Task, 'TASK' as IntlString)
|
2021-08-07 14:49:14 +00:00
|
|
|
export class TTask extends TDoc implements Task {
|
2021-12-02 13:12:16 +00:00
|
|
|
declare number: DocWithState['number']
|
|
|
|
declare state: DocWithState['state']
|
2021-11-30 15:39:08 +00:00
|
|
|
|
|
|
|
@Prop(TypeString(), 'Name' as IntlString)
|
|
|
|
name!: string
|
2021-08-07 14:49:14 +00:00
|
|
|
|
|
|
|
@Prop(TypeString(), 'Description' as IntlString)
|
|
|
|
description!: string
|
|
|
|
|
2021-12-03 10:16:16 +00:00
|
|
|
@Prop(TypeRef(contact.class.Employee), 'Assignee' as IntlString)
|
|
|
|
assignee!: Ref<Employee> | null
|
2021-11-30 15:39:08 +00:00
|
|
|
|
|
|
|
@Prop(TypeString(), 'Comments' as IntlString)
|
|
|
|
comments!: number
|
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
@Prop(TypeString(), 'Attachments' as IntlString)
|
|
|
|
attachments!: number
|
|
|
|
|
2021-11-30 15:39:08 +00:00
|
|
|
@Prop(TypeString(), 'Labels' as IntlString)
|
|
|
|
labels!: string
|
2021-08-07 14:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function createModel (builder: Builder): void {
|
|
|
|
builder.createModel(TProject, TTask)
|
|
|
|
builder.mixin(task.class.Project, core.class.Class, workbench.mixin.SpaceView, {
|
|
|
|
view: {
|
|
|
|
class: task.class.Task,
|
|
|
|
createItemDialog: task.component.CreateTask
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.createDoc(workbench.class.Application, core.space.Model, {
|
|
|
|
label: task.string.ApplicationLabelTask,
|
|
|
|
icon: task.icon.Task,
|
2021-11-22 12:06:14 +00:00
|
|
|
hidden: false,
|
2021-08-07 14:49:14 +00:00
|
|
|
navigatorModel: {
|
|
|
|
spaces: [
|
|
|
|
{
|
|
|
|
label: task.string.Projects,
|
|
|
|
spaceClass: task.class.Project,
|
|
|
|
addSpaceLabel: task.string.CreateProject,
|
2021-11-03 14:57:55 +00:00
|
|
|
createComponent: task.component.CreateProject
|
2021-08-07 14:49:14 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-11-30 15:39:08 +00:00
|
|
|
}, task.app.Tasks)
|
|
|
|
|
|
|
|
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
|
|
|
attachTo: task.class.Task,
|
|
|
|
descriptor: view.viewlet.Table,
|
|
|
|
open: task.component.EditTask,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
|
|
options: {
|
|
|
|
lookup: {
|
|
|
|
assignee: contact.class.Employee
|
|
|
|
}
|
|
|
|
} as FindOptions<Doc>,
|
|
|
|
config: [
|
|
|
|
'',
|
|
|
|
'name',
|
|
|
|
'$lookup.assignee',
|
2021-12-06 10:07:08 +00:00
|
|
|
{ presenter: attachment.component.AttachmentsPresenter, label: 'Files' },
|
2021-11-30 15:39:08 +00:00
|
|
|
{ presenter: chunter.component.CommentsPresenter, label: 'Comments' },
|
|
|
|
'modifiedOn'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.Task, core.class.Class, view.mixin.AttributePresenter, {
|
|
|
|
presenter: task.component.TaskPresenter
|
2021-08-07 14:49:14 +00:00
|
|
|
})
|
2021-11-30 15:39:08 +00:00
|
|
|
|
|
|
|
builder.mixin(task.class.Task, core.class.Class, view.mixin.ObjectEditor, {
|
|
|
|
editor: task.component.EditTask
|
|
|
|
})
|
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
builder.createDoc(view.class.Sequence, view.space.Sequence, {
|
|
|
|
attachedTo: task.class.Task,
|
|
|
|
sequence: 0
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
|
|
|
attachTo: task.class.Task,
|
|
|
|
descriptor: view.viewlet.Kanban,
|
|
|
|
open: task.component.EditTask,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
|
|
options: {
|
|
|
|
lookup: {
|
2021-12-07 09:08:56 +00:00
|
|
|
assignee: contact.class.Employee,
|
2021-12-02 13:12:16 +00:00
|
|
|
state: core.class.State
|
|
|
|
}
|
|
|
|
} as FindOptions<Doc>, // TODO: fix
|
|
|
|
config: ['$lookup.attachedTo', '$lookup.state']
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.Task, core.class.Class, view.mixin.KanbanCard, {
|
|
|
|
card: task.component.KanbanCard
|
|
|
|
})
|
|
|
|
|
2021-08-07 14:49:14 +00:00
|
|
|
builder.createDoc(task.class.Project, core.space.Model, {
|
2021-11-30 15:39:08 +00:00
|
|
|
name: 'public',
|
|
|
|
description: 'Public tasks',
|
2021-08-07 14:49:14 +00:00
|
|
|
private: false,
|
|
|
|
members: []
|
2021-11-30 15:39:08 +00:00
|
|
|
}, task.space.TasksPublic)
|
|
|
|
|
2021-12-02 13:12:16 +00:00
|
|
|
createProjectKanban(task.space.TasksPublic, async (_class, space, data, id) => {
|
|
|
|
builder.createDoc(_class, space, data, id)
|
|
|
|
return await Promise.resolve()
|
|
|
|
}).catch((err) => console.error(err))
|
2021-08-07 14:49:14 +00:00
|
|
|
}
|
2021-12-07 18:45:11 +00:00
|
|
|
|
|
|
|
export { taskOperation } from './migration'
|