initial Kanban object

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-10-08 16:49:46 +02:00
parent fc13903163
commit 1eb5ff15f8
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
9 changed files with 904 additions and 824 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,16 +14,18 @@
//
import type { IntlString, Asset, Resource } from '@anticrm/platform'
import type { Ref, Class, Space, Doc } from '@anticrm/core'
import type { Ref, Class, Space, Doc, Arr, Domain } from '@anticrm/core'
import { DOMAIN_MODEL } from '@anticrm/core'
import { Model, Mixin, Builder } from '@anticrm/model'
import type { AnyComponent } from '@anticrm/ui'
import type { ViewletDescriptor, Viewlet, AttributeEditor, AttributePresenter, KanbanCard, ObjectEditor, Action, ActionTarget } from '@anticrm/view'
import type { ViewletDescriptor, Viewlet, AttributeEditor, AttributePresenter, KanbanCard, ObjectEditor, Action, ActionTarget, Kanban } from '@anticrm/view'
import core, { TDoc, TClass } from '@anticrm/model-core'
import view from './plugin'
const DOMAIN_KANBAN = 'kanban' as Domain
@Mixin(view.mixin.AttributeEditor, core.class.Class)
export class TAttributeEditor extends TClass implements AttributeEditor {
editor!: AnyComponent
@ -71,8 +73,14 @@ export class TActionTarget extends TDoc implements ActionTarget {
action!: Ref<Action>
}
@Model(view.class.Kanban, core.class.Doc, DOMAIN_KANBAN)
export class TKanban extends TDoc implements Kanban {
attachedTo!: Ref<Space>
order!: Arr<Ref<Doc>>
}
export function createModel (builder: Builder): void {
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TObjectEditor, TViewletDescriptor, TViewlet, TAction, TActionTarget)
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TObjectEditor, TViewletDescriptor, TViewlet, TAction, TActionTarget, TKanban)
builder.mixin(core.class.TypeString, core.class.Class, view.mixin.AttributeEditor, {
editor: view.component.StringEditor

View File

@ -30,6 +30,7 @@
"@anticrm/login": "~0.6.0",
"deep-equal": "^2.0.5",
"@anticrm/panel": "~0.6.0",
"@anticrm/chunter-resources": "~0.6.0"
"@anticrm/chunter-resources": "~0.6.0",
"@anticrm/view": "~0.6.0"
}
}

View File

@ -29,6 +29,7 @@
import core from '@anticrm/core'
import recruit from '../plugin'
import contact from '@anticrm/contact'
import view from '@anticrm/view'
export let space: Ref<SpaceWithStates>
export let candidate: Ref<Candidate> // | null = null
@ -52,7 +53,13 @@
state: state._id
})
await client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
const kanban = await client.findOne(view.class.Kanban, { attachedTo: _space })
if (kanban === undefined) {
throw new Error('kanban object not found')
}
await client.updateDoc(view.class.Kanban, _space, kanban._id, {
$push: {
order: id
}

View File

@ -22,6 +22,7 @@
import recruit from '../plugin'
import core from '@anticrm/core'
import view from '@anticrm/view'
const dispatch = createEventDispatcher()
@ -74,6 +75,10 @@
await client.updateDoc(recruit.class.Vacancy, core.space.Model, id, {
states: [s1, s2, s3, s4, s5, s6]
})
await client.createDoc(view.class.Kanban, id, {
attachedTo: id,
order: []
})
}
</script>

View File

@ -22,6 +22,7 @@
import { getClient } from '@anticrm/presentation'
import { Label, showPopup, Loading, ScrollBox, AnyComponent } from '@anticrm/ui'
import type { AnySvelteComponent } from '@anticrm/ui'
import type { Kanban } from '@anticrm/view'
import { createQuery } from '@anticrm/presentation'
@ -39,12 +40,16 @@
export let config: string[]
let _space: SpaceWithStates | undefined
let kanban: Kanban
let states: State[] = []
let objects: (Doc & { state: Ref<State> })[] = []
const spaceQuery = createQuery()
$: spaceQuery.query(core.class.SpaceWithStates, { _id: space }, result => { _space = result[0] })
const kanbanQuery = createQuery()
$: kanbanQuery.query(view.class.Kanban, { attachedTo: space }, result => { kanban = result[0] })
function sort(states: State[]): State[] {
if (_space === undefined || states.length === 0) { return [] }
const map = states.reduce((map, state) => { map.set(state._id, state); return map }, new Map<Ref<State>, State>())
@ -54,7 +59,7 @@
function sortObjects<T extends Doc> (objects: T[]): T[] {
if (_space === undefined || objects.length === 0) { return [] }
const map = objects.reduce((map, doc) => { map.set(doc._id, doc); return map }, new Map<Ref<Doc>, Doc>())
const x = _space.order.map(id => map.get(id) as T)
const x = kanban.order.map(id => map.get(id) as T)
return x
}
@ -63,7 +68,7 @@
$: if (_space) statesQuery.query(core.class.State, { _id: { $in: _space.states } }, result => { states = sort(result); console.log('states', sort(result)) })
const query = createQuery()
$: if (_space) query.query(_class, { space }, result => { objects = sortObjects(result) }, options)
$: if (kanban) query.query(_class, { space }, result => { objects = sortObjects(result) }, options)
function dragover(ev: MouseEvent, object: Doc) {
// if (dragswap(ev, i)) {
@ -86,13 +91,13 @@
if (dragCardInitialPosition !== to) {
await client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
await client.updateDoc(view.class.Kanban, space, kanban._id, {
$pull: {
order: id
}
})
client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
client.updateDoc(view.class.Kanban, space, kanban._id, {
$push: {
order: {
$each: [id],

View File

@ -16,7 +16,7 @@
import type { Plugin, Asset, Resource } from '@anticrm/platform'
import { plugin } from '@anticrm/platform'
import type { Ref, Mixin, UXObject, Space, FindOptions, Class, Doc } from '@anticrm/core'
import type { Ref, Mixin, UXObject, Space, FindOptions, Class, Doc, Arr } from '@anticrm/core'
import type { AnyComponent } from '@anticrm/ui'
@ -81,6 +81,14 @@ export interface ActionTarget extends Doc {
action: Ref<Action>
}
/**
* @public
*/
export interface Kanban extends Doc {
attachedTo: Ref<Space>
order: Arr<Ref<Doc>>
}
/**
* @public
*/
@ -97,7 +105,8 @@ export default plugin(viewId, {
ViewletDescriptor: '' as Ref<Class<ViewletDescriptor>>,
Viewlet: '' as Ref<Class<Viewlet>>,
Action: '' as Ref<Class<Action>>,
ActionTarget: '' as Ref<Class<ActionTarget>>
ActionTarget: '' as Ref<Class<ActionTarget>>,
Kanban: '' as Ref<Class<Kanban>>
},
viewlet: {
Table: '' as Ref<ViewletDescriptor>,

File diff suppressed because it is too large Load Diff