mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
introduce Sequence
(#280)
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
2cc2f5c700
commit
465c57f37c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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, {
|
||||
|
@ -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
Loading…
Reference in New Issue
Block a user