From 13d8b6195bcb0956febdd1d3891a83be5c4a218f Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Fri, 3 Dec 2021 12:49:00 +0700 Subject: [PATCH] Fix workspace create Fix workspace create Signed-off-by: Andrey Sobolev --- models/task/package.json | 1 - models/task/src/index.ts | 2 +- .../src/components/CreateProject.svelte | 2 +- plugins/task-resources/src/index.ts | 2 - plugins/task-resources/src/utils.ts | 38 ---------------- plugins/task/package.json | 3 +- plugins/task/src/index.ts | 45 ++++++++++++++++++- 7 files changed, 48 insertions(+), 45 deletions(-) diff --git a/models/task/package.json b/models/task/package.json index de9b9eef71..9fcefd250f 100644 --- a/models/task/package.json +++ b/models/task/package.json @@ -35,7 +35,6 @@ "@anticrm/model-workbench": "~0.6.1", "@anticrm/model-contact": "~0.6.1", "@anticrm/task": "~0.6.0", - "@anticrm/task-resources": "~0.6.0", "@anticrm/model-chunter": "~0.6.0", "@anticrm/workbench": "~0.6.1" } diff --git a/models/task/src/index.ts b/models/task/src/index.ts index c84c29d03a..3701a6b4fb 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -23,7 +23,7 @@ import view from '@anticrm/model-view' import workbench from '@anticrm/model-workbench' import type { IntlString } from '@anticrm/platform' import type { Project, Task } from '@anticrm/task' -import { createProjectKanban } from '@anticrm/task-resources' +import { createProjectKanban } from '@anticrm/task' import task from './plugin' @Model(task.class.Project, core.class.SpaceWithStates) diff --git a/plugins/task-resources/src/components/CreateProject.svelte b/plugins/task-resources/src/components/CreateProject.svelte index 3314de04de..49532e7179 100644 --- a/plugins/task-resources/src/components/CreateProject.svelte +++ b/plugins/task-resources/src/components/CreateProject.svelte @@ -19,7 +19,7 @@ import { EditBox, Grid, IconFolder, ToggleWithLabel } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import task from '../plugin' - import { createProjectKanban } from '../utils' + import { createProjectKanban } from '@anticrm/task' const dispatch = createEventDispatcher() diff --git a/plugins/task-resources/src/index.ts b/plugins/task-resources/src/index.ts index e5c441acaf..c0fcd7d76d 100644 --- a/plugins/task-resources/src/index.ts +++ b/plugins/task-resources/src/index.ts @@ -21,8 +21,6 @@ import CreateProject from './components/CreateProject.svelte' import TaskPresenter from './components/TaskPresenter.svelte' import KanbanCard from './components/KanbanCard.svelte' -export { createProjectKanban } from './utils' - export default async (): Promise => ({ component: { CreateTask, diff --git a/plugins/task-resources/src/utils.ts b/plugins/task-resources/src/utils.ts index 659d7adfce..c45e32a2ed 100644 --- a/plugins/task-resources/src/utils.ts +++ b/plugins/task-resources/src/utils.ts @@ -43,41 +43,3 @@ export async function uploadFile (space: Ref, file: File, attachedTo: Ref console.log(uuid) return uuid } - -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) - } - - await factory( - view.class.Kanban, - projectId, - { - attachedTo: projectId, - states: ids, - order: [] - }, - (projectId + '.kanban.') as Ref - ) -} diff --git a/plugins/task/package.json b/plugins/task/package.json index 2b6b53ed28..fa256318a2 100644 --- a/plugins/task/package.json +++ b/plugins/task/package.json @@ -28,6 +28,7 @@ "dependencies": { "@anticrm/platform": "~0.6.5", "@anticrm/core": "~0.6.11", - "@anticrm/contact": "~0.6.2" + "@anticrm/contact": "~0.6.2", + "@anticrm/view": "~0.6.0" } } diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index 6b3431f525..55eaac94d2 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -14,9 +14,11 @@ // import type { Employee } from '@anticrm/contact' -import type { Class, Doc, Ref, Space } from '@anticrm/core' +import type { Class, Data, Doc, 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 } from '@anticrm/view' /** * @public @@ -52,3 +54,44 @@ export default plugin(taskId, { Task: '' as Asset } }) + +/** + * @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) + } + + await factory( + view.class.Kanban, + projectId, + { + attachedTo: projectId, + states: ids, + order: [] + }, + (projectId + '.kanban.') as Ref + ) +}