Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
AccountRole,
AccountUuid,
Expand Down Expand Up @@ -51,6 +51,8 @@
let roles = client.getModel().findAllSync(card.class.Role, { types: { $in: types } })
$: roles = client.getModel().findAllSync(card.class.Role, { types: { $in: types } })

$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)

let name: string = space?.name ?? ''

let isPrivate: boolean = space?.private ?? false
Expand Down Expand Up @@ -247,6 +249,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
16 changes: 16 additions & 0 deletions plugins/contact-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import core, {
type Permission,
type PersonId,
pickPrimarySocialId,
readOnlyGuestAccountUuid,
type Ref,
type SocialId,
SocialIdType,
Expand Down Expand Up @@ -373,6 +374,21 @@ export const primarySocialIdByEmployeeRefStore = writable<Map<Ref<Employee>, Per
*/
export const employeeRefByAccountUuidStore = writable<Map<AccountUuid, Ref<Employee>>>(new Map())

/**
* {@link Ref}<{@link Person}>[] for `excludeItems` so the read-only anonymous guest does not appear in the picker
* when not already selected. If they are in `selectedAccountUuids`, returns [] so they stay visible among chips.
*/
export function getAnonymousRefs (
byAccount: Map<AccountUuid, Ref<Employee>>,
selectedAccountUuids: readonly AccountUuid[] = []
): Array<Ref<Person>> {
if (selectedAccountUuids.includes(readOnlyGuestAccountUuid)) {
return []
}
const ref = byAccount.get(readOnlyGuestAccountUuid)
return ref !== undefined ? [ref as unknown as Ref<Person>] : []
}

/**
* [PersonId (social ID) => Employee] mapping
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte'
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
Data,
DocumentUpdate,
Expand Down Expand Up @@ -58,6 +58,7 @@

$: isNew = docSpace === undefined
$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)

let typeId: Ref<DocumentSpaceType> | undefined = docSpace?.type ?? documents.spaceType.DocumentSpaceType
let spaceType: WithLookup<DocumentSpaceType> | undefined
Expand Down Expand Up @@ -283,6 +284,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-->
<script lang="ts">
import { deepEqual } from 'fast-equals'
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
Data,
DocumentUpdate,
Expand Down Expand Up @@ -71,6 +71,7 @@

$: isNew = teamspace === undefined
$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)

let typeId: Ref<SpaceType> | undefined = teamspace?.type ?? document.spaceType.DefaultTeamspaceType
let spaceType: WithLookup<SpaceType> | undefined
Expand Down Expand Up @@ -377,6 +378,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
4 changes: 3 additions & 1 deletion plugins/drive-resources/src/components/CreateDrive.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte'
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
Data,
RolesAssignment,
Expand Down Expand Up @@ -58,6 +58,7 @@
let spaceType: WithLookup<SpaceType> | undefined

$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)
$: void loadSpaceType(typeId)
const loadSpaceType = reduceCalls(async (id: typeof typeId): Promise<void> => {
spaceType =
Expand Down Expand Up @@ -248,6 +249,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
4 changes: 3 additions & 1 deletion plugins/lead-resources/src/components/CreateFunnel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
-->
<script lang="ts">
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
getCurrentAccount,
Ref,
Expand Down Expand Up @@ -56,6 +56,7 @@
let owners: AccountUuid[] = funnel?.owners !== undefined ? hierarchy.clone(funnel.owners) : [getCurrentAccount().uuid]

$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)
$: void loadSpaceType(typeId)
async function loadSpaceType (id: typeof typeId): Promise<void> {
spaceType =
Expand Down Expand Up @@ -230,6 +231,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { type Product, ProductVersionState } from '@hcengineering/products'
import { type Attachment } from '@hcengineering/attachment'
import { AttachmentPresenter, AttachmentStyledBox } from '@hcengineering/attachment-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import core, {
AccountUuid,
Data,
Expand Down Expand Up @@ -72,6 +72,7 @@
let spaceType: WithLookup<SpaceType> | undefined

$: membersPersons = object.members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, object.owners ?? [])

let roles: Role[] = []
const rolesQuery = createQuery()
Expand Down Expand Up @@ -327,6 +328,7 @@

<AccountArrayEditor
value={object.owners ?? []}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
emptyLabel={core.string.Owners}
onChange={handleOwnersChanged}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { deepEqual } from 'fast-equals'
import { createEventDispatcher } from 'svelte'
import { AccountArrayEditor, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import { AccountArrayEditor, employeeRefByAccountUuidStore, getAnonymousRefs } from '@hcengineering/contact-resources'
import { Asset } from '@hcengineering/platform'
import core, {
Data,
Expand Down Expand Up @@ -64,6 +64,7 @@
let members: AccountUuid[] =
project?.members !== undefined ? hierarchy.clone(project.members) : [getCurrentAccount().uuid]
$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)
let owners: AccountUuid[] =
project?.owners !== undefined ? hierarchy.clone(project.owners) : [getCurrentAccount().uuid]
let rolesAssignment: RolesAssignment = {}
Expand Down Expand Up @@ -343,6 +344,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
onChange={handleOwnersChanged}
kind={'regular'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
<script lang="ts">
import { Analytics } from '@hcengineering/analytics'
import { Employee } from '@hcengineering/contact'
import { AccountArrayEditor, AssigneeBox, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
import {
AccountArrayEditor,
AssigneeBox,
employeeRefByAccountUuidStore,
getAnonymousRefs
} from '@hcengineering/contact-resources'
import core, {
AccountRole,
AccountUuid,
Expand Down Expand Up @@ -83,6 +88,7 @@
let typeId: Ref<ProjectType> | undefined = project?.type
$: typeType = typeId !== undefined ? $typeStore.get(typeId) : undefined
$: membersPersons = members.map((m) => $employeeRefByAccountUuidStore.get(m)).filter(notEmpty)
$: readOnlyGuestOwnerExcludeItems = getAnonymousRefs($employeeRefByAccountUuidStore, owners)
let autoJoin = project?.autoJoin ?? typeType?.autoJoin ?? false
let autoJoinForRoles: AccountRole[] =
project?.autoJoinForRoles != null ? hierarchy.clone(project.autoJoinForRoles) : []
Expand Down Expand Up @@ -512,6 +518,7 @@
</div>
<AccountArrayEditor
value={owners}
excludeItems={readOnlyGuestOwnerExcludeItems}
label={core.string.Owners}
allowGuests
onChange={handleOwnersChanged}
Expand Down
Loading