diff --git a/dev/generator/src/issues.ts b/dev/generator/src/issues.ts index ec56522f77..686772ebb5 100644 --- a/dev/generator/src/issues.ts +++ b/dev/generator/src/issues.ts @@ -49,7 +49,7 @@ export async function generateIssues ( options: IssueOptions ): Promise { const connection = await connect(transactorUrl, workspaceId) - const accounts = await connection.findAll(contact.class.EmployeeAccount, {}) + const accounts = await connection.findAll(contact.class.PersonAccount, {}) const account = faker.random.arrayElement(accounts) const client = new TxOperations(connection, account._id) const ctx = new MeasureMetricsContext('recruit', {}) diff --git a/dev/generator/src/recruit.ts b/dev/generator/src/recruit.ts index 866555e532..27e6c398fa 100644 --- a/dev/generator/src/recruit.ts +++ b/dev/generator/src/recruit.ts @@ -1,4 +1,4 @@ -import contact, { Channel, Employee, EmployeeAccount, Person } from '@hcengineering/contact' +import contact, { Channel, PersonAccount, Person, Employee } from '@hcengineering/contact' import core, { AttachedData, Data, @@ -48,9 +48,9 @@ export async function generateContacts ( ): Promise { const connection = await connect(transactorUrl, workspaceId) - const accounts = await connection.findAll(contact.class.EmployeeAccount, {}) + const accounts = await connection.findAll(contact.class.PersonAccount, {}) const accountIds = accounts.map((a) => a._id) - const emoloyeeIds = accounts.map((a) => a.employee) + const emoloyeeIds = accounts.map((a) => a.person as Ref) const account = faker.random.arrayElement(accounts) @@ -78,7 +78,7 @@ export async function generateContacts ( async function genVacansyApplicants ( ctx: MeasureContext, - accountIds: Ref[], + accountIds: Ref[], options: RecruitOptions, i: number, client: TxOperations, diff --git a/dev/tool/src/benchmark.ts b/dev/tool/src/benchmark.ts index 5ee2889bf4..57db3b64e1 100644 --- a/dev/tool/src/benchmark.ts +++ b/dev/tool/src/benchmark.ts @@ -207,7 +207,7 @@ export async function benchmark ( 'avg', {}, async () => - await monitorConnection?.findAll(contact.class.Employee, {}).then((res) => { + await monitorConnection?.findAll(contact.mixin.Employee, {}).then((res) => { const cur = Date.now() - st opTime += cur moment = cur diff --git a/dev/tool/src/clean.ts b/dev/tool/src/clean.ts index bea7d99aeb..6761480548 100644 --- a/dev/tool/src/clean.ts +++ b/dev/tool/src/clean.ts @@ -76,7 +76,7 @@ export async function cleanWorkspace ( if (opt.recruit) { const contacts = await ops.findAll(recruit.mixin.Candidate, {}) console.log('removing Talents', contacts.length) - const filter = contacts.filter((it) => !hierarchy.isDerived(it._class, contact.class.Employee)) + const filter = contacts.filter((it) => !hierarchy.isDerived(it._class, contact.mixin.Employee)) while (filter.length > 0) { const part = filter.splice(0, 100) diff --git a/dev/tool/src/workspace.ts b/dev/tool/src/workspace.ts index a803e32dbc..ad81664ab9 100644 --- a/dev/tool/src/workspace.ts +++ b/dev/tool/src/workspace.ts @@ -33,7 +33,7 @@ export async function diffWorkspace (mongoUrl: string, workspace: WorkspaceId, r .find({ objectSpace: core.space.Model, modifiedBy: core.account.System, - objectClass: { $ne: contact.class.EmployeeAccount } + objectClass: { $ne: contact.class.PersonAccount } }) .toArray() @@ -41,7 +41,7 @@ export async function diffWorkspace (mongoUrl: string, workspace: WorkspaceId, r return ( tx.objectSpace === core.space.Model && tx.modifiedBy === core.account.System && - (tx as any).objectClass !== contact.class.EmployeeAccount + (tx as any).objectClass !== contact.class.PersonAccount ) }) diff --git a/models/board/src/index.ts b/models/board/src/index.ts index 4d1d65ad52..e807b4e6a0 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -88,10 +88,10 @@ export class TCard extends TTask implements Card { @Index(IndexKind.FullText) location?: string - @Prop(TypeRef(contact.class.Employee), board.string.Assignee) + @Prop(TypeRef(contact.mixin.Employee), board.string.Assignee) declare assignee: Ref | null - @Prop(ArrOf(TypeRef(contact.class.Employee)), board.string.Members) + @Prop(ArrOf(TypeRef(contact.mixin.Employee)), board.string.Members) members?: Ref[] @Prop(TypeCardCover(), board.string.Cover) diff --git a/models/calendar/src/migration.ts b/models/calendar/src/migration.ts index 2a35999fc0..38d63c2182 100644 --- a/models/calendar/src/migration.ts +++ b/models/calendar/src/migration.ts @@ -22,7 +22,7 @@ import contact from '@hcengineering/contact' async function migrateCalendars (tx: TxOperations): Promise { const existCalendars = new Set((await tx.findAll(calendar.class.Calendar, {})).map((p) => p._id)) - const users = await tx.findAll(contact.class.EmployeeAccount, {}) + const users = await tx.findAll(contact.class.PersonAccount, {}) for (const user of users) { if (!existCalendars.has(`${user._id}_calendar` as Ref)) { await tx.createDoc( diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index b5e3cf1f22..ebbba234be 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -27,7 +27,7 @@ import { SavedMessages, ThreadMessage } from '@hcengineering/chunter' -import contact, { Employee } from '@hcengineering/contact' +import contact, { Person } from '@hcengineering/contact' import type { Account, Class, Doc, Domain, Ref, Space, Timestamp } from '@hcengineering/core' import { IndexKind } from '@hcengineering/core' import { @@ -113,8 +113,8 @@ export class TMessage extends TChunterMessage implements Message { declare attachedToClass: Ref> - @Prop(ArrOf(TypeRef(contact.class.Employee)), chunter.string.Replies) - replies?: Ref[] + @Prop(ArrOf(TypeRef(contact.class.Person)), chunter.string.Replies) + replies?: Ref[] repliesCount?: number diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 029783c146..8da46b602d 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -23,7 +23,7 @@ import { Contact, ContactsTab, Employee, - EmployeeAccount, + PersonAccount, GetAvatarUrl, Member, Organization, @@ -39,8 +39,11 @@ import { Collection, Hidden, Index, + Mixin, Model, Prop, + ReadOnly, + TypeBoolean, TypeDate, TypeRef, TypeString, @@ -153,27 +156,30 @@ export class TStatus extends TAttachedDoc implements Status { dueDate!: Timestamp } -@Model(contact.class.Employee, contact.class.Person) +@Mixin(contact.mixin.Employee, contact.class.Person) @UX(contact.string.Employee, contact.icon.Person, 'EMP', 'name') export class TEmployee extends TPerson implements Employee { - active!: boolean + @Prop(TypeBoolean(), contact.string.Active) + @ReadOnly() + @Hidden() + active!: boolean @Prop(Collection(contact.class.Status), contact.string.Status) + @Hidden() statuses?: number - mergedTo?: Ref - @Prop(TypeString(), contact.string.DisplayName) + @Hidden() displayName?: string | null @Prop(TypeString(), contact.string.Position) + @Hidden() position?: string | null } -@Model(contact.class.EmployeeAccount, core.class.Account) -export class TEmployeeAccount extends TAccount implements EmployeeAccount { - employee!: Ref - mergedTo!: Ref +@Model(contact.class.PersonAccount, core.class.Account) +export class TPersonAccount extends TAccount implements PersonAccount { + person!: Ref } @Model(contact.class.Organizations, core.class.Space) @@ -201,14 +207,14 @@ export function createModel (builder: Builder): void { TOrganization, TOrganizations, TEmployee, - TEmployeeAccount, + TPersonAccount, TChannel, TStatus, TMember, TContactsTab ) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ObjectFactory, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ObjectFactory, { component: contact.component.CreateEmployee }) @@ -239,7 +245,7 @@ export function createModel (builder: Builder): void { icon: contact.icon.Person, label: contact.string.Employee, componentProps: { - _class: contact.class.Employee, + _class: contact.mixin.Employee, icon: contact.icon.Person, label: contact.string.Employee, createLabel: contact.string.CreateEmployee, @@ -253,6 +259,9 @@ export function createModel (builder: Builder): void { label: contact.string.Person, componentProps: { _class: contact.class.Person, + baseQuery: { + [contact.mixin.Employee]: { $exists: false } + }, icon: contact.icon.Person, label: contact.string.Person, createLabel: contact.string.CreatePerson, @@ -337,7 +346,7 @@ export function createModel (builder: Builder): void { baseQuery: { _class: { $in: [contact.class.Person], - $nin: [contact.class.Employee] + $nin: [contact.mixin.Employee] } } }, @@ -347,7 +356,7 @@ export function createModel (builder: Builder): void { view.class.Viewlet, core.space.Model, { - attachTo: contact.class.Employee, + attachTo: contact.mixin.Employee, descriptor: view.viewlet.Table, config: [ '', @@ -400,7 +409,7 @@ export function createModel (builder: Builder): void { pinned: true }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ObjectEditor, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ObjectEditor, { editor: contact.component.EditEmployee, pinned: true }) @@ -418,7 +427,7 @@ export function createModel (builder: Builder): void { editor: contact.component.Members }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ArrayEditor, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ArrayEditor, { inlineEditor: contact.component.EmployeeArrayEditor }) @@ -450,7 +459,7 @@ export function createModel (builder: Builder): void { inlineEditor: contact.component.PersonEditor }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributeEditor, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.AttributeEditor, { inlineEditor: contact.component.EmployeeEditor }) @@ -466,15 +475,15 @@ export function createModel (builder: Builder): void { encode: contact.function.GetContactLink }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributeFilterPresenter, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.AttributeFilterPresenter, { presenter: contact.component.EmployeeFilterValuePresenter }) builder.mixin(core.class.Account, core.class.Class, view.mixin.AttributeFilterPresenter, { - presenter: contact.component.EmployeeAccountFilterValuePresenter + presenter: contact.component.PersonAccountFilterValuePresenter }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributeFilter, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.AttributeFilter, { component: contact.component.EmployeeFilter }) @@ -621,15 +630,15 @@ export function createModel (builder: Builder): void { inlineEditor: contact.component.AccountArrayEditor }) - builder.mixin(contact.class.EmployeeAccount, core.class.Class, view.mixin.ArrayEditor, { + builder.mixin(contact.class.PersonAccount, core.class.Class, view.mixin.ArrayEditor, { inlineEditor: contact.component.AccountArrayEditor }) builder.mixin(core.class.Account, core.class.Class, view.mixin.ObjectPresenter, { - presenter: contact.component.EmployeeAccountPresenter + presenter: contact.component.PersonAccountPresenter }) builder.mixin(core.class.Account, core.class.Class, view.mixin.AttributePresenter, { - presenter: contact.component.EmployeeAccountRefPresenter + presenter: contact.component.PersonAccountRefPresenter }) builder.mixin(contact.class.Organization, core.class.Class, view.mixin.ObjectPresenter, { @@ -640,11 +649,11 @@ export function createModel (builder: Builder): void { presenter: contact.component.ContactPresenter }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ObjectPresenter, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ObjectPresenter, { presenter: contact.component.EmployeePresenter }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.SortFuncs, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.SortFuncs, { func: contact.function.EmployeeSort }) @@ -656,11 +665,11 @@ export function createModel (builder: Builder): void { presenter: contact.component.ContactRefPresenter }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributePresenter, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.AttributePresenter, { presenter: contact.component.EmployeeRefPresenter }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.IgnoreActions, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.IgnoreActions, { actions: [view.action.Delete] }) @@ -671,7 +680,7 @@ export function createModel (builder: Builder): void { builder.mixin(contact.class.Person, core.class.Class, view.mixin.ClassFilters, { filters: [] }) - builder.mixin(contact.class.Employee, core.class.Class, view.mixin.ClassFilters, { + builder.mixin(contact.mixin.Employee, core.class.Class, view.mixin.ClassFilters, { filters: [] }) builder.mixin(contact.class.Organization, core.class.Class, view.mixin.ClassFilters, { @@ -737,7 +746,7 @@ export function createModel (builder: Builder): void { active: true }, category: contact.category.Contact, - target: contact.class.Employee, + target: contact.mixin.Employee, input: 'focus', context: { mode: ['context'], @@ -757,7 +766,7 @@ export function createModel (builder: Builder): void { active: false }, category: contact.category.Contact, - target: contact.class.Employee, + target: contact.mixin.Employee, input: 'focus', context: { mode: ['context'], @@ -773,18 +782,16 @@ export function createModel (builder: Builder): void { { action: view.actionImpl.ShowPopup, actionProps: { - component: contact.component.MergeEmployee, + component: contact.component.MergePersons, element: 'top', fillProps: { _object: 'value' } }, - query: { - active: false - }, - label: contact.string.MergeEmployee, + query: {}, + label: contact.string.MergePersons, category: contact.category.Contact, - target: contact.class.Employee, + target: contact.class.Person, input: 'focus', context: { mode: ['context'], @@ -792,7 +799,7 @@ export function createModel (builder: Builder): void { }, secured: true }, - contact.action.MergeEmployee + contact.action.MergePersons ) // Allow to use fuzzy search for mixins diff --git a/models/contact/src/migration.ts b/models/contact/src/migration.ts index 5495368f3f..942176122e 100644 --- a/models/contact/src/migration.ts +++ b/models/contact/src/migration.ts @@ -1,9 +1,11 @@ // -import { TxOperations } from '@hcengineering/core' +import { Class, DOMAIN_TX, Doc, Domain, Ref, TxOperations } from '@hcengineering/core' import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model' +import { DOMAIN_COMMENT } from '@hcengineering/model-chunter' import core from '@hcengineering/model-core' -import contact from './index' +import { DOMAIN_VIEW } from '@hcengineering/model-view' +import contact, { DOMAIN_CONTACT } from './index' async function createSpace (tx: TxOperations): Promise { const current = await tx.findOne(core.class.Space, { @@ -43,14 +45,14 @@ async function createSpace (tx: TxOperations): Promise { } async function createEmployeeEmail (client: TxOperations): Promise { - const employees = await client.findAll(contact.class.Employee, {}) + const employees = await client.findAll(contact.mixin.Employee, {}) const channels = await client.findAll(contact.class.Channel, { provider: contact.channelProvider.Email, attachedTo: { $in: employees.map((p) => p._id) } }) const channelsMap = new Map(channels.map((p) => [p.attachedTo, p])) for (const employee of employees) { - const acc = await client.findOne(contact.class.EmployeeAccount, { employee: employee._id }) + const acc = await client.findOne(contact.class.PersonAccount, { person: employee._id }) if (acc === undefined) continue const current = channelsMap.get(employee._id) if (current === undefined) { @@ -58,7 +60,7 @@ async function createEmployeeEmail (client: TxOperations): Promise { contact.class.Channel, contact.space.Contacts, employee._id, - contact.class.Employee, + contact.mixin.Employee, 'channels', { provider: contact.channelProvider.Email, @@ -74,7 +76,88 @@ async function createEmployeeEmail (client: TxOperations): Promise { } export const contactOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, + async migrate (client: MigrationClient): Promise { + await client.update( + DOMAIN_TX, + { + objectClass: 'contact:class:EmployeeAccount' + }, + { + $rename: { 'attributes.employee': 'attributes.person' }, + $set: { objectClass: contact.class.PersonAccount } + } + ) + + await client.update( + DOMAIN_TX, + { + objectClass: 'contact:class:Employee' + }, + { + $set: { objectClass: contact.mixin.Employee } + } + ) + + await client.update( + DOMAIN_TX, + { + 'tx.attributes.backlinkClass': 'contact:class:Employee' + }, + { + $set: { 'tx.attributes.backlinkClass': contact.mixin.Employee } + } + ) + + await client.update( + DOMAIN_TX, + { + 'tx.attributes.backlinkClass': 'contact:class:Employee' + }, + { + $set: { 'tx.attributes.backlinkClass': contact.mixin.Employee } + } + ) + + for (const d of client.hierarchy.domains()) { + await client.update( + d, + { attachedToClass: 'contact:class:Employee' }, + { $set: { attachedToClass: contact.mixin.Employee } } + ) + } + await client.update( + DOMAIN_COMMENT, + { backlinkClass: 'contact:class:Employee' }, + { $set: { backlinkClass: contact.mixin.Employee } } + ) + await client.update( + 'tags' as Domain, + { targetClass: 'contact:class:Employee' }, + { $set: { targetClass: contact.mixin.Employee } } + ) + await client.update( + DOMAIN_VIEW, + { filterClass: 'contact:class:Employee' }, + { $set: { filterClass: contact.mixin.Employee } } + ) + await client.update( + DOMAIN_CONTACT, + { + _class: 'contact:class:Employee' as Ref> + }, + { + $rename: { + active: `${contact.mixin.Employee as string}.active`, + statuses: `${contact.mixin.Employee as string}.statuses`, + displayName: `${contact.mixin.Employee as string}.displayName`, + position: `${contact.mixin.Employee as string}.position` + }, + $set: { + _class: contact.class.Person + } + } + ) + }, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) await createSpace(tx) diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 79946f6c10..0f046552a8 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -36,8 +36,8 @@ export default mergeIds(contactId, contact, { OrganizationPresenter: '' as AnyComponent, Contacts: '' as AnyComponent, ContactsTabs: '' as AnyComponent, - EmployeeAccountPresenter: '' as AnyComponent, - EmployeeAccountRefPresenter: '' as AnyComponent, + PersonAccountPresenter: '' as AnyComponent, + PersonAccountRefPresenter: '' as AnyComponent, OrganizationEditor: '' as AnyComponent, EmployeePresenter: '' as AnyComponent, EmployeeRefPresenter: '' as AnyComponent, @@ -52,13 +52,13 @@ export default mergeIds(contactId, contact, { CreateEmployee: '' as AnyComponent, AccountArrayEditor: '' as AnyComponent, ChannelFilter: '' as AnyComponent, - MergeEmployee: '' as AnyComponent, + MergePersons: '' as AnyComponent, ActivityChannelMessage: '' as AnyComponent, ChannelPanel: '' as AnyComponent, ActivityChannelPresenter: '' as AnyComponent, EmployeeFilter: '' as AnyComponent, EmployeeFilterValuePresenter: '' as AnyComponent, - EmployeeAccountFilterValuePresenter: '' as AnyComponent + PersonAccountFilterValuePresenter: '' as AnyComponent }, string: { Persons: '' as IntlString, @@ -114,7 +114,7 @@ export default mergeIds(contactId, contact, { action: { KickEmployee: '' as Ref, DeleteEmployee: '' as Ref, - MergeEmployee: '' as Ref + MergePersons: '' as Ref }, actionImpl: { KickEmployee: '' as ViewAction, diff --git a/models/document/src/index.ts b/models/document/src/index.ts index 492b65bf7f..aba886af6e 100644 --- a/models/document/src/index.ts +++ b/models/document/src/index.ts @@ -133,13 +133,13 @@ export class TDocument extends TDoc implements Document { @Hidden() versions!: number - @Prop(ArrOf(TypeRef(contact.class.Employee)), document.string.Authors) + @Prop(ArrOf(TypeRef(contact.mixin.Employee)), document.string.Authors) authors!: Ref[] - @Prop(ArrOf(TypeRef(contact.class.Employee)), document.string.Reviewers) + @Prop(ArrOf(TypeRef(contact.mixin.Employee)), document.string.Reviewers) reviewers!: Ref[] - @Prop(ArrOf(TypeRef(contact.class.Employee)), document.string.Approvers) + @Prop(ArrOf(TypeRef(contact.mixin.Employee)), document.string.Approvers) approvers!: Ref[] @Prop(Collection(document.class.DocumentRequest), document.string.Requests) diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 2ae5d2e3c9..4b5721c0b9 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -43,7 +43,7 @@ import { import attachment from '@hcengineering/model-attachment' import calendar from '@hcengineering/model-calendar' import chunter from '@hcengineering/model-chunter' -import contact, { TEmployee, TEmployeeAccount } from '@hcengineering/model-contact' +import contact, { TEmployee, TPersonAccount } from '@hcengineering/model-contact' import core, { TAttachedDoc, TDoc, TSpace, TType } from '@hcengineering/model-core' import view, { classPresenter, createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' @@ -80,7 +80,7 @@ export class TDepartment extends TSpace implements Department { avatar?: string | null - @Prop(TypeRef(contact.class.Employee), hr.string.TeamLead) + @Prop(TypeRef(contact.mixin.Employee), hr.string.TeamLead) teamLead!: Ref | null @Prop(ArrOf(TypeRef(hr.class.DepartmentMember)), contact.string.Members) @@ -89,15 +89,15 @@ export class TDepartment extends TSpace implements Department { @Prop(ArrOf(TypeRef(contact.class.Contact)), hr.string.Subscribers) subscribers?: Arr> - @Prop(ArrOf(TypeRef(contact.class.Employee)), hr.string.Managers) + @Prop(ArrOf(TypeRef(contact.mixin.Employee)), hr.string.Managers) managers!: Arr> } -@Model(hr.class.DepartmentMember, contact.class.EmployeeAccount) +@Model(hr.class.DepartmentMember, contact.class.PersonAccount) @UX(contact.string.Employee, hr.icon.HR) -export class TDepartmentMember extends TEmployeeAccount implements DepartmentMember {} +export class TDepartmentMember extends TPersonAccount implements DepartmentMember {} -@Mixin(hr.mixin.Staff, contact.class.Employee) +@Mixin(hr.mixin.Staff, contact.mixin.Employee) @UX(hr.string.Staff, hr.icon.HR, 'STFF', 'name') export class TStaff extends TEmployee implements Staff { @Prop(TypeRef(hr.class.Department), hr.string.Department) diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 4328121a13..d4bdbc44df 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -78,7 +78,7 @@ export class TLead extends TTask implements Lead { @Index(IndexKind.FullText) title!: string - @Prop(TypeRef(contact.class.Employee), lead.string.Assignee) + @Prop(TypeRef(contact.mixin.Employee), lead.string.Assignee) declare assignee: Ref | null @Prop(TypeRef(task.class.State), task.string.TaskState, { _id: task.attribute.State }) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 7b5fb162c0..4b69794a39 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -162,7 +162,7 @@ export class TApplicant extends TTask implements Applicant { @Prop(TypeDate(), task.string.StartDate) startDate!: Timestamp | null - @Prop(TypeRef(contact.class.Employee), recruit.string.AssignedRecruiter) + @Prop(TypeRef(contact.mixin.Employee), recruit.string.AssignedRecruiter) declare assignee: Ref | null @Prop(TypeRef(task.class.State), task.string.TaskState, { _id: task.attribute.State }) @@ -1105,7 +1105,7 @@ export function createModel (builder: Builder): void { actionPopup: view.component.ValueSelector, actionProps: { attribute: 'assignee', - _class: contact.class.Employee, + _class: contact.mixin.Employee, query: {}, placeholder: recruit.string.AssignRecruiter }, diff --git a/models/recruit/src/review.ts b/models/recruit/src/review.ts index 0a43603106..099af76e78 100644 --- a/models/recruit/src/review.ts +++ b/models/recruit/src/review.ts @@ -13,7 +13,7 @@ import { generateClassNotificationTypes } from '@hcengineering/model-notificatio export const reviewTableOptions: FindOptions = { lookup: { attachedTo: recruit.mixin.Candidate, - participants: contact.class.Employee, + participants: contact.mixin.Employee, company: contact.class.Organization } } diff --git a/models/request/src/index.ts b/models/request/src/index.ts index 6d19fd6de4..3a1921d813 100644 --- a/models/request/src/index.ts +++ b/models/request/src/index.ts @@ -15,7 +15,7 @@ import activity from '@hcengineering/activity' import chunter from '@hcengineering/chunter' -import type { EmployeeAccount } from '@hcengineering/contact' +import type { PersonAccount } from '@hcengineering/contact' import contact from '@hcengineering/contact' import { Domain, IndexKind, Ref, Tx } from '@hcengineering/core' import { @@ -48,13 +48,13 @@ export const DOMAIN_REQUEST = 'request' as Domain @Model(request.class.Request, core.class.AttachedDoc, DOMAIN_REQUEST) @UX(request.string.Request, request.icon.Requests) export class TRequest extends TAttachedDoc implements Request { - @Prop(ArrOf(TypeRef(contact.class.EmployeeAccount)), request.string.Requested) + @Prop(ArrOf(TypeRef(contact.class.PersonAccount)), request.string.Requested) @Index(IndexKind.Indexed) - requested!: Ref[] + requested!: Ref[] - @Prop(ArrOf(TypeRef(contact.class.EmployeeAccount)), request.string.Approved) + @Prop(ArrOf(TypeRef(contact.class.PersonAccount)), request.string.Approved) @ReadOnly() - approved!: Ref[] + approved!: Ref[] requiredApprovesCount!: number @@ -64,9 +64,9 @@ export class TRequest extends TAttachedDoc implements Request { tx!: Tx - @Prop(TypeRef(contact.class.EmployeeAccount), request.string.Rejected) + @Prop(TypeRef(contact.class.PersonAccount), request.string.Rejected) @ReadOnly() - rejected?: Ref + rejected?: Ref @Prop(Collection(chunter.class.Comment), chunter.string.Comments) comments?: number diff --git a/models/server-calendar/src/index.ts b/models/server-calendar/src/index.ts index b70670f11d..53b8353560 100644 --- a/models/server-calendar/src/index.ts +++ b/models/server-calendar/src/index.ts @@ -34,10 +34,10 @@ export function createModel (builder: Builder): void { }) builder.createDoc(serverCore.class.Trigger, core.space.Model, { - trigger: serverCalendar.trigger.OnEmployeeAccountCreate, + trigger: serverCalendar.trigger.OnPersonAccountCreate, txMatch: { _class: core.class.TxCreateDoc, - objectClass: contact.class.EmployeeAccount + objectClass: contact.class.PersonAccount } }) diff --git a/models/server-contact/src/index.ts b/models/server-contact/src/index.ts index 54e35744b3..43bd02ea71 100644 --- a/models/server-contact/src/index.ts +++ b/models/server-contact/src/index.ts @@ -55,12 +55,4 @@ export function createModel (builder: Builder): void { _class: core.class.TxUpdateDoc } }) - - builder.createDoc(serverCore.class.Trigger, core.space.Model, { - trigger: serverContact.trigger.OnEmployeeUpdate, - txMatch: { - objectClass: contact.class.Employee, - _class: core.class.TxUpdateDoc - } - }) } diff --git a/models/task/src/index.ts b/models/task/src/index.ts index e9cea8f587..3ceb17f187 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import type { Employee } from '@hcengineering/contact' +import type { Employee, Person } from '@hcengineering/contact' import contact from '@hcengineering/contact' import attachment from '@hcengineering/model-attachment' import chunter from '@hcengineering/model-chunter' @@ -101,8 +101,8 @@ export class TTask extends TAttachedDoc implements Task { @Hidden() number!: number - // @Prop(TypeRef(contact.class.Employee), task.string.TaskAssignee) - assignee!: Ref | null + // @Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee) + assignee!: Ref | null @Prop(TypeDate(), task.string.DueDate, { editor: task.component.DueDateEditor }) dueDate!: Timestamp | null @@ -126,7 +126,7 @@ export class TTodoItem extends TAttachedDoc implements TodoItem { @Index(IndexKind.FullText) name!: string - @Prop(TypeRef(contact.class.Employee), task.string.TaskAssignee) + @Prop(TypeRef(contact.mixin.Employee), task.string.TaskAssignee) assignee!: Ref | null @Prop(TypeBoolean(), task.string.TaskDone) diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index c877a83b37..0c951dfd51 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -14,7 +14,7 @@ // import activity from '@hcengineering/activity' -import contact, { Employee } from '@hcengineering/contact' +import contact, { Employee, Person } from '@hcengineering/contact' import { DOMAIN_MODEL, DateRangeMode, @@ -135,7 +135,7 @@ export class TProject extends TSpaceWithStates implements Project { @Prop(TypeRef(tracker.class.IssueStatus), tracker.string.DefaultIssueStatus) defaultIssueStatus!: Ref - @Prop(TypeRef(contact.class.Employee), tracker.string.DefaultAssignee) + @Prop(TypeRef(contact.mixin.Employee), tracker.string.DefaultAssignee) defaultAssignee!: Ref declare defaultTimeReportDay: TimeReportDayType @@ -183,9 +183,9 @@ export class TIssue extends TTask implements Issue { @ReadOnly() number!: number - @Prop(TypeRef(contact.class.Employee), tracker.string.Assignee) + @Prop(TypeRef(contact.class.Person), tracker.string.Assignee) @Index(IndexKind.Indexed) - assignee!: Ref | null + assignee!: Ref | null @Prop(TypeRef(tracker.class.Component), tracker.string.Component, { icon: tracker.icon.Component }) @Index(IndexKind.Indexed) @@ -256,8 +256,8 @@ export class TIssueTemplate extends TDoc implements IssueTemplate { @Prop(TypeIssuePriority(), tracker.string.Priority) priority!: IssuePriority - @Prop(TypeRef(contact.class.Employee), tracker.string.Assignee) - assignee!: Ref | null + @Prop(TypeRef(contact.class.Person), tracker.string.Assignee) + assignee!: Ref | null @Prop(TypeRef(tracker.class.Component), tracker.string.Component) component!: Ref | null @@ -298,7 +298,7 @@ export class TTimeSpendReport extends TAttachedDoc implements TimeSpendReport { @Prop(TypeRef(tracker.class.Issue), tracker.string.Parent) declare attachedTo: Ref - @Prop(TypeRef(contact.class.Employee), contact.string.Employee) + @Prop(TypeRef(contact.mixin.Employee), contact.string.Employee) employee!: Ref @Prop(TypeDate(), tracker.string.TimeSpendReportDate) @@ -324,7 +324,7 @@ export class TComponent extends TDoc implements Component { @Prop(TypeMarkup(), tracker.string.Description) description?: Markup - @Prop(TypeRef(contact.class.Employee), tracker.string.ComponentLead) + @Prop(TypeRef(contact.mixin.Employee), tracker.string.ComponentLead) lead!: Ref | null @Prop(Collection(chunter.class.Comment), chunter.string.Comments) @@ -1584,7 +1584,7 @@ export function createModel (builder: Builder): void { actionPopup: view.component.ValueSelector, actionProps: { attribute: 'assignee', - _class: contact.class.Employee, + _class: contact.mixin.Employee, query: {}, placeholder: tracker.string.AssignTo }, @@ -2006,7 +2006,7 @@ export function createModel (builder: Builder): void { dividerBefore: true, key: 'lead' }, - props: { _class: tracker.class.Component, defaultClass: contact.class.Employee, shouldShowLabel: false } + props: { _class: tracker.class.Component, defaultClass: contact.mixin.Employee, shouldShowLabel: false } } ] }, diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 5791a59f39..a8601caa03 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -279,16 +279,17 @@ async function loadModel ( console.log('find' + (lastTxTime >= 0 ? 'full model' : 'model diff'), atxes.length, Date.now() - t) // Ignore Employee accounts. - function isEmployeeAccount (tx: Tx): boolean { + function isPersonAccount (tx: Tx): boolean { return ( (tx._class === core.class.TxCreateDoc || tx._class === core.class.TxUpdateDoc || tx._class === core.class.TxRemoveDoc) && - (tx as TxCUD).objectClass === 'contact:class:EmployeeAccount' + ((tx as TxCUD).objectClass === 'contact:class:PersonAccount' || + (tx as TxCUD).objectClass === 'contact:class:Account') ) } - atxes.forEach((tx) => (tx.modifiedBy === core.account.System && !isEmployeeAccount(tx) ? systemTx : userTx).push(tx)) + atxes.forEach((tx) => (tx.modifiedBy === core.account.System && !isPersonAccount(tx) ? systemTx : userTx).push(tx)) if (allowedPlugins != null) { fillConfiguration(systemTx, configs) diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 396d5a2b68..040ee91286 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -227,10 +227,11 @@ export class TxOperations implements Omit { modifiedBy?: Ref ): Promise { const hierarchy = this.client.getHierarchy() - if (hierarchy.isMixin(doc._class)) { + const mixClass = Hierarchy.mixinOrClass(doc) + if (hierarchy.isMixin(mixClass)) { // TODO: Rework it is wrong, we need to split values to mixin update and original document update if mixed. const baseClass = hierarchy.getBaseClass(doc._class) - return this.updateMixin(doc._id, baseClass, doc.space, doc._class, update, modifiedOn, modifiedBy) + return this.updateMixin(doc._id, baseClass, doc.space, mixClass, update, modifiedOn, modifiedBy) } if (hierarchy.isDerived(doc._class, core.class.AttachedDoc)) { const adoc = doc as unknown as AttachedDoc diff --git a/packages/platform/src/lang/en.json b/packages/platform/src/lang/en.json index 90d2718155..8a5fc3fd8f 100644 --- a/packages/platform/src/lang/en.json +++ b/packages/platform/src/lang/en.json @@ -16,7 +16,6 @@ "AccountAlreadyExists": "Account already exists", "WorkspaceRateLimit": "Server is busy, Please wait a bit and try again", "AccountAlreadyConfirmed": "Account already confirmed", - "AccountWasMerged": "Account was merged", "WorkspaceAlreadyExists": "Workspace already exists", "ProductIdMismatch": "Product Mismatch" } diff --git a/packages/platform/src/lang/ru.json b/packages/platform/src/lang/ru.json index c23c9cc331..8114333e32 100644 --- a/packages/platform/src/lang/ru.json +++ b/packages/platform/src/lang/ru.json @@ -16,7 +16,6 @@ "AccountAlreadyExists": "Аккаунт уже существует", "WorkspaceRateLimit": "Сервер перегружен, Пожалуйста подождите", "AccountAlreadyConfirmed": "Аккаунт уже подтвержден", - "AccountWasMerged": "Аккаунт был объединен", "WorkspaceAlreadyExists": "Рабочее пространство уже существует", "ProductIdMismatch": "Продукт не соответсвует" } diff --git a/packages/platform/src/platform.ts b/packages/platform/src/platform.ts index 8db4f0c7da..67714eb691 100644 --- a/packages/platform/src/platform.ts +++ b/packages/platform/src/platform.ts @@ -150,7 +150,6 @@ export default plugin(platformId, { InvalidPassword: '' as StatusCode<{ account: string }>, AccountAlreadyExists: '' as StatusCode<{ account: string }>, AccountAlreadyConfirmed: '' as StatusCode<{ account: string }>, - AccountWasMerged: '' as StatusCode<{ account: string }>, WorkspaceAlreadyExists: '' as StatusCode<{ workspace: string }>, WorkspaceRateLimit: '' as StatusCode<{ workspace: string }>, ProductIdMismatch: '' as StatusCode<{ productId: string }> diff --git a/packages/presentation/src/components/AttributeBarEditor.svelte b/packages/presentation/src/components/AttributeBarEditor.svelte index bd816bf838..bf66f27a0a 100644 --- a/packages/presentation/src/components/AttributeBarEditor.svelte +++ b/packages/presentation/src/components/AttributeBarEditor.svelte @@ -76,6 +76,7 @@ [] | undefined = undefined + export let filter: (it: Doc) => boolean = () => { + return true + } + const created: Doc[] = [] const dispatch = createEventDispatcher() @@ -75,9 +79,9 @@ }) if (created.length > 0) { const cmap = new Set(created.map((it) => it._id)) - objects = [...created, ...result.filter((d) => !cmap.has(d._id))] + objects = [...created, ...result.filter((d) => !cmap.has(d._id))].filter(filter) } else { - objects = result + objects = result.filter(filter) } }, { ...(options ?? {}), limit: 200 } diff --git a/packages/presentation/src/components/message/Nodes.svelte b/packages/presentation/src/components/message/Nodes.svelte index 4f00377d30..e36bc38fc3 100644 --- a/packages/presentation/src/components/message/Nodes.svelte +++ b/packages/presentation/src/components/message/Nodes.svelte @@ -48,6 +48,12 @@ } } catch {} } + function correctClass (clName: string): string { + if (clName === 'contact:class:Employee') { + return 'contact:mixin:Employee' + } + return clName + } {#if nodes} @@ -121,7 +127,7 @@ props={{ objectId: node.getAttribute('data-id'), title: node.getAttribute('data-label'), - _class: node.getAttribute('data-objectclass'), + _class: correctClass(node.getAttribute('data-objectclass')), inline: true }} /> diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index f4d137a1a7..20e9596891 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -17,7 +17,7 @@ import type { DisplayTx, TxViewlet } from '@hcengineering/activity' import attachment from '@hcengineering/attachment' import chunter from '@hcengineering/chunter' - import contact, { Employee, EmployeeAccount, getName } from '@hcengineering/contact' + import contact, { Employee, PersonAccount, getName } from '@hcengineering/contact' import core, { AnyAttribute, Class, Doc, Ref, TxCUD, getCurrentAccount } from '@hcengineering/core' import { Asset } from '@hcengineering/platform' import { createQuery, getClient } from '@hcengineering/presentation' @@ -55,7 +55,7 @@ let viewlet: TxDisplayViewlet | undefined let props: any - let account: EmployeeAccount | undefined + let account: PersonAccount | undefined let employee: Employee | undefined let model: AttributeModel[] = [] let modelIcon: Asset | undefined = undefined @@ -97,8 +97,8 @@ }) $: query.query( - contact.class.EmployeeAccount, - { _id: tx.tx.modifiedBy as Ref }, + contact.class.PersonAccount, + { _id: tx.tx.modifiedBy as Ref }, (res) => { ;[account] = res }, @@ -107,8 +107,8 @@ $: account && employeeQuery.query( - contact.class.Employee, - { _id: account.employee }, + contact.mixin.Employee, + { _id: account.person as Ref }, (res) => { ;[employee] = res }, @@ -213,7 +213,7 @@
{#if employee} - {getName(employee)} + {getName(client.getHierarchy(), employee)} {:else}