add number field for auto-incremented object id

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-10-14 10:43:55 +02:00
parent 1be2b83308
commit 7fb8d31f89
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
9 changed files with 923 additions and 942 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,9 @@ export class TState extends TDoc implements State {
export class TDocWithState extends TDoc {
@Prop(TypeString(), 'State' as IntlString)
state!: Ref<State>
@Prop(TypeString(), 'No.' as IntlString)
number!: number
}
@Model(core.class.SpaceWithStates, core.class.Space)

View File

@ -141,22 +141,22 @@ export function createModel (builder: Builder): void {
state: core.class.State
}
} as FindOptions<Doc>, // TODO: fix
config: ['$lookup.candidate', { presenter: recruit.component.ApplicationPresenter, label: 'Application' }, '$lookup.state', '$lookup.candidate.city', '$lookup.candidate.channels']
config: ['number', '$lookup.candidate', { presenter: recruit.component.ApplicationPresenter, label: 'Application' }, '$lookup.state', '$lookup.candidate.city', '$lookup.candidate.channels']
})
builder.createDoc(view.class.Viewlet, core.space.Model, {
attachTo: recruit.class.Applicant,
descriptor: view.viewlet.Kanban,
open: recruit.component.EditCandidate,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
options: {
lookup: {
candidate: recruit.class.Candidate,
state: core.class.State
}
} as FindOptions<Doc>, // TODO: fix
config: ['$lookup.candidate', '$lookup.state', '$lookup.candidate.city', '$lookup.candidate.channels']
})
// builder.createDoc(view.class.Viewlet, core.space.Model, {
// attachTo: recruit.class.Applicant,
// descriptor: view.viewlet.Kanban,
// open: recruit.component.EditCandidate,
// // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
// options: {
// lookup: {
// candidate: recruit.class.Candidate,
// state: core.class.State
// }
// } as FindOptions<Doc>, // TODO: fix
// config: ['$lookup.candidate', '$lookup.state', '$lookup.candidate.city', '$lookup.candidate.channels']
// })
builder.mixin(recruit.class.Applicant, core.class.Class, view.mixin.KanbanCard, {
card: recruit.component.KanbanCard

View File

@ -76,6 +76,7 @@ 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>>
}

View File

@ -209,6 +209,7 @@ export interface State extends Doc {
*/
export interface DocWithState extends Doc {
state: Ref<State>
number: number
}
/**

View File

@ -53,22 +53,18 @@
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 incResult = await client.updateDoc(view.class.Kanban, _space, kanban._id, {
$inc: { sequence: 1 }
}, true)
const id = await client.createDoc(recruit.class.Applicant, _space, {
candidate,
state: state._id
state: state._id,
number: incResult.object.sequence
})
// 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
// }
// })
}
async function validate(candidate: Ref<Candidate>, space: Ref<Space>) {

View File

@ -86,6 +86,7 @@ export interface ActionTarget extends Doc {
*/
export interface Kanban extends Doc {
attachedTo: Ref<Space>
sequence: number
states: Arr<Ref<State>>
order: Arr<Ref<Doc>>
}

File diff suppressed because it is too large Load Diff