introduce EmployeeAccount

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-10 11:47:38 +02:00
parent f1f254b104
commit 12e49add3f
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
3 changed files with 22 additions and 9 deletions

View File

@ -103,14 +103,15 @@ program
const url = new URL(`/${token}`, transactorUrl)
const contrib = await createContributingClient(url.href)
const txop = new TxOperations(contrib, core.account.System)
await txop.createDoc(contact.class.Employee, contact.space.Employee, {
const employee = await txop.createDoc(contact.class.Employee, contact.space.Employee, {
firstName: account.first,
lastName: account.last,
city: 'Mountain View',
channels: []
})
await txop.createDoc(core.class.Account, core.space.Model, {
email
await txop.createDoc(contact.class.EmployeeAccount, core.space.Model, {
email,
employee
})
})
})

View File

@ -13,13 +13,13 @@
// limitations under the License.
//
import type { Domain, Type } from '@anticrm/core'
import type { Domain, Type, Ref } from '@anticrm/core'
import { DOMAIN_MODEL } from '@anticrm/core'
import { Builder, Model, Prop, TypeString, UX } from '@anticrm/model'
import type { IntlString, Asset } from '@anticrm/platform'
import core, { TDoc, TType } from '@anticrm/model-core'
import type { Contact, Person, Organization, Employee, Channel, ChannelProvider } from '@anticrm/contact'
import core, { TAccount, TDoc, TType } from '@anticrm/model-core'
import type { Contact, Person, Organization, Employee, Channel, ChannelProvider, EmployeeAccount } from '@anticrm/contact'
import view from '@anticrm/model-view'
import { ids as contact } from './plugin'
@ -77,8 +77,13 @@ export class TOrganization extends TContact implements Organization {
export class TEmployee extends TPerson implements Employee {
}
@Model(contact.class.EmployeeAccount, core.class.Account)
export class TEmployeeAccount extends TAccount implements EmployeeAccount {
employee!: Ref<Employee>
}
export function createModel (builder: Builder): void {
builder.createModel(TChannelProvider, TTypeChannels, TContact, TPerson, TOrganization, TEmployee)
builder.createModel(TChannelProvider, TTypeChannels, TContact, TPerson, TOrganization, TEmployee, TEmployeeAccount)
builder.mixin(contact.class.TypeChannels, core.class.Class, view.mixin.AttributePresenter, {
presenter: contact.component.ChannelsPresenter

View File

@ -15,7 +15,7 @@
import { plugin } from '@anticrm/platform'
import type { Plugin, Asset } from '@anticrm/platform'
import type { Doc, Ref, Class, UXObject, Space } from '@anticrm/core'
import type { Doc, Ref, Class, UXObject, Space, Account } from '@anticrm/core'
/**
* @public
@ -61,7 +61,13 @@ export interface Organization extends Contact {
* @public
*/
export interface Employee extends Person {
}
/**
* @public
*/
export interface EmployeeAccount extends Account {
employee: Ref<Employee>
}
/**
@ -75,7 +81,8 @@ export default plugin(contactId, {
Contact: '' as Ref<Class<Contact>>,
Person: '' as Ref<Class<Person>>,
Organization: '' as Ref<Class<Organization>>,
Employee: '' as Ref<Class<Employee>>
Employee: '' as Ref<Class<Employee>>,
EmployeeAccount: '' as Ref<Class<EmployeeAccount>>
},
icon: {
Phone: '' as Asset,