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-14 09:24:14 +00:00
|
|
|
// To help typescript locate view plugin properly
|
|
|
|
import type {} from '@anticrm/view'
|
|
|
|
|
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-15 09:04:43 +00:00
|
|
|
import { Arr, Class, Doc, Domain, DOMAIN_MODEL, FindOptions, Ref, Space } from '@anticrm/core'
|
|
|
|
import { Builder, Collection, Mixin, Model, Prop, TypeRef, TypeString, UX } from '@anticrm/model'
|
2021-11-30 15:39:08 +00:00
|
|
|
import chunter from '@anticrm/model-chunter'
|
2021-12-15 09:04:43 +00:00
|
|
|
import core, { TAttachedDoc, TClass, TDoc, TSpace } 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'
|
2021-12-17 09:04:49 +00:00
|
|
|
import type {
|
|
|
|
Kanban,
|
|
|
|
KanbanCard,
|
|
|
|
Project,
|
|
|
|
State,
|
|
|
|
Issue,
|
|
|
|
Sequence,
|
|
|
|
DoneState,
|
|
|
|
WonState,
|
|
|
|
LostState,
|
|
|
|
KanbanTemplateSpace,
|
|
|
|
StateTemplate,
|
|
|
|
DoneStateTemplate,
|
|
|
|
WonStateTemplate,
|
|
|
|
LostStateTemplate,
|
|
|
|
KanbanTemplate,
|
|
|
|
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-15 09:04:43 +00:00
|
|
|
import { AnyComponent } from '@anticrm/ui'
|
2021-08-07 14:49:14 +00:00
|
|
|
|
2021-12-15 09:04:43 +00:00
|
|
|
export { default } from './plugin'
|
|
|
|
|
|
|
|
export const DOMAIN_TASK = 'task' as Domain
|
|
|
|
export const DOMAIN_STATE = 'state' as Domain
|
|
|
|
export const DOMAIN_KANBAN = 'kanban' as Domain
|
|
|
|
@Model(task.class.State, core.class.Doc, DOMAIN_STATE)
|
|
|
|
export class TState extends TDoc implements State {
|
|
|
|
@Prop(TypeString(), 'Title' as IntlString)
|
|
|
|
title!: string
|
|
|
|
|
|
|
|
color!: string
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.DoneState, core.class.Doc, DOMAIN_STATE)
|
|
|
|
export class TDoneState extends TDoc implements DoneState {
|
|
|
|
@Prop(TypeString(), 'Title' as IntlString)
|
|
|
|
title!: string
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.WonState, task.class.DoneState, DOMAIN_STATE)
|
|
|
|
export class TWonState extends TDoneState implements WonState {}
|
|
|
|
|
|
|
|
@Model(task.class.LostState, task.class.DoneState, DOMAIN_STATE)
|
|
|
|
export class TLostState extends TDoneState implements LostState {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*
|
|
|
|
* No domain is specified, since pure Tasks could not exists
|
|
|
|
*/
|
|
|
|
@Model(task.class.Task, core.class.AttachedDoc, DOMAIN_TASK)
|
|
|
|
export class TTask extends TAttachedDoc implements Task {
|
|
|
|
@Prop(TypeRef(task.class.State), 'State' as IntlString)
|
|
|
|
state!: Ref<State>
|
|
|
|
|
|
|
|
@Prop(TypeRef(task.class.DoneState), 'Done Status' as IntlString)
|
|
|
|
doneState!: Ref<DoneState> | null
|
|
|
|
|
|
|
|
@Prop(TypeString(), 'No.' as IntlString)
|
|
|
|
number!: number
|
|
|
|
|
|
|
|
// @Prop(TypeRef(contact.class.Employee), 'Assignee' as IntlString)
|
|
|
|
assignee!: Ref<Employee> | null
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.SpaceWithStates, core.class.Space)
|
2021-12-17 09:04:49 +00:00
|
|
|
export class TSpaceWithStates extends TSpace {}
|
2021-12-15 09:04:43 +00:00
|
|
|
|
|
|
|
@Model(task.class.Project, task.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-15 09:04:43 +00:00
|
|
|
@Model(task.class.Issue, task.class.Task, DOMAIN_TASK)
|
|
|
|
@UX('Task' as IntlString, task.icon.Task, 'Task' as IntlString)
|
|
|
|
export class TIssue extends TTask implements Issue {
|
|
|
|
// We need to declare, to provide property with label
|
|
|
|
@Prop(TypeRef(core.class.Doc), 'Parent' as IntlString)
|
|
|
|
declare attachedTo: Ref<Doc>
|
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-15 10:02:24 +00:00
|
|
|
@Prop(Collection(chunter.class.Comment), 'Comments' as IntlString)
|
2021-11-30 15:39:08 +00:00
|
|
|
comments!: number
|
|
|
|
|
2021-12-15 10:02:24 +00:00
|
|
|
@Prop(Collection(attachment.class.Attachment), 'Attachments' as IntlString)
|
2021-12-02 13:12:16 +00:00
|
|
|
attachments!: number
|
|
|
|
|
2021-11-30 15:39:08 +00:00
|
|
|
@Prop(TypeString(), 'Labels' as IntlString)
|
|
|
|
labels!: string
|
2021-12-15 09:04:43 +00:00
|
|
|
|
|
|
|
@Prop(TypeRef(contact.class.Employee), 'Assignee' as IntlString)
|
|
|
|
declare assignee: Ref<Employee> | null
|
|
|
|
}
|
|
|
|
|
|
|
|
@Mixin(task.mixin.KanbanCard, core.class.Class)
|
|
|
|
export class TKanbanCard extends TClass implements KanbanCard {
|
|
|
|
card!: AnyComponent
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.Kanban, core.class.Doc, DOMAIN_KANBAN)
|
|
|
|
export class TKanban extends TDoc implements Kanban {
|
|
|
|
states!: Arr<Ref<State>>
|
|
|
|
doneStates!: Arr<Ref<DoneState>>
|
|
|
|
attachedTo!: Ref<Space>
|
|
|
|
order!: Arr<Ref<Doc>>
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.KanbanTemplateSpace, core.class.Space, DOMAIN_MODEL)
|
|
|
|
export class TKanbanTemplateSpace extends TSpace implements KanbanTemplateSpace {
|
|
|
|
icon!: AnyComponent
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.StateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN)
|
|
|
|
export class TStateTemplate extends TAttachedDoc implements StateTemplate {
|
|
|
|
@Prop(TypeString(), 'Title' as IntlString)
|
|
|
|
title!: string
|
|
|
|
|
|
|
|
@Prop(TypeString(), 'Color' as IntlString)
|
|
|
|
color!: string
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.DoneStateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN)
|
|
|
|
export class TDoneStateTemplate extends TAttachedDoc implements DoneStateTemplate {
|
|
|
|
@Prop(TypeString(), 'Title' as IntlString)
|
|
|
|
title!: string
|
|
|
|
}
|
|
|
|
|
|
|
|
@Model(task.class.WonStateTemplate, task.class.DoneStateTemplate, DOMAIN_KANBAN)
|
|
|
|
export class TWonStateTemplate extends TDoneStateTemplate implements WonStateTemplate {}
|
|
|
|
|
|
|
|
@Model(task.class.LostStateTemplate, task.class.DoneStateTemplate, DOMAIN_KANBAN)
|
|
|
|
export class TLostStateTemplate extends TDoneStateTemplate implements LostStateTemplate {}
|
|
|
|
|
|
|
|
@Model(task.class.KanbanTemplate, core.class.Doc, DOMAIN_KANBAN)
|
|
|
|
export class TKanbanTemplate extends TDoc implements KanbanTemplate {
|
|
|
|
@Prop(TypeString(), 'Title' as IntlString)
|
|
|
|
title!: string
|
|
|
|
|
|
|
|
states!: Arr<Ref<StateTemplate>>
|
|
|
|
doneStates!: Arr<Ref<DoneStateTemplate>>
|
|
|
|
|
|
|
|
@Prop(Collection(task.class.StateTemplate), 'States' as IntlString)
|
|
|
|
statesC!: number
|
|
|
|
|
|
|
|
@Prop(Collection(task.class.DoneStateTemplate), 'Done States' as IntlString)
|
|
|
|
doneStatesC!: number
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|
|
|
|
|
|
|
|
export function createModel (builder: Builder): void {
|
2021-12-15 09:04:43 +00:00
|
|
|
builder.createModel(
|
|
|
|
TState,
|
|
|
|
TDoneState,
|
|
|
|
TWonState,
|
|
|
|
TLostState,
|
|
|
|
TKanbanCard,
|
|
|
|
TKanban,
|
|
|
|
TKanbanTemplateSpace,
|
|
|
|
TStateTemplate,
|
|
|
|
TDoneStateTemplate,
|
|
|
|
TWonStateTemplate,
|
|
|
|
TLostStateTemplate,
|
|
|
|
TKanbanTemplate,
|
|
|
|
TSequence,
|
|
|
|
TTask,
|
|
|
|
TSpaceWithStates,
|
|
|
|
TProject,
|
2021-12-17 09:04:49 +00:00
|
|
|
TIssue
|
|
|
|
)
|
2021-08-07 14:49:14 +00:00
|
|
|
builder.mixin(task.class.Project, core.class.Class, workbench.mixin.SpaceView, {
|
|
|
|
view: {
|
2021-12-15 09:04:43 +00:00
|
|
|
class: task.class.Issue,
|
2021-08-07 14:49:14 +00:00
|
|
|
createItemDialog: task.component.CreateTask
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
|
|
|
workbench.class.Application,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
label: task.string.ApplicationLabelTask,
|
|
|
|
icon: task.icon.Task,
|
|
|
|
hidden: false,
|
|
|
|
navigatorModel: {
|
|
|
|
spaces: [
|
|
|
|
{
|
|
|
|
label: task.string.Projects,
|
|
|
|
spaceClass: task.class.Project,
|
|
|
|
addSpaceLabel: task.string.CreateProject,
|
|
|
|
createComponent: task.component.CreateProject
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
task.app.Tasks
|
|
|
|
)
|
2021-11-30 15:39:08 +00:00
|
|
|
|
|
|
|
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
2021-12-15 09:04:43 +00:00
|
|
|
attachTo: task.class.Issue,
|
2021-11-30 15:39:08 +00:00
|
|
|
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'
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2021-12-15 09:04:43 +00:00
|
|
|
builder.mixin(task.class.Issue, core.class.Class, view.mixin.AttributePresenter, {
|
2021-11-30 15:39:08 +00:00
|
|
|
presenter: task.component.TaskPresenter
|
2021-08-07 14:49:14 +00:00
|
|
|
})
|
2021-11-30 15:39:08 +00:00
|
|
|
|
2021-12-15 09:04:43 +00:00
|
|
|
builder.mixin(task.class.Issue, core.class.Class, view.mixin.ObjectEditor, {
|
2021-12-17 09:04:49 +00:00
|
|
|
editor: task.component.EditIssue
|
2021-11-30 15:39:08 +00:00
|
|
|
})
|
|
|
|
|
2021-12-15 09:04:43 +00:00
|
|
|
builder.createDoc(task.class.Sequence, task.space.Sequence, {
|
|
|
|
attachedTo: task.class.Issue,
|
2021-12-02 13:12:16 +00:00
|
|
|
sequence: 0
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.createDoc(view.class.Viewlet, core.space.Model, {
|
2021-12-15 09:04:43 +00:00
|
|
|
attachTo: task.class.Issue,
|
|
|
|
descriptor: task.viewlet.Kanban,
|
2021-12-02 13:12:16 +00:00
|
|
|
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-15 09:04:43 +00:00
|
|
|
state: task.class.State
|
|
|
|
// attachedTo: core.class.Doc
|
2021-12-02 13:12:16 +00:00
|
|
|
}
|
|
|
|
} as FindOptions<Doc>, // TODO: fix
|
2021-12-15 09:04:43 +00:00
|
|
|
config: [
|
|
|
|
// '$lookup.attachedTo',
|
|
|
|
'$lookup.state',
|
2021-12-17 09:04:49 +00:00
|
|
|
'$lookup.assignee'
|
|
|
|
]
|
2021-12-02 13:12:16 +00:00
|
|
|
})
|
|
|
|
|
2021-12-15 09:04:43 +00:00
|
|
|
builder.mixin(task.class.Issue, core.class.Class, task.mixin.KanbanCard, {
|
2021-12-02 13:12:16 +00:00
|
|
|
card: task.component.KanbanCard
|
|
|
|
})
|
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
|
|
|
task.class.Project,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
name: 'public',
|
|
|
|
description: 'Public tasks',
|
|
|
|
private: false,
|
|
|
|
members: []
|
|
|
|
},
|
|
|
|
task.space.TasksPublic
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
task.class.KanbanTemplateSpace,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
name: 'Projects',
|
|
|
|
description: 'Manage project statuses',
|
|
|
|
members: [],
|
|
|
|
private: false,
|
|
|
|
icon: task.component.TemplatesIcon
|
|
|
|
},
|
|
|
|
task.space.ProjectTemplates
|
|
|
|
)
|
2021-12-14 09:24:14 +00:00
|
|
|
|
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-12-15 09:04:43 +00:00
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
|
|
|
view.class.Action,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
label: 'Create task' as IntlString,
|
|
|
|
icon: task.icon.Task,
|
|
|
|
action: task.actionImpl.CreateTask
|
|
|
|
},
|
|
|
|
task.action.CreateTask
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
view.class.Action,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
label: 'Edit Statuses' as IntlString,
|
|
|
|
icon: view.icon.MoreH,
|
|
|
|
action: task.actionImpl.EditStatuses
|
|
|
|
},
|
|
|
|
task.action.EditStatuses
|
|
|
|
)
|
2021-12-15 09:04:43 +00:00
|
|
|
|
|
|
|
builder.createDoc(view.class.ActionTarget, core.space.Model, {
|
|
|
|
target: task.class.SpaceWithStates,
|
|
|
|
action: task.action.EditStatuses
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.State, core.class.Class, view.mixin.AttributeEditor, {
|
|
|
|
editor: task.component.StateEditor
|
|
|
|
})
|
|
|
|
|
|
|
|
builder.mixin(task.class.State, core.class.Class, view.mixin.AttributePresenter, {
|
|
|
|
presenter: task.component.StatePresenter
|
|
|
|
})
|
|
|
|
|
2021-12-17 09:04:49 +00:00
|
|
|
builder.createDoc(
|
|
|
|
view.class.ViewletDescriptor,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
label: 'Kanban' as IntlString,
|
|
|
|
icon: task.icon.Kanban,
|
|
|
|
component: task.component.KanbanView
|
|
|
|
},
|
|
|
|
task.viewlet.Kanban
|
|
|
|
)
|
|
|
|
|
|
|
|
builder.createDoc(
|
|
|
|
core.class.Space,
|
|
|
|
core.space.Model,
|
|
|
|
{
|
|
|
|
name: 'Sequences',
|
|
|
|
description: 'Internal space to store sequence numbers',
|
|
|
|
members: [],
|
|
|
|
private: false
|
|
|
|
},
|
|
|
|
task.space.Sequence
|
|
|
|
)
|
2021-08-07 14:49:14 +00:00
|
|
|
}
|
2021-12-07 18:45:11 +00:00
|
|
|
|
|
|
|
export { taskOperation } from './migration'
|