Kanban templates & won/lost states (#612)

Signed-off-by: Ilya Sumbatyants <ilya.sumb@gmail.com>
This commit is contained in:
Ilya Sumbatyants
2021-12-14 10:24:14 +01:00
committed by GitHub
parent f27f221dc6
commit caff583483
71 changed files with 1978 additions and 431 deletions
@@ -13,18 +13,19 @@
// limitations under the License.
-->
<script lang="ts">
import core, { generateId, Ref } from '@anticrm/core'
import core, { Ref } from '@anticrm/core'
import { getClient, SpaceCreateCard } from '@anticrm/presentation'
import { Project } from '@anticrm/task'
import { EditBox, Grid, IconFolder, ToggleWithLabel } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import task from '../plugin'
import { createProjectKanban } from '@anticrm/task'
import view, { createKanban, KanbanTemplate } from '@anticrm/view'
import { KanbanTemplateSelector } from '@anticrm/view-resources'
const dispatch = createEventDispatcher()
let name: string = ''
const description: string = ''
let templateId: Ref<KanbanTemplate> | undefined
export function canClose (): boolean {
return name === ''
@@ -33,8 +34,11 @@
const client = getClient()
async function createProject (): Promise<void> {
const id: Ref<Project> = generateId()
await client.createDoc(
if (templateId !== undefined && await client.findOne(view.class.KanbanTemplate, { _id: templateId }) === undefined) {
throw Error(`Failed to find target kanban template: ${templateId}`)
}
const id = await client.createDoc(
task.class.Project,
core.space.Model,
{
@@ -42,13 +46,10 @@
description,
private: false,
members: []
},
id
}
)
await createProjectKanban(id, async (_class, space, data, id) => {
await client.createDoc(_class, space, data, id)
})
await createKanban(client, id, templateId)
}
</script>
@@ -63,5 +64,6 @@
<Grid column={1} rowGap={1.5}>
<EditBox label={task.string.ProjectName} icon={IconFolder} bind:value={name} placeholder={'Project name'} focus />
<ToggleWithLabel label={task.string.MakePrivate} description={task.string.MakePrivateDescription} />
<KanbanTemplateSelector folders={[task.space.ProjectTemplates]} bind:template={templateId}/>
</Grid>
</SpaceCreateCard>
@@ -15,6 +15,7 @@
<script lang="ts">
import contact, { Employee } from '@anticrm/contact'
import type { Data, Ref, Space } from '@anticrm/core'
import core from '@anticrm/core'
import { generateId } from '@anticrm/core'
import { OK, Status } from '@anticrm/platform'
import { Card, getClient, UserBox } from '@anticrm/presentation'
@@ -47,6 +48,11 @@
}
async function createTask () {
const state = await client.findOne(core.class.State, { space: _space })
if (state === undefined) {
throw new Error('create application: state not found')
}
const sequence = await client.findOne(view.class.Sequence, { attachedTo: task.class.Task })
if (sequence === undefined) {
throw new Error('sequence object not found')
@@ -66,7 +72,9 @@
name: object.name,
description: object.description,
assignee,
number: (incResult as any).object.sequence
number: (incResult as any).object.sequence,
doneState: null,
state: state._id
}
await client.createDoc(task.class.Task, _space, value, taskId)
@@ -0,0 +1,21 @@
<script lang="ts">
import { Icon } from '@anticrm/ui'
import task from '@anticrm/task'
</script>
<div class="root">
<Icon icon={task.icon.Task} size="xsmall" />
</div>
<style lang="scss">
.root {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
color: #fff;
background-color: #7C6FCD;
}
</style>