introduce Sequence (#280)

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-10-23 12:09:39 +02:00 committed by GitHub
parent 2cc2f5c700
commit 465c57f37c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1033 additions and 870 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -181,6 +181,11 @@ export function createModel (builder: Builder): void {
target: recruit.class.Candidate,
action: recruit.action.CreateApplication
})
builder.createDoc(view.class.Sequence, view.space.Sequence, {
attachedTo: recruit.class.Applicant,
sequence: 0
})
}
export { default } from './plugin'

View File

@ -18,7 +18,7 @@ import type { Ref, Class, Space, Doc, Arr, Domain, State } 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, Kanban } from '@anticrm/view'
import type { ViewletDescriptor, Viewlet, AttributeEditor, AttributePresenter, KanbanCard, ObjectEditor, Action, ActionTarget, Kanban, Sequence } from '@anticrm/view'
import core, { TDoc, TClass } from '@anticrm/model-core'
@ -76,13 +76,18 @@ export class TActionTarget extends TDoc implements ActionTarget {
@Model(view.class.Kanban, core.class.Doc, DOMAIN_KANBAN)
export class TKanban extends TDoc implements Kanban {
attachedTo!: Ref<Space>
sequence!: number
states!: Arr<Ref<State>>
order!: Arr<Ref<Doc>>
}
@Model(view.class.Sequence, core.class.Doc, DOMAIN_KANBAN)
export class TSequence extends TDoc implements Sequence {
attachedTo!: Ref<Class<Doc>>
sequence!: number
}
export function createModel (builder: Builder): void {
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TObjectEditor, TViewletDescriptor, TViewlet, TAction, TActionTarget, TKanban)
builder.createModel(TAttributeEditor, TAttributePresenter, TKanbanCard, TObjectEditor, TViewletDescriptor, TViewlet, TAction, TActionTarget, TKanban, TSequence)
builder.mixin(core.class.TypeString, core.class.Class, view.mixin.AttributeEditor, {
editor: view.component.StringEditor
@ -126,6 +131,13 @@ export function createModel (builder: Builder): void {
target: core.class.Doc,
action: view.action.Delete
})
builder.createDoc(core.class.Space, core.space.Model, {
name: 'Sequences',
description: 'Internal space to store sequence numbers',
members: [],
private: false
}, view.space.Sequence)
}
export default view

View File

@ -53,11 +53,11 @@
if (state === undefined) {
throw new Error('create application: state not found')
}
const kanban = await client.findOne(view.class.Kanban, { attachedTo: _space })
if (kanban === undefined) {
throw new Error('kanban object not found')
const sequence = await client.findOne(view.class.Sequence, { attachedTo: recruit.class.Applicant })
if (sequence === undefined) {
throw new Error('sequence object not found')
}
const incResult = await client.updateDoc(view.class.Kanban, _space, kanban._id, {
const incResult = await client.updateDoc(view.class.Sequence, view.space.Sequence, sequence._id, {
$inc: { sequence: 1 }
}, true)
const id = await client.createDoc(recruit.class.Applicant, _space, {

View File

@ -86,11 +86,18 @@ export interface ActionTarget extends Doc {
*/
export interface Kanban extends Doc {
attachedTo: Ref<Space>
sequence: number
states: Arr<Ref<State>>
order: Arr<Ref<Doc>>
}
/**
* @public
*/
export interface Sequence extends Doc {
attachedTo: Ref<Class<Doc>>
sequence: number
}
/**
* @public
*/
@ -108,12 +115,16 @@ export default plugin(viewId, {
Viewlet: '' as Ref<Class<Viewlet>>,
Action: '' as Ref<Class<Action>>,
ActionTarget: '' as Ref<Class<ActionTarget>>,
Kanban: '' as Ref<Class<Kanban>>
Kanban: '' as Ref<Class<Kanban>>,
Sequence: '' as Ref<Class<Sequence>>
},
viewlet: {
Table: '' as Ref<ViewletDescriptor>,
Kanban: '' as Ref<ViewletDescriptor>
},
space: {
Sequence: '' as Ref<Space>
},
icon: {
Table: '' as Asset,
Kanban: '' as Asset

File diff suppressed because it is too large Load Diff