mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-15 12:55:59 +00:00
UBER-741 Fix collaborators logic (#3594)
Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
parent
cdba698d2a
commit
5933ca81d5
@ -279,7 +279,7 @@ async function getValueCollaborators (value: any, attr: AnyAttribute, control: T
|
|||||||
const hierarchy = control.hierarchy
|
const hierarchy = control.hierarchy
|
||||||
if (attr.type._class === core.class.RefTo) {
|
if (attr.type._class === core.class.RefTo) {
|
||||||
const to = (attr.type as RefTo<Doc>).to
|
const to = (attr.type as RefTo<Doc>).to
|
||||||
if (hierarchy.isDerived(to, contact.mixin.Employee)) {
|
if (hierarchy.isDerived(to, contact.class.Person)) {
|
||||||
const acc = await getPersonAccount(value, control)
|
const acc = await getPersonAccount(value, control)
|
||||||
return acc !== undefined ? [acc._id] : []
|
return acc !== undefined ? [acc._id] : []
|
||||||
} else if (hierarchy.isDerived(to, core.class.Account)) {
|
} else if (hierarchy.isDerived(to, core.class.Account)) {
|
||||||
@ -290,7 +290,7 @@ async function getValueCollaborators (value: any, attr: AnyAttribute, control: T
|
|||||||
const arrOf = (attr.type as ArrOf<RefTo<Doc>>).of
|
const arrOf = (attr.type as ArrOf<RefTo<Doc>>).of
|
||||||
if (arrOf._class === core.class.RefTo) {
|
if (arrOf._class === core.class.RefTo) {
|
||||||
const to = (arrOf as RefTo<Doc>).to
|
const to = (arrOf as RefTo<Doc>).to
|
||||||
if (hierarchy.isDerived(to, contact.mixin.Employee)) {
|
if (hierarchy.isDerived(to, contact.class.Person)) {
|
||||||
const employeeAccounts = await control.modelDb.findAll(contact.class.PersonAccount, {
|
const employeeAccounts = await control.modelDb.findAll(contact.class.PersonAccount, {
|
||||||
person: { $in: Array.isArray(value) ? value : [value] }
|
person: { $in: Array.isArray(value) ? value : [value] }
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||||
// Copyright © 2021, 2022 Hardcore Engineering Inc.
|
// Copyright © 2021, 2022, 2023 Hardcore Engineering Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License. You may
|
// you may not use this file except in compliance with the License. You may
|
||||||
@ -14,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import contact, { Employee, PersonAccount } from '@hcengineering/contact'
|
import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact'
|
||||||
import { Account, Class, Doc, Mixin, Ref, Tx } from '@hcengineering/core'
|
import { Account, Class, Doc, Mixin, Ref, Tx } from '@hcengineering/core'
|
||||||
import { NotificationType } from '@hcengineering/notification'
|
import { NotificationType } from '@hcengineering/notification'
|
||||||
import { Plugin, Resource, plugin } from '@hcengineering/platform'
|
import { Plugin, Resource, plugin } from '@hcengineering/platform'
|
||||||
@ -29,14 +29,14 @@ export const serverNotificationId = 'server-notification' as Plugin
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export async function getPersonAccount (
|
export async function getPersonAccount (
|
||||||
employee: Ref<Employee>,
|
person: Ref<Person>,
|
||||||
control: TriggerControl
|
control: TriggerControl
|
||||||
): Promise<PersonAccount | undefined> {
|
): Promise<PersonAccount | undefined> {
|
||||||
const account = (
|
const account = (
|
||||||
await control.modelDb.findAll(
|
await control.modelDb.findAll(
|
||||||
contact.class.PersonAccount,
|
contact.class.PersonAccount,
|
||||||
{
|
{
|
||||||
employee
|
person
|
||||||
},
|
},
|
||||||
{ limit: 1 }
|
{ limit: 1 }
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user