Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-08 10:43:11 +02:00 committed by GitHub
parent 89c22a92fa
commit c8f37bb496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 276 additions and 159 deletions

File diff suppressed because it is too large Load Diff

View File

@ -60,6 +60,13 @@ export class TEmployee extends TPerson implements Employee {
export function createModel (builder: Builder): void { export function createModel (builder: Builder): void {
builder.createModel(TContact, TPerson, TOrganization, TEmployee) builder.createModel(TContact, TPerson, TOrganization, TEmployee)
builder.createDoc(core.class.Space, core.space.Model, {
name: 'Employees',
description: 'Employees',
private: false,
members: []
}, contact.space.Employee)
builder.mixin(contact.class.Person, core.class.Class, view.mixin.AttributePresenter, { builder.mixin(contact.class.Person, core.class.Class, view.mixin.AttributePresenter, {
presenter: contact.component.PersonPresenter presenter: contact.component.PersonPresenter
}) })

View File

@ -14,7 +14,7 @@
// //
import { mergeIds } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform'
import type { Ref, Class } from '@anticrm/core' import type { Ref, Class, Space } from '@anticrm/core'
import contact, { contactId, Employee } from '@anticrm/contact' import contact, { contactId, Employee } from '@anticrm/contact'
import type { AnyComponent } from '@anticrm/ui' import type { AnyComponent } from '@anticrm/ui'
import {} from '@anticrm/core' import {} from '@anticrm/core'
@ -25,5 +25,8 @@ export const ids = mergeIds(contactId, contact, {
}, },
class: { class: {
Employee: '' as Ref<Class<Employee>> Employee: '' as Ref<Class<Employee>>
},
space: {
Employee: '' as Ref<Space>
} }
}) })

View File

@ -30,4 +30,6 @@ export class TSpace extends TDoc implements Space {
} }
@Model(core.class.Account, core.class.Doc, DOMAIN_MODEL) @Model(core.class.Account, core.class.Doc, DOMAIN_MODEL)
export class TAccount extends TDoc implements Account {} export class TAccount extends TDoc implements Account {
email!: string
}

View File

@ -20,6 +20,7 @@
"@anticrm/core": "~0.6.7", "@anticrm/core": "~0.6.7",
"@anticrm/model": "~0.6.0", "@anticrm/model": "~0.6.0",
"@anticrm/platform": "~0.6.3", "@anticrm/platform": "~0.6.3",
"@anticrm/model-recruit":"~0.6.0" "@anticrm/model-recruit": "~0.6.0",
"@anticrm/model-contact": "~0.6.0"
} }
} }

View File

@ -16,9 +16,35 @@
import { Builder } from '@anticrm/model' import { Builder } from '@anticrm/model'
import core from '@anticrm/core'
import contact from '@anticrm/model-contact'
import recruit from '@anticrm/model-recruit' import recruit from '@anticrm/model-recruit'
export function createDemo (builder: Builder): void { export function createDemo (builder: Builder): void {
builder.createDoc(contact.class.Employee, contact.space.Employee, {
firstName: 'Rosamund',
lastName: 'Chen',
email: 'rosamund@hc.engineering',
phone: '+1 655 912 3424',
city: 'Mountain View'
})
builder.createDoc(core.class.Account, core.space.Model, {
email: 'rosamund@hc.engineering'
})
builder.createDoc(contact.class.Employee, contact.space.Employee, {
firstName: 'Elon',
lastName: 'Musk',
email: 'elon@hc.engineering',
phone: '+1 655 843 3453',
city: 'Bel Air'
})
builder.createDoc(core.class.Account, core.space.Model, {
email: 'elon@hc.engineering'
})
builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, { builder.createDoc(recruit.class.Candidate, recruit.space.CandidatesPublic, {
firstName: 'Andrey', firstName: 'Andrey',
lastName: 'P.', lastName: 'P.',

View File

@ -153,7 +153,7 @@ describe('memdb', () => {
private: false, private: false,
members: [] members: []
}) })
const account = await model.createDoc(core.class.Account, core.space.Model, {}) const account = await model.createDoc(core.class.Account, core.space.Model, { email: 'email' })
await model.updateDoc(core.class.Space, core.space.Model, space, { $push: { members: account } }) await model.updateDoc(core.class.Space, core.space.Model, space, { $push: { members: account } })
const txSpace = await model.findAll(core.class.Space, { _id: space }) const txSpace = await model.findAll(core.class.Space, { _id: space })
expect(txSpace[0].members).toEqual(expect.arrayContaining([account])) expect(txSpace[0].members).toEqual(expect.arrayContaining([account]))

View File

@ -175,4 +175,6 @@ export interface Space extends Doc {
/** /**
* @public * @public
*/ */
export interface Account extends Doc {} export interface Account extends Doc {
email: string
}