From c2c99079613df4153c323baba2e0afda0dd37892 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov Date: Mon, 16 Jan 2023 10:49:10 +0700 Subject: [PATCH 1/6] Add new assignee popup with categories Signed-off-by: Denis Maslennikov --- packages/presentation/lang/en.json | 8 +- packages/presentation/lang/ru.json | 10 +- packages/presentation/package.json | 1 + .../src/components/AssigneeBox.svelte | 177 ++++++++++ .../src/components/AssigneePopup.svelte | 320 ++++++++++++++++++ packages/presentation/src/index.ts | 1 + packages/presentation/src/plugin.ts | 8 +- packages/presentation/src/utils.ts | 43 ++- .../components/issues/AssigneeEditor.svelte | 6 +- .../timereport/EstimationSubIssueList.svelte | 5 +- 10 files changed, 569 insertions(+), 10 deletions(-) create mode 100644 packages/presentation/src/components/AssigneeBox.svelte create mode 100644 packages/presentation/src/components/AssigneePopup.svelte diff --git a/packages/presentation/lang/en.json b/packages/presentation/lang/en.json index e9909711813..95f11ca0a39 100644 --- a/packages/presentation/lang/en.json +++ b/packages/presentation/lang/en.json @@ -27,6 +27,12 @@ "Add": "Add", "Edit": "Edit", "SelectAvatar": "Select avatar", - "GravatarsManaged": "Gravatars are managed through" + "GravatarsManaged": "Gravatars are managed through", + "CategoryCurrentUser": "Current user", + "Assigned": "Assigned", + "CategoryPreviousAssigned": "Previously assigned", + "CategoryProjectLead": "Project lead", + "CategoryProjectMembers": "Project members", + "CategoryOther": "Other" } } diff --git a/packages/presentation/lang/ru.json b/packages/presentation/lang/ru.json index 080f5102d24..de3e58261e3 100644 --- a/packages/presentation/lang/ru.json +++ b/packages/presentation/lang/ru.json @@ -22,11 +22,17 @@ "NumberSpaces": "{count, plural, =0 {В} =1 {В 1 месте} other {В # местах}}", "InThis": "В этом {space}", "NoMatchesInThis": "В этом {space} совпадения не обнаружены", - "NoMatchesFound": "Не найдено соответсвий", + "NoMatchesFound": "Не найдено соответствий", "NotInThis": "Не в этом {space}", "Add": "Добавить", "Edit": "Редактировать", "SelectAvatar": "Выбрать аватар", - "GravatarsManaged": "Граватары управляются через" + "GravatarsManaged": "Граватары управляются через", + "CategoryCurrentUser": "Текущий пользователь", + "Assigned": "Назначен", + "CategoryPreviousAssigned": "Ранее назначенные", + "CategoryProjectLead": "Руководитель проекта", + "CategoryProjectMembers": "Участники проекта", + "CategoryOther": "Прочие" } } diff --git a/packages/presentation/package.json b/packages/presentation/package.json index 7324880e6f1..28ebabfcc5a 100644 --- a/packages/presentation/package.json +++ b/packages/presentation/package.json @@ -42,6 +42,7 @@ "@hcengineering/login": "~0.6.1", "@hcengineering/image-cropper": "~0.6.0", "@hcengineering/client": "^0.6.6", + "@hcengineering/tracker": "^0.6.1", "@hcengineering/setting": "~0.6.1", "fast-equals": "^2.0.3" } diff --git a/packages/presentation/src/components/AssigneeBox.svelte b/packages/presentation/src/components/AssigneeBox.svelte new file mode 100644 index 00000000000..a40dc5ad4f5 --- /dev/null +++ b/packages/presentation/src/components/AssigneeBox.svelte @@ -0,0 +1,177 @@ + + + + +
+ {#if $$slots.content} +
+ +
+ {:else} + + {/if} +
diff --git a/packages/presentation/src/components/AssigneePopup.svelte b/packages/presentation/src/components/AssigneePopup.svelte new file mode 100644 index 00000000000..979a36c403f --- /dev/null +++ b/packages/presentation/src/components/AssigneePopup.svelte @@ -0,0 +1,320 @@ + + + + + +
{ + dispatch('changeContent') + }} +> +
+ +
+ {#if cHeight === 1} +
+ {/if} +
updateLocation(scrollDiv, selectedDiv, contacts, selected)} + bind:this={scrollDiv} + > +
+ + + {#if showCategories} + {@const obj = toAny(contacts[item])} + {@const category = categorizedPersons.get(obj._id)} + {@const cl = hierarchy.getClass(contacts[item]._class)} + {#if item === 0 || (item > 0 && categorizedPersons.get(toAny(contacts[item - 1])._id) !== categorizedPersons.get(obj._id))} + +
+
+ + {#if cl.icon} + + {/if} + +
+
+ {/if} + {/if} +
+ + {@const obj = contacts[item]} + + +
+
+
+ {#if cHeight === -1} +
+ {/if} +
+ + diff --git a/packages/presentation/src/index.ts b/packages/presentation/src/index.ts index 5145137ad48..6c2aaf6fbdf 100644 --- a/packages/presentation/src/index.ts +++ b/packages/presentation/src/index.ts @@ -17,6 +17,7 @@ import { addStringsLoader } from '@hcengineering/platform' import { presentationId } from './plugin' export * from './attributes' +export { default as AssigneeBox } from './components/AssigneeBox.svelte' export { default as AttributeBarEditor } from './components/AttributeBarEditor.svelte' export { default as AttributeEditor } from './components/AttributeEditor.svelte' export { default as AttributesBar } from './components/AttributesBar.svelte' diff --git a/packages/presentation/src/plugin.ts b/packages/presentation/src/plugin.ts index e802faf584e..5c4c78cad1b 100644 --- a/packages/presentation/src/plugin.ts +++ b/packages/presentation/src/plugin.ts @@ -56,7 +56,13 @@ export default plugin(presentationId, { Add: '' as IntlString, Edit: '' as IntlString, SelectAvatar: '' as IntlString, - GravatarsManaged: '' as IntlString + GravatarsManaged: '' as IntlString, + CategoryCurrentUser: '' as IntlString, + Assigned: '' as IntlString, + CategoryPreviousAssigned: '' as IntlString, + CategoryProjectLead: '' as IntlString, + CategoryProjectMembers: '' as IntlString, + CategoryOther: '' as IntlString }, metadata: { RequiredVersion: '' as Metadata, diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index 05a6874051d..fdef280d810 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -34,12 +34,13 @@ import core, { TxResult } from '@hcengineering/core' import login from '@hcengineering/login' -import { getMetadata } from '@hcengineering/platform' +import { getMetadata, IntlString } from '@hcengineering/platform' import { LiveQuery as LQ } from '@hcengineering/query' import { onDestroy } from 'svelte' import { deepEqual } from 'fast-equals' import { IconSize, DropdownIntlItem } from '@hcengineering/ui' import contact, { AvatarType, AvatarProvider } from '@hcengineering/contact' +import presentation from '..' let liveQuery: LQ let client: TxOperations @@ -272,3 +273,43 @@ export function getAvatarProviderId (avatar?: string | null): Ref = Object.freeze({ + CurrentUser: presentation.string.CategoryCurrentUser, + Assigned: presentation.string.Assigned, + PreviouslyAssigned: presentation.string.CategoryPreviousAssigned, + ProjectLead: presentation.string.CategoryProjectLead, + ProjectMembers: presentation.string.CategoryProjectMembers, + Other: presentation.string.CategoryOther +}) + +/** + * @public + */ +export const assigneeCategoryOrder: AssigneeCategory[] = [ + 'CurrentUser', + 'Assigned', + 'PreviouslyAssigned', + 'ProjectLead', + 'ProjectMembers', + 'Other' +] + +/** + * @public + */ +export function getCategorytitle (category: AssigneeCategory | undefined): IntlString { + const cat: AssigneeCategory = category ?? 'Other' + return assigneeCategoryTitleMap[cat] +} diff --git a/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte index d0006397790..6795469cdce 100644 --- a/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte @@ -15,7 +15,7 @@ {#if value} - import contact from '@hcengineering/contact' import { Doc, Ref } from '@hcengineering/core' - import { UserBox } from '@hcengineering/presentation' + import { AssigneeBox } from '@hcengineering/presentation' import { Issue, Team } from '@hcengineering/tracker' import { getEventPositionElement, ListView, showPopup } from '@hcengineering/ui' import { ContextMenu, FixedColumn, ListSelectionProvider, SelectDirection } from '@hcengineering/view-resources' @@ -77,10 +77,11 @@
- From 40a8022fbcf4d6f952a0eb46519fc60e102b610f Mon Sep 17 00:00:00 2001 From: Denis Maslennikov Date: Mon, 16 Jan 2023 11:49:39 +0700 Subject: [PATCH 2/6] Fix dependencies Signed-off-by: Denis Maslennikov --- packages/presentation/package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/presentation/package.json b/packages/presentation/package.json index 31afa515f3f..67ff4bfc11e 100644 --- a/packages/presentation/package.json +++ b/packages/presentation/package.json @@ -16,7 +16,7 @@ "svelte-loader": "^3.1.3", "sass": "^1.53.0", "svelte-preprocess": "^4.10.7", - "@hcengineering/platform-rig": "~0.6.0", + "@hcengineering/platform-rig": "^0.6.0", "@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/parser": "^5.41.0", "eslint-config-standard-with-typescript": "^23.0.0", @@ -31,16 +31,16 @@ "typescript": "^4.3.5" }, "dependencies": { - "@hcengineering/attachment": "~0.6.1", + "@hcengineering/attachment": "^0.6.1", "@hcengineering/platform": "^0.6.8", - "@hcengineering/core": "^0.6.19", - "@hcengineering/query": "~0.6.1", - "@hcengineering/ui": "^0.6.2", - "@hcengineering/view": "^0.6.1", + "@hcengineering/core": "^0.6.20", + "@hcengineering/query": "^0.6.1", + "@hcengineering/ui": "^0.6.3", + "@hcengineering/view": "^0.6.2", "svelte": "^3.47", - "@hcengineering/contact": "~0.6.8", - "@hcengineering/login": "~0.6.1", - "@hcengineering/image-cropper": "~0.6.0", + "@hcengineering/contact": "^0.6.9", + "@hcengineering/login": "^0.6.1", + "@hcengineering/image-cropper": "^0.6.0", "@hcengineering/client": "^0.6.6", "@hcengineering/tracker": "^0.6.1", "@hcengineering/setting": "^0.6.2", From c4ccaa26f8b2950e7064762b8f4dc9df4f5b1bd4 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov Date: Mon, 16 Jan 2023 19:13:20 +0700 Subject: [PATCH 3/6] Fix svelte-check Signed-off-by: Denis Maslennikov --- .../presentation/src/components/AssigneePopup.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/presentation/src/components/AssigneePopup.svelte b/packages/presentation/src/components/AssigneePopup.svelte index 979a36c403f..6aee719fd0e 100644 --- a/packages/presentation/src/components/AssigneePopup.svelte +++ b/packages/presentation/src/components/AssigneePopup.svelte @@ -21,6 +21,7 @@ FindOptions, getCurrentAccount, Ref, + TxCollectionCUD, TxUpdateDoc } from '@hcengineering/core' import type { Asset, IntlString } from '@hcengineering/platform' @@ -131,10 +132,13 @@ 'tx.operations.assignee': { $exists: true } }, (res) => { - prevAssigned = res.map((t) => (t as TxUpdateDoc).tx.operations.assignee) - }, - { sort: { name: 1 } } + prevAssigned = res + .map((t) => ((t as TxCollectionCUD).tx as TxUpdateDoc).operations.assignee) + .filter((p) => !!p) + .filter((p) => !!p) as Ref[] + } ) + if (issue.project) { const project = await client.findOne(tracker.class.Project, { _id: issue.project }) projectLead = project?.lead || undefined From b4c35ed0718b790b85ffb76361bb5bf24ee18e01 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov Date: Tue, 17 Jan 2023 23:44:29 +0700 Subject: [PATCH 4/6] Move component to tracker-resource Signed-off-by: Denis Maslennikov --- packages/presentation/package.json | 1 - packages/presentation/src/index.ts | 2 +- .../src/components/issues}/AssigneeBox.svelte | 4 +--- .../src/components/issues/AssigneeEditor.svelte | 3 ++- .../src/components/issues}/AssigneePopup.svelte | 11 ++++++++--- 5 files changed, 12 insertions(+), 9 deletions(-) rename {packages/presentation/src/components => plugins/tracker-resources/src/components/issues}/AssigneeBox.svelte (97%) rename {packages/presentation/src/components => plugins/tracker-resources/src/components/issues}/AssigneePopup.svelte (98%) diff --git a/packages/presentation/package.json b/packages/presentation/package.json index 67ff4bfc11e..8432b9986bf 100644 --- a/packages/presentation/package.json +++ b/packages/presentation/package.json @@ -42,7 +42,6 @@ "@hcengineering/login": "^0.6.1", "@hcengineering/image-cropper": "^0.6.0", "@hcengineering/client": "^0.6.6", - "@hcengineering/tracker": "^0.6.1", "@hcengineering/setting": "^0.6.2", "fast-equals": "^2.0.3" } diff --git a/packages/presentation/src/index.ts b/packages/presentation/src/index.ts index 56cca404ef7..1d9f7f24b6d 100644 --- a/packages/presentation/src/index.ts +++ b/packages/presentation/src/index.ts @@ -17,7 +17,6 @@ import { addStringsLoader } from '@hcengineering/platform' import { presentationId } from './plugin' export * from './attributes' -export { default as AssigneeBox } from './components/AssigneeBox.svelte' export { default as AttributeBarEditor } from './components/AttributeBarEditor.svelte' export { default as AttributeEditor } from './components/AttributeEditor.svelte' export { default as AttributesBar } from './components/AttributesBar.svelte' @@ -42,6 +41,7 @@ export { default as EmployeeBox } from './components/EmployeeBox.svelte' export { default as UsersPopup } from './components/UsersPopup.svelte' export { default as MembersBox } from './components/MembersBox.svelte' export { default as IconMembers } from './components/icons/Members.svelte' +export { default as IconPerson } from './components/icons/Person.svelte' export { default as IconMembersOutline } from './components/icons/MembersOutline.svelte' export { default as ObjectSearchPopup } from './components/ObjectSearchPopup.svelte' export { default as IndexedDocumentPreview } from './components/IndexedDocumentPreview.svelte' diff --git a/packages/presentation/src/components/AssigneeBox.svelte b/plugins/tracker-resources/src/components/issues/AssigneeBox.svelte similarity index 97% rename from packages/presentation/src/components/AssigneeBox.svelte rename to plugins/tracker-resources/src/components/issues/AssigneeBox.svelte index a40dc5ad4f5..40a2dfb450d 100644 --- a/packages/presentation/src/components/AssigneeBox.svelte +++ b/plugins/tracker-resources/src/components/issues/AssigneeBox.svelte @@ -34,9 +34,7 @@ } from '@hcengineering/ui' import view from '@hcengineering/view' import { createEventDispatcher } from 'svelte' - import presentation, { getClient } from '..' - import IconPerson from './icons/Person.svelte' - import UserInfo from './UserInfo.svelte' + import presentation, { IconPerson, UserInfo, getClient } from '@hcengineering/presentation' import AssigneePopup from './AssigneePopup.svelte' export let _class: Ref> = contact.class.Employee diff --git a/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte index 6795469cdce..6cd22ed03d8 100644 --- a/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte @@ -15,11 +15,12 @@