diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 9cec799090..4a15f9bac1 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -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 }) }) }) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 61c34a1ab4..345a79abd9 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -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 +} + 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 diff --git a/plugins/contact/src/index.ts b/plugins/contact/src/index.ts index eb3d48a301..57e707aa9c 100644 --- a/plugins/contact/src/index.ts +++ b/plugins/contact/src/index.ts @@ -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 } /** @@ -75,7 +81,8 @@ export default plugin(contactId, { Contact: '' as Ref>, Person: '' as Ref>, Organization: '' as Ref>, - Employee: '' as Ref> + Employee: '' as Ref>, + EmployeeAccount: '' as Ref> }, icon: { Phone: '' as Asset,