Skip to content

Commit

Permalink
UBER-665: Rename EmployeeAccount->PersonAccount (#3550)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo authored and annano committed Aug 24, 2023
1 parent 416a5f0 commit 1b54804
Show file tree
Hide file tree
Showing 181 changed files with 1,214 additions and 1,158 deletions.
2 changes: 1 addition & 1 deletion dev/generator/src/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function generateIssues (
options: IssueOptions
): Promise<void> {
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', {})
Expand Down
8 changes: 4 additions & 4 deletions dev/generator/src/recruit.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -48,9 +48,9 @@ export async function generateContacts (
): Promise<void> {
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<Employee>)

const account = faker.random.arrayElement(accounts)

Expand Down Expand Up @@ -78,7 +78,7 @@ export async function generateContacts (

async function genVacansyApplicants (
ctx: MeasureContext,
accountIds: Ref<EmployeeAccount>[],
accountIds: Ref<PersonAccount>[],
options: RecruitOptions,
i: number,
client: TxOperations,
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions dev/tool/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export async function diffWorkspace (mongoUrl: string, workspace: WorkspaceId, r
.find<Tx>({
objectSpace: core.space.Model,
modifiedBy: core.account.System,
objectClass: { $ne: contact.class.EmployeeAccount }
objectClass: { $ne: contact.class.PersonAccount }
})
.toArray()

const txes = rawTxes.filter((tx) => {
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
)
})

Expand Down
4 changes: 2 additions & 2 deletions models/board/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Employee> | null

@Prop(ArrOf(TypeRef(contact.class.Employee)), board.string.Members)
@Prop(ArrOf(TypeRef(contact.mixin.Employee)), board.string.Members)
members?: Ref<Employee>[]

@Prop(TypeCardCover(), board.string.Cover)
Expand Down
2 changes: 1 addition & 1 deletion models/calendar/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import contact from '@hcengineering/contact'

async function migrateCalendars (tx: TxOperations): Promise<void> {
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<Calendar>)) {
await tx.createDoc(
Expand Down
6 changes: 3 additions & 3 deletions models/chunter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -113,8 +113,8 @@ export class TMessage extends TChunterMessage implements Message {

declare attachedToClass: Ref<Class<Space>>

@Prop(ArrOf(TypeRef(contact.class.Employee)), chunter.string.Replies)
replies?: Ref<Employee>[]
@Prop(ArrOf(TypeRef(contact.class.Person)), chunter.string.Replies)
replies?: Ref<Person>[]

repliesCount?: number

Expand Down
81 changes: 44 additions & 37 deletions models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
Contact,
ContactsTab,
Employee,
EmployeeAccount,
PersonAccount,
GetAvatarUrl,
Member,
Organization,
Expand All @@ -39,8 +39,11 @@ import {
Collection,
Hidden,
Index,
Mixin,
Model,
Prop,
ReadOnly,
TypeBoolean,
TypeDate,
TypeRef,
TypeString,
Expand Down Expand Up @@ -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<Employee>

@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<Employee>
mergedTo!: Ref<EmployeeAccount>
@Model(contact.class.PersonAccount, core.class.Account)
export class TPersonAccount extends TAccount implements PersonAccount {
person!: Ref<Person>
}

@Model(contact.class.Organizations, core.class.Space)
Expand Down Expand Up @@ -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
})

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -337,7 +346,7 @@ export function createModel (builder: Builder): void {
baseQuery: {
_class: {
$in: [contact.class.Person],
$nin: [contact.class.Employee]
$nin: [contact.mixin.Employee]
}
}
},
Expand All @@ -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: [
'',
Expand Down Expand Up @@ -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
})
Expand All @@ -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
})

Expand Down Expand Up @@ -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
})

Expand All @@ -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
})

Expand Down Expand Up @@ -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, {
Expand All @@ -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
})

Expand All @@ -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]
})

Expand All @@ -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, {
Expand Down Expand Up @@ -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'],
Expand All @@ -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'],
Expand All @@ -773,26 +782,24 @@ 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'],
group: 'remove'
},
secured: true
},
contact.action.MergeEmployee
contact.action.MergePersons
)

// Allow to use fuzzy search for mixins
Expand Down
Loading

0 comments on commit 1b54804

Please sign in to comment.