From 8ce6d005dfa2238f30f6ea900775407a59dbcbce Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Thu, 1 Jun 2023 20:38:53 +0400 Subject: [PATCH] [UBER-334] Add categories to the assignee popup (#3324) --- models/tracker/src/index.ts | 16 ++- plugins/contact-assets/lang/en.json | 3 +- plugins/contact-assets/lang/ru.json | 3 +- plugins/contact-resources/src/assignee.ts | 15 +-- .../src/components/AssigneeBox.svelte | 25 +++-- .../src/components/AssigneePopup.svelte | 16 ++- .../src/components/PersonPresenter.svelte | 4 +- plugins/contact-resources/src/index.ts | 3 +- plugins/contact-resources/src/plugin.ts | 3 +- .../src/components/CreateIssue.svelte | 3 +- .../components/issues/AssigneeEditor.svelte | 83 +++++++++------- .../issues/AssigneePresenter.svelte | 99 ------------------- .../src/components/issues/IssuePreview.svelte | 2 +- .../src/components/issues/KanbanView.svelte | 12 +-- .../issues/edit/ControlPanel.svelte | 2 +- .../templates/CreateIssueTemplate.svelte | 3 +- .../templates/DraftIssueChildEditor.svelte | 2 +- .../templates/DraftIssueChildList.svelte | 2 +- .../templates/IssueTemplateChildEditor.svelte | 11 ++- .../templates/IssueTemplateChildList.svelte | 2 +- .../templates/IssueTemplateChilds.svelte | 1 + .../templates/TemplateControlPanel.svelte | 2 +- plugins/tracker-resources/src/index.ts | 4 +- plugins/tracker-resources/src/plugin.ts | 2 +- plugins/tracker-resources/src/utils.ts | 4 +- 25 files changed, 112 insertions(+), 210 deletions(-) delete mode 100644 plugins/tracker-resources/src/components/issues/AssigneePresenter.svelte diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 49b0b1348c..85dd3a99f5 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -604,13 +604,9 @@ export function createModel (builder: Builder): void { }, { key: 'assignee', - presenter: tracker.component.AssigneePresenter, + presenter: tracker.component.AssigneeEditor, displayProps: { key: 'assigee', fixed: 'right' }, - props: { - key: 'assignee', - defaultClass: contact.class.Employee, - shouldShowLabel: false - } + props: { kind: 'list', shouldShowName: false, avatarSize: 'x-small' } } ], options: { @@ -715,8 +711,8 @@ export function createModel (builder: Builder): void { }, { key: 'assignee', - presenter: tracker.component.AssigneePresenter, - props: { defaultClass: contact.class.Employee, shouldShowLabel: false } + presenter: tracker.component.AssigneeEditor, + props: { kind: 'list', shouldShowName: false, avatarSize: 'x-small' } } ] }, @@ -791,8 +787,8 @@ export function createModel (builder: Builder): void { }, { key: 'assignee', - presenter: tracker.component.AssigneePresenter, - props: { defaultClass: contact.class.Employee, shouldShowLabel: false } + presenter: tracker.component.AssigneeEditor, + props: { kind: 'list', shouldShowName: false, avatarSize: 'x-small' } } ] }, diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index 9827588bb8..baa9de059f 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -86,12 +86,11 @@ "AvatarProvider": "Avatar provider", "GravatarsManaged": "Gravatars are managed", "Through": "through", - "CategoryProjectMembers": "Project members", "AddMembersHeader": "Add members to {value}:", "Assigned": "Assigned", "Unassigned": "Unassigned", "CategoryPreviousAssigned": "Previously assigned", - "CategoryProjectLead": "Project lead", + "CategoryComponentLead": "Component lead", "CategoryCurrentUser": "Current user", "CategoryOther": "Other", "NumberMembers": "{count, plural, =0 {no members} =1 {1 member} other {# members}}", diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index afe3530eb1..81cedcf284 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -92,8 +92,7 @@ "Unassigned": "Не назначен", "CategoryCurrentUser": "Текущий пользователь", "CategoryPreviousAssigned": "Ранее назначенные", - "CategoryProjectLead": "Руководитель проекта", - "CategoryProjectMembers": "Участники проекта", + "CategoryComponentLead": "Ответственный за компонент", "CategoryOther": "Прочие", "Position": "Должность", "ConfigLabel": "Контакты", diff --git a/plugins/contact-resources/src/assignee.ts b/plugins/contact-resources/src/assignee.ts index d34eb704cd..7eefb560db 100644 --- a/plugins/contact-resources/src/assignee.ts +++ b/plugins/contact-resources/src/assignee.ts @@ -4,21 +4,13 @@ import contact from './plugin' /** * @public */ -export type AssigneeCategory = - | 'CurrentUser' - | 'Assigned' - | 'PreviouslyAssigned' - | 'ProjectLead' - | 'ProjectMembers' - | 'Members' - | 'Other' +export type AssigneeCategory = 'CurrentUser' | 'Assigned' | 'PreviouslyAssigned' | 'ComponentLead' | 'Members' | 'Other' const assigneeCategoryTitleMap: Record = Object.freeze({ CurrentUser: contact.string.CategoryCurrentUser, Assigned: contact.string.Assigned, PreviouslyAssigned: contact.string.CategoryPreviousAssigned, - ProjectLead: contact.string.CategoryProjectLead, - ProjectMembers: contact.string.CategoryProjectMembers, + ComponentLead: contact.string.CategoryComponentLead, Members: contact.string.Members, Other: contact.string.CategoryOther }) @@ -30,8 +22,7 @@ export const assigneeCategoryOrder: AssigneeCategory[] = [ 'CurrentUser', 'Assigned', 'PreviouslyAssigned', - 'ProjectLead', - 'ProjectMembers', + 'ComponentLead', 'Members', 'Other' ] diff --git a/plugins/contact-resources/src/components/AssigneeBox.svelte b/plugins/contact-resources/src/components/AssigneeBox.svelte index 5e1e353f0d..aebbc59987 100644 --- a/plugins/contact-resources/src/components/AssigneeBox.svelte +++ b/plugins/contact-resources/src/components/AssigneeBox.svelte @@ -35,9 +35,11 @@ import view from '@hcengineering/view' import { createEventDispatcher } from 'svelte' import presentation, { getClient } from '@hcengineering/presentation' + import { PersonLabelTooltip, employeeByIdStore } from '..' import AssigneePopup from './AssigneePopup.svelte' import IconPerson from './icons/Person.svelte' import UserInfo from './UserInfo.svelte' + import EmployeePresenter from './EmployeePresenter.svelte' export let _class: Ref> = contact.class.Employee export let excluded: Ref[] | undefined = undefined @@ -49,8 +51,7 @@ export let placeholder: IntlString = presentation.string.Search export let value: Ref | null | undefined export let prevAssigned: Ref[] | undefined = [] - export let projectLead: Ref | undefined = undefined - export let projectMembers: Ref[] | undefined = [] + export let componentLead: Ref | undefined = undefined export let members: Ref[] | undefined = [] export let allowDeselect = true export let titleDeselect: IntlString | undefined = undefined @@ -61,8 +62,9 @@ export let justify: 'left' | 'center' = 'center' export let width: string | undefined = undefined export let focusIndex = -1 - export let showTooltip: LabelAndProps | undefined = undefined + export let showTooltip: LabelAndProps | PersonLabelTooltip | undefined = undefined export let showNavigate = true + export let shouldShowName = true export let id: string | undefined = undefined export let short: boolean = false @@ -76,7 +78,7 @@ const client = getClient() async function updateSelected (value: Ref | null | undefined) { - selected = value ? await client.findOne(_class, { _id: value }) : undefined + selected = value ? $employeeByIdStore.get(value) ?? (await client.findOne(_class, { _id: value })) : undefined } $: updateSelected(value) @@ -85,6 +87,9 @@ const _click = (ev: MouseEvent): void => { if (!readonly) { + ev.preventDefault() + ev.stopPropagation() + showPopup( AssigneePopup, { @@ -92,8 +97,7 @@ options, docQuery, prevAssigned, - projectLead, - projectMembers, + componentLead, members, ignoreUsers: excluded ?? [], icon, @@ -131,6 +135,15 @@ > + {:else if !shouldShowName} + {:else}