// // 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. // import type { Employee } from '@anticrm/contact' import type { Class, Data, Doc, DocWithState, DoneState, Ref, Space, State } from '@anticrm/core' import type { Asset, Plugin } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import core from '@anticrm/core' import view, { Kanban, KanbanTemplateSpace } from '@anticrm/view' /** * @public */ export interface Project extends Space {} /** * @public */ export interface Task extends DocWithState { number: number // Sequence number name: string description: string assignee: Ref | null comments?: number attachments?: number labels?: string } /** * @public */ export const taskId = 'task' as Plugin export default plugin(taskId, { class: { Task: '' as Ref>, Project: '' as Ref> }, icon: { Task: '' as Asset }, space: { ProjectTemplates: '' as Ref } }) /** * @public */ export async function createProjectKanban ( projectId: Ref, factory: (_class: Ref>, space: Ref, data: Data, id: Ref) => Promise ): Promise { const states = [ { color: '#7C6FCD', name: 'Open' }, { color: '#6F7BC5', name: 'In Progress' }, { color: '#77C07B', name: 'Under review' }, { color: '#A5D179', name: 'Done' }, { color: '#F28469', name: 'Invalid' } ] const ids: Array> = [] for (const st of states) { const sid = (projectId + '.state.' + st.name.toLowerCase().replace(' ', '_')) as Ref await factory( core.class.State, projectId, { title: st.name, color: st.color }, sid ) ids.push(sid) } const rawDoneStates = [ { class: core.class.WonState, title: 'Won' }, { class: core.class.LostState, title: 'Lost' } ] const doneStates: Array> = [] for (const st of rawDoneStates) { const sid = (projectId + '.done-state.' + st.title.toLowerCase().replace(' ', '_')) as Ref await factory( st.class, projectId, { title: st.title }, sid ) doneStates.push(sid) } await factory( view.class.Kanban, projectId, { attachedTo: projectId, states: ids, doneStates, order: [] }, (projectId + '.kanban.') as Ref ) }