diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index a76e9f8db2e..6b6fc1891e4 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -114,13 +114,11 @@ export function devTool ( .command('create-account ') .description('create user and corresponding account in master database') .requiredOption('-p, --password ', 'user password') - .requiredOption('-f, --first ', 'first name') - .requiredOption('-l, --last ', 'last name') .action(async (email: string, cmd) => { const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { console.log(`creating account ${cmd.first as string} ${cmd.last as string} (${email})...`) - await createAcc(db, productId, email, cmd.password, cmd.first, cmd.last, true) + await createAcc(db, productId, email, cmd.password, true) }) }) @@ -139,11 +137,13 @@ export function devTool ( program .command('assign-workspace ') .description('assign workspace') + .requiredOption('-f, --first ', 'first name') + .requiredOption('-l, --last ', 'last name') .action(async (email: string, workspace: string, cmd) => { const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db, client) => { console.log(`assigning user ${email} to ${workspace}...`) - await assignWorkspace(db, productId, email, workspace) + await assignWorkspace(db, productId, email, workspace, cmd.first, cmd.last) }) }) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 8da46b602d4..ce7634ac2d2 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -90,7 +90,6 @@ export class TChannelProvider extends TDoc implements ChannelProvider { export class TContact extends TDoc implements Contact { @Prop(TypeString(), contact.string.Name) @Index(IndexKind.FullText) - @Hidden() name!: string avatar?: string | null @@ -168,10 +167,6 @@ export class TEmployee extends TPerson implements Employee { @Hidden() statuses?: number - @Prop(TypeString(), contact.string.DisplayName) - @Hidden() - displayName?: string | null - @Prop(TypeString(), contact.string.Position) @Hidden() position?: string | null @@ -293,6 +288,15 @@ export function createModel (builder: Builder): void { index: 100 }) + builder.createDoc(activity.class.TxViewlet, core.space.Model, { + objectClass: contact.class.Person, + icon: contact.icon.Person, + txClass: core.class.TxUpdateDoc, + labelComponent: contact.activity.TxNameChange, + display: 'inline', + match: { 'operations.name': { $exists: true } } + }) + builder.createDoc( view.class.Viewlet, core.space.Model, diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 0f046552a85..446ac506108 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -26,6 +26,9 @@ import type { AnyComponent } from '@hcengineering/ui' import { Action, ActionCategory, ViewAction } from '@hcengineering/view' export default mergeIds(contactId, contact, { + activity: { + TxNameChange: '' as AnyComponent + }, component: { PersonPresenter: '' as AnyComponent, ContactRefPresenter: '' as AnyComponent, diff --git a/models/core/src/index.ts b/models/core/src/index.ts index 67c234b7f63..053f24b3f1f 100644 --- a/models/core/src/index.ts +++ b/models/core/src/index.ts @@ -139,7 +139,6 @@ export function createModel (builder: Builder): void { core.space.Model, { email: systemAccountEmail, - name: systemAccountEmail, role: AccountRole.Owner }, core.account.System diff --git a/models/core/src/security.ts b/models/core/src/security.ts index 6d18fde85b6..9b4ce67bf0c 100644 --- a/models/core/src/security.ts +++ b/models/core/src/security.ts @@ -48,6 +48,5 @@ export class TSpace extends TDoc implements Space { @UX(core.string.Account, undefined, undefined, 'name') export class TAccount extends TDoc implements Account { email!: string - name!: string role!: AccountRole } diff --git a/packages/core/src/__tests__/memdb.test.ts b/packages/core/src/__tests__/memdb.test.ts index dd0bfcea28b..4e3061448b7 100644 --- a/packages/core/src/__tests__/memdb.test.ts +++ b/packages/core/src/__tests__/memdb.test.ts @@ -238,7 +238,6 @@ describe('memdb', () => { }) const account = await model.createDoc(core.class.Account, core.space.Model, { email: 'email', - name: 'test', role: 0 }) await model.updateDoc(core.class.Space, core.space.Model, space, { $push: { members: account } }) diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index 60f430c3d5a..11402ac1510 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -321,7 +321,6 @@ export interface Space extends Doc { * @public */ export interface Account extends Doc { - name: string email: string role: AccountRole } diff --git a/packages/query/src/__tests__/minmodel.ts b/packages/query/src/__tests__/minmodel.ts index 069896c9bdf..7bea8a83d7c 100644 --- a/packages/query/src/__tests__/minmodel.ts +++ b/packages/query/src/__tests__/minmodel.ts @@ -194,8 +194,8 @@ export function genMinModel (): TxCUD[] { const u1 = 'User1' as Ref const u2 = 'User2' as Ref txes.push( - createDoc(core.class.Account, { email: 'user1@site.com', name: 'user1', role: 0 }, u1), - createDoc(core.class.Account, { email: 'user2@site.com', name: 'user2', role: 0 }, u2), + createDoc(core.class.Account, { email: 'user1@site.com', role: 0 }, u1), + createDoc(core.class.Account, { email: 'user2@site.com', role: 0 }, u2), createDoc(core.class.Space, { name: 'Sp1', description: '', diff --git a/packages/query/src/__tests__/query.test.ts b/packages/query/src/__tests__/query.test.ts index cc5d1086095..d0d4d7c66c6 100644 --- a/packages/query/src/__tests__/query.test.ts +++ b/packages/query/src/__tests__/query.test.ts @@ -101,7 +101,6 @@ describe('query', () => { await factory.createDoc(core.class.Account, core.space.Model, { email: 'user1@site.com', - name: 'user1', role: 0 }) await factory.createDoc(core.class.Space, core.space.Model, { diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index eb604968991..5ba2b32c636 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -46,7 +46,7 @@ const activityQuery = newActivity(client, attrs) - let viewlets: Map + let viewlets: Map = new Map() let allViewlets: TxViewlet[] = [] let editableMap: Map>, boolean> | undefined = undefined @@ -61,7 +61,18 @@ ) }) - $: viewlets = new Map(allViewlets.map((r) => [activityKey(r.objectClass, r.txClass), r])) + $: viewlets = buildViewletsMap(allViewlets) + + function buildViewletsMap (allViewlets: TxViewlet[]): Map { + const viewlets = new Map() + for (const res of allViewlets) { + const key = activityKey(res.objectClass, res.txClass) + const arr = viewlets.get(key) ?? [] + arr.push(res) + viewlets.set(key, arr) + } + return viewlets + } let loading = false diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index 20e95968915..d3ea8fcca0b 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -43,7 +43,7 @@ import TxViewTx from './TxViewTx.svelte' export let tx: DisplayTx - export let viewlets: Map + export let viewlets: Map export let showIcon: boolean = true export let isNew: boolean = false export let isNextNew: boolean = false diff --git a/plugins/activity-resources/src/utils.ts b/plugins/activity-resources/src/utils.ts index 3ac005b5152..9f558e42bba 100644 --- a/plugins/activity-resources/src/utils.ts +++ b/plugins/activity-resources/src/utils.ts @@ -5,6 +5,7 @@ import core, { Client, Collection, Doc, + Hierarchy, Obj, Ref, TxCUD, @@ -14,7 +15,8 @@ import core, { TxOperations, TxProcessor, TxUpdateDoc, - getObjectValue + getObjectValue, + matchQuery } from '@hcengineering/core' import { Asset, IntlString, getResource, translate } from '@hcengineering/platform' import { getAttributePresenterClass } from '@hcengineering/presentation' @@ -82,7 +84,11 @@ export function getDTxProps (dtx: DisplayTx): any { return { tx: dtx.tx, value: dtx.doc, isOwnTx: dtx.isOwnTx, prevValue: dtx.prevDoc } } -function getViewlet (viewlets: Map, dtx: DisplayTx): TxDisplayViewlet | undefined { +function getViewlet ( + viewlets: Map, + dtx: DisplayTx, + hierarchy: Hierarchy +): TxDisplayViewlet | undefined { let key: string if (dtx.mixinTx?.mixin !== undefined && dtx.tx._id === dtx.mixinTx._id) { key = activityKey(dtx.mixinTx.mixin, dtx.tx._class) @@ -91,13 +97,21 @@ function getViewlet (viewlets: Map, dtx: DisplayTx): TxD } const vl = viewlets.get(key) if (vl !== undefined) { - return { ...vl, pseudo: false } + for (const viewlet of vl) { + if (viewlet.match === undefined) { + return { ...viewlet, pseudo: false } + } + const res = matchQuery([dtx.tx], viewlet.match, dtx.tx._class, hierarchy) + if (res.length > 0) { + return { ...viewlet, pseudo: false } + } + } } } export async function updateViewlet ( client: TxOperations, - viewlets: Map, + viewlets: Map, dtx: DisplayTx ): Promise<{ viewlet: TxDisplayViewlet @@ -107,7 +121,7 @@ export async function updateViewlet ( modelIcon: Asset | undefined iconComponent: AnyComponent | undefined }> { - let viewlet = getViewlet(viewlets, dtx) + let viewlet = getViewlet(viewlets, dtx, client.getHierarchy()) const props = getDTxProps(dtx) let model: AttributeModel[] = [] diff --git a/plugins/bitrix/src/sync.ts b/plugins/bitrix/src/sync.ts index f4f38ab85c6..fef8d4869ea 100644 --- a/plugins/bitrix/src/sync.ts +++ b/plugins/bitrix/src/sync.ts @@ -946,7 +946,6 @@ async function synchronizeUsers ( }) accountId = await ops.client.createDoc(contact.class.PersonAccount, core.space.Model, { email: u.EMAIL, - name: combineName(u.NAME, u.LAST_NAME), person: employeeId, role: AccountRole.User }) diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index ee53b431f55..8185683a409 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -83,7 +83,6 @@ "MergePersons": "Merge contacts", "MergePersonsFrom": "Source contact", "MergePersonsTo": "Final contact", - "DisplayName": "Display name", "SelectAvatar": "Select avatar", "AvatarProvider": "Avatar provider", "GravatarsManaged": "Gravatars are managed", diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index dad2451c445..2b1332923c3 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -84,7 +84,6 @@ "MergePersons": "Объеденить контакта", "MergePersonsFrom": "Исходный контакт", "MergePersonsTo": "Финальный контакт", - "DisplayName": "Отображаемое имя", "SelectAvatar": "Выбрать аватар", "GravatarsManaged": "Граватары управляются", "Through": "через", diff --git a/plugins/contact-resources/src/components/CreateEmployee.svelte b/plugins/contact-resources/src/components/CreateEmployee.svelte index 8881a3ddc28..f18be7a0947 100644 --- a/plugins/contact-resources/src/components/CreateEmployee.svelte +++ b/plugins/contact-resources/src/components/CreateEmployee.svelte @@ -62,7 +62,6 @@ await client.createDoc(contact.class.PersonAccount, core.space.Model, { email: email.trim(), - name, person: id, role: AccountRole.User }) diff --git a/plugins/contact-resources/src/components/EditEmployee.svelte b/plugins/contact-resources/src/components/EditEmployee.svelte index 532603a850e..27b33d9cdae 100644 --- a/plugins/contact-resources/src/components/EditEmployee.svelte +++ b/plugins/contact-resources/src/components/EditEmployee.svelte @@ -14,13 +14,19 @@ // limitations under the License. --> + +{#if val} + + + + + {formatName(val)} + +{/if} diff --git a/plugins/contact-resources/src/index.ts b/plugins/contact-resources/src/index.ts index 461206586bf..d717425043a 100644 --- a/plugins/contact-resources/src/index.ts +++ b/plugins/contact-resources/src/index.ts @@ -88,6 +88,7 @@ import ActivityChannelMessage from './components/activity/ActivityChannelMessage import ActivityChannelPresenter from './components/activity/ActivityChannelPresenter.svelte' import ExpandRightDouble from './components/icons/ExpandRightDouble.svelte' import IconMembers from './components/icons/Members.svelte' +import TxNameChange from './components/activity/TxNameChange.svelte' import contact from './plugin' import { @@ -274,6 +275,9 @@ export default async (): Promise => ({ KickEmployee: kickEmployee, OpenChannel: openChannelURL }, + activity: { + TxNameChange + }, component: { ContactArrayEditor, PersonEditor, diff --git a/plugins/contact-resources/src/utils.ts b/plugins/contact-resources/src/utils.ts index 9562dd69ee3..aac669ee013 100644 --- a/plugins/contact-resources/src/utils.ts +++ b/plugins/contact-resources/src/utils.ts @@ -140,7 +140,9 @@ export async function getRefs ( export async function getCurrentEmployeeName (): Promise { const me = getCurrentAccount() as PersonAccount - return formatName(me.name) + const client = getClient() + const employee = await client.findOne(contact.class.Person, { _id: me.person }) + return employee !== undefined ? formatName(employee.name) : '' } export async function getCurrentEmployeeEmail (): Promise { diff --git a/plugins/contact/src/index.ts b/plugins/contact/src/index.ts index 15df6d41bde..cc63df967fb 100644 --- a/plugins/contact/src/index.ts +++ b/plugins/contact/src/index.ts @@ -139,7 +139,6 @@ export interface Status extends AttachedDoc { export interface Employee extends Person { active: boolean statuses?: number - displayName?: string | null position?: string | null } @@ -263,7 +262,6 @@ export const contactPlugin = plugin(contactId, { UseColor: '' as IntlString, PersonFirstNamePlaceholder: '' as IntlString, PersonLastNamePlaceholder: '' as IntlString, - DisplayName: '' as IntlString, NumberMembers: '' as IntlString, Position: '' as IntlString }, diff --git a/plugins/contact/src/utils.ts b/plugins/contact/src/utils.ts index b0ce49c937b..a05edf1fa08 100644 --- a/plugins/contact/src/utils.ts +++ b/plugins/contact/src/utils.ts @@ -16,7 +16,7 @@ import { AttachedData, Class, Client, Doc, FindResult, Ref, Hierarchy } from '@hcengineering/core' import { IconSize } from '@hcengineering/ui' import { MD5 } from 'crypto-js' -import { Channel, Contact, contactPlugin, Employee, Person } from '.' +import { Channel, Contact, contactPlugin, Person } from '.' import { AVATAR_COLORS, GravatarPlaceholderType } from './types' /** @@ -212,19 +212,12 @@ export function formatName (name: string): string { * @public */ export function getName (hierarchy: Hierarchy, value: Contact): string { - if (isEmployee(hierarchy, value)) { - return hierarchy.as(value, contactPlugin.mixin.Employee).displayName ?? formatName(value.name) - } - if (isPerson(value)) { + if (isPerson(hierarchy, value)) { return formatName(value.name) } return value.name } -function isEmployee (hierarchy: Hierarchy, value: Contact): value is Employee { - return hierarchy.hasMixin(value, contactPlugin.mixin.Employee) -} - -function isPerson (value: Contact): value is Person { - return value._class === contactPlugin.class.Person +function isPerson (hierarchy: Hierarchy, value: Contact): value is Person { + return hierarchy.isDerived(value._class, contactPlugin.class.Person) } diff --git a/plugins/login-resources/src/components/CreateWorkspaceForm.svelte b/plugins/login-resources/src/components/CreateWorkspaceForm.svelte index 15e6a93e32c..7527efe48be 100644 --- a/plugins/login-resources/src/components/CreateWorkspaceForm.svelte +++ b/plugins/login-resources/src/components/CreateWorkspaceForm.svelte @@ -25,6 +25,8 @@ import { onMount } from 'svelte' const fields = [ + { id: 'given-name', name: 'first', i18n: login.string.FirstName, short: true }, + { id: 'family-name', name: 'last', i18n: login.string.LastName, short: true }, { name: 'workspace', i18n: login.string.Workspace, @@ -34,7 +36,9 @@ ] const object = { - workspace: '' + workspace: '', + first: '', + last: '' } let status: Status = OK @@ -54,7 +58,7 @@ func: async () => { status = new Status(Severity.INFO, login.status.ConnectingToServer, {}) - const [loginStatus, result] = await createWorkspace(object.workspace) + const [loginStatus, result] = await createWorkspace(object.workspace, object.first, object.last) status = loginStatus if (result !== undefined) { diff --git a/plugins/login-resources/src/components/Join.svelte b/plugins/login-resources/src/components/Join.svelte index 51b7b674451..8ca1985089f 100644 --- a/plugins/login-resources/src/components/Join.svelte +++ b/plugins/login-resources/src/components/Join.svelte @@ -30,6 +30,8 @@ $: fields = page === 'login' ? [ + { id: 'given-name', name: 'first', i18n: login.string.FirstName, short: true }, + { id: 'family-name', name: 'last', i18n: login.string.LastName, short: true }, { id: 'email', name: 'username', i18n: login.string.Email }, { id: 'current-password', @@ -63,7 +65,7 @@ const [loginStatus, result] = page === 'login' - ? await join(object.username, object.password, location.query?.inviteId ?? '') + ? await join(object.username, object.password, object.first, object.last, location.query?.inviteId ?? '') : await signUpJoin( object.username, object.password, diff --git a/plugins/login-resources/src/components/SignupForm.svelte b/plugins/login-resources/src/components/SignupForm.svelte index 102c4c5bc25..482bf19393c 100644 --- a/plugins/login-resources/src/components/SignupForm.svelte +++ b/plugins/login-resources/src/components/SignupForm.svelte @@ -22,8 +22,6 @@ import Form from './Form.svelte' const fields = [ - { id: 'given-name', name: 'first', i18n: login.string.FirstName, short: true }, - { id: 'family-name', name: 'last', i18n: login.string.LastName, short: true }, { id: 'email', name: 'username', i18n: login.string.Email }, { id: 'new-password', name: 'password', i18n: login.string.Password, password: true }, { id: 'new-password', name: 'password2', i18n: login.string.PasswordRepeat, password: true } @@ -44,7 +42,7 @@ func: async () => { status = new Status(Severity.INFO, login.status.ConnectingToServer, {}) - const [loginStatus, result] = await signUp(object.username, object.password, object.first, object.last) + const [loginStatus, result] = await signUp(object.username, object.password) status = loginStatus diff --git a/plugins/login-resources/src/index.ts b/plugins/login-resources/src/index.ts index 86d2422c953..df59f701f97 100644 --- a/plugins/login-resources/src/index.ts +++ b/plugins/login-resources/src/index.ts @@ -16,7 +16,7 @@ import InviteLink from './components/InviteLink.svelte' import LoginApp from './components/LoginApp.svelte' -import { changeName, changePassword, getWorkspaces, leaveWorkspace, selectWorkspace, sendInvite } from './utils' +import { changePassword, getWorkspaces, leaveWorkspace, selectWorkspace, sendInvite } from './utils' /*! * Anticrm Platform™ Login Plugin * © 2020, 2021 Anticrm Platform Contributors. @@ -30,7 +30,6 @@ export default async () => ({ InviteLink }, function: { - ChangeName: changeName, LeaveWorkspace: leaveWorkspace, ChangePassword: changePassword, SelectWorkspace: selectWorkspace, diff --git a/plugins/login-resources/src/utils.ts b/plugins/login-resources/src/utils.ts index 14f9efedae4..bffaa46c30f 100644 --- a/plugins/login-resources/src/utils.ts +++ b/plugins/login-resources/src/utils.ts @@ -76,12 +76,7 @@ export async function doLogin (email: string, password: string): Promise<[Status } } -export async function signUp ( - email: string, - password: string, - first: string, - last: string -): Promise<[Status, LoginInfo | undefined]> { +export async function signUp (email: string, password: string): Promise<[Status, LoginInfo | undefined]> { const accountsUrl = getMetadata(login.metadata.AccountsUrl) if (accountsUrl === undefined) { @@ -98,7 +93,7 @@ export async function signUp ( const request = { method: 'createAccount', - params: [email, password, first, last] + params: [email, password] } try { @@ -116,7 +111,11 @@ export async function signUp ( } } -export async function createWorkspace (workspace: string): Promise<[Status, LoginInfo | undefined]> { +export async function createWorkspace ( + workspace: string, + firstName: string, + lastName: string +): Promise<[Status, LoginInfo | undefined]> { const accountsUrl = getMetadata(login.metadata.AccountsUrl) if (accountsUrl === undefined) { @@ -143,7 +142,7 @@ export async function createWorkspace (workspace: string): Promise<[Status, Logi const request = { method: 'createWorkspace', - params: [workspace] + params: [workspace, firstName, lastName] } try { @@ -426,6 +425,8 @@ export async function getInviteLink (expHours: number = 1, emailMask: string = ' export async function join ( email: string, password: string, + first: string, + last: string, inviteId: string ): Promise<[Status, WorkspaceLoginInfo | undefined]> { const accountsUrl = getMetadata(login.metadata.AccountsUrl) @@ -444,7 +445,7 @@ export async function join ( const request = { method: 'join', - params: [email, password, inviteId] + params: [email, password, first, last, inviteId] } try { @@ -503,37 +504,6 @@ export async function signUpJoin ( } } -export async function changeName (first: string, last: string): Promise { - const accountsUrl = getMetadata(login.metadata.AccountsUrl) - - if (accountsUrl === undefined) { - throw new Error('accounts url not specified') - } - - const overrideToken = getMetadata(login.metadata.OverrideLoginToken) - if (overrideToken !== undefined) { - const endpoint = getMetadata(login.metadata.OverrideEndpoint) - if (endpoint !== undefined) { - return - } - } - const token = getMetadata(presentation.metadata.Token) as string - - const request = { - method: 'changeName', - params: [first, last] - } - - await fetch(accountsUrl, { - method: 'POST', - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - }, - body: JSON.stringify(request) - }) -} - export async function changePassword (oldPassword: string, password: string): Promise { const accountsUrl = getMetadata(login.metadata.AccountsUrl) diff --git a/plugins/login/src/index.ts b/plugins/login/src/index.ts index 7bd1a06342f..dd90f10312a 100644 --- a/plugins/login/src/index.ts +++ b/plugins/login/src/index.ts @@ -69,7 +69,6 @@ export default plugin(loginId, { InviteLimit: '' as IntlString }, function: { - ChangeName: '' as Resource<(first: string, last: string) => Promise>, SendInvite: '' as Resource<(email: string) => Promise>, LeaveWorkspace: '' as Resource<(email: string) => Promise>, ChangePassword: '' as Resource<(oldPassword: string, password: string) => Promise>, diff --git a/plugins/notification-resources/src/components/Activity.svelte b/plugins/notification-resources/src/components/Activity.svelte index 6e2a500d2c7..7ce49aa5081 100644 --- a/plugins/notification-resources/src/components/Activity.svelte +++ b/plugins/notification-resources/src/components/Activity.svelte @@ -106,7 +106,7 @@ } } - let viewlets: Map + let viewlets: Map const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => { if (dir === 'vertical') { @@ -121,7 +121,14 @@ const descriptors = createQuery() descriptors.query(activity.class.TxViewlet, {}, (result) => { - viewlets = new Map(result.map((r) => [activityKey(r.objectClass, r.txClass), r])) + viewlets = new Map() + for (const res of result) { + const key = activityKey(res.objectClass, res.txClass) + const arr = viewlets.get(key) ?? [] + arr.push(res) + viewlets.set(key, arr) + } + viewlets = viewlets }) let selected = 0 diff --git a/plugins/notification-resources/src/components/EmployeeInbox.svelte b/plugins/notification-resources/src/components/EmployeeInbox.svelte index e89180f4942..db839d4e45b 100644 --- a/plugins/notification-resources/src/components/EmployeeInbox.svelte +++ b/plugins/notification-resources/src/components/EmployeeInbox.svelte @@ -105,11 +105,18 @@ } } - let viewlets: Map + let viewlets: Map const descriptors = createQuery() descriptors.query(activity.class.TxViewlet, {}, (result) => { - viewlets = new Map(result.map((r) => [activityKey(r.objectClass, r.txClass), r])) + viewlets = new Map() + for (const res of result) { + const key = activityKey(res.objectClass, res.txClass) + const arr = viewlets.get(key) ?? [] + arr.push(res) + viewlets.set(key, arr) + } + viewlets = viewlets }) let selected = 0 diff --git a/plugins/notification-resources/src/components/NotificationView.svelte b/plugins/notification-resources/src/components/NotificationView.svelte index 06a2e1daf8c..aebc0de9e45 100644 --- a/plugins/notification-resources/src/components/NotificationView.svelte +++ b/plugins/notification-resources/src/components/NotificationView.svelte @@ -26,7 +26,7 @@ import TxView from './TxView.svelte' export let value: DocUpdates - export let viewlets: Map + export let viewlets: Map export let selected: boolean export let preview: boolean = false diff --git a/plugins/notification-resources/src/components/People.svelte b/plugins/notification-resources/src/components/People.svelte index 0afe977d96e..049aebe92b6 100644 --- a/plugins/notification-resources/src/components/People.svelte +++ b/plugins/notification-resources/src/components/People.svelte @@ -125,11 +125,18 @@ } } - let viewlets: Map + let viewlets: Map const descriptors = createQuery() descriptors.query(activity.class.TxViewlet, {}, (result) => { - viewlets = new Map(result.map((r) => [activityKey(r.objectClass, r.txClass), r])) + viewlets = new Map() + for (const res of result) { + const key = activityKey(res.objectClass, res.txClass) + const arr = viewlets.get(key) ?? [] + arr.push(res) + viewlets.set(key, arr) + } + viewlets = viewlets }) let selected = 0 diff --git a/plugins/notification-resources/src/components/PeopleNotificationsView.svelte b/plugins/notification-resources/src/components/PeopleNotificationsView.svelte index 80d0b1412fa..11fdf785dfb 100644 --- a/plugins/notification-resources/src/components/PeopleNotificationsView.svelte +++ b/plugins/notification-resources/src/components/PeopleNotificationsView.svelte @@ -30,7 +30,7 @@ export let value: PersonAccount export let items: DocUpdates[] - export let viewlets: Map + export let viewlets: Map export let selected: boolean $: firstItem = items[0] diff --git a/plugins/notification-resources/src/components/TxView.svelte b/plugins/notification-resources/src/components/TxView.svelte index f6836f4ff07..5da3c8befc5 100644 --- a/plugins/notification-resources/src/components/TxView.svelte +++ b/plugins/notification-resources/src/components/TxView.svelte @@ -35,7 +35,7 @@ export let tx: TxCUD export let objectId: Ref - export let viewlets: Map + export let viewlets: Map const client = getClient() let ptx: DisplayTx | undefined diff --git a/plugins/request-resources/src/components/TxView.svelte b/plugins/request-resources/src/components/TxView.svelte index 13d1c8126c4..d85d45dcc0d 100644 --- a/plugins/request-resources/src/components/TxView.svelte +++ b/plugins/request-resources/src/components/TxView.svelte @@ -27,7 +27,7 @@ import request from '../plugin' export let tx: Tx - const viewlets: Map = new Map() + const viewlets: Map = new Map() const client = getClient() let ptx: DisplayTx | undefined diff --git a/plugins/setting-resources/src/components/Owners.svelte b/plugins/setting-resources/src/components/Owners.svelte index ca7046f90e2..e9b04ac074c 100644 --- a/plugins/setting-resources/src/components/Owners.svelte +++ b/plugins/setting-resources/src/components/Owners.svelte @@ -13,11 +13,11 @@ // limitations under the License. -->