diff --git a/packages/presentation/src/components/AttributeEditor.svelte b/packages/presentation/src/components/AttributeEditor.svelte index 939abef29f..fd84a231c8 100644 --- a/packages/presentation/src/components/AttributeEditor.svelte +++ b/packages/presentation/src/components/AttributeEditor.svelte @@ -28,6 +28,7 @@ export let maxWidth: string export let focus: boolean = false export let editable = true + export let focusIndex = -1 const client = getClient() const hierarchy = client.getHierarchy() @@ -64,6 +65,7 @@ value={getAttribute(client, object, { key: attributeKey, attr: attribute })} {onChange} {focus} + {focusIndex} /> {/await} {/if} diff --git a/plugins/chunter-resources/src/components/DmHeader.svelte b/plugins/chunter-resources/src/components/DmHeader.svelte index 0c2820a99e..0762627328 100644 --- a/plugins/chunter-resources/src/components/DmHeader.svelte +++ b/plugins/chunter-resources/src/components/DmHeader.svelte @@ -45,7 +45,7 @@ async function onSpaceEdit (): Promise { if (dm === undefined) return - showPanel(chunter.component.EditChannel, dm._id, dm._class, 'right') + showPanel(chunter.component.EditChannel, dm._id, dm._class, 'content') } diff --git a/plugins/contact-resources/src/components/ChannelEditor.svelte b/plugins/contact-resources/src/components/ChannelEditor.svelte index 108c776759..adf816ac2f 100644 --- a/plugins/contact-resources/src/components/ChannelEditor.svelte +++ b/plugins/contact-resources/src/components/ChannelEditor.svelte @@ -16,7 +16,15 @@ import { createEventDispatcher, onMount } from 'svelte' import type { IntlString } from '@anticrm/platform' import { translate } from '@anticrm/platform' - import { Button, IconClose, closeTooltip, IconBlueCheck, registerFocus, createFocusManager } from '@anticrm/ui' + import { + Button, + IconClose, + closeTooltip, + IconBlueCheck, + registerFocus, + createFocusManager, + IconArrowRight + } from '@anticrm/ui' import IconCopy from './icons/Copy.svelte' import { FocusHandler } from '@anticrm/ui' import plugin from '../plugin' @@ -24,6 +32,7 @@ export let value: string = '' export let placeholder: IntlString export let editable: boolean = false + export let integration: boolean = false const dispatch = createEventDispatcher() let input: HTMLInputElement @@ -65,8 +74,8 @@ -
- {#if editable} +{#if editable} +
{ if (ev.key === 'Enter') { - dispatch('update', value) + dispatch('close', value) closeTooltip() } }} @@ -97,48 +106,58 @@ } }} /> - {:else} +
+{:else} +
{value} - {/if} -
+ {#if integration} +
+{/if} diff --git a/plugins/contact-resources/src/components/ChannelsDropdown.svelte b/plugins/contact-resources/src/components/ChannelsDropdown.svelte index a7f65ea96d..f4ee944ecc 100644 --- a/plugins/contact-resources/src/components/ChannelsDropdown.svelte +++ b/plugins/contact-resources/src/components/ChannelsDropdown.svelte @@ -31,7 +31,7 @@ getFocusManager, Menu, showPopup, - showTooltip + Tooltip } from '@anticrm/ui' import { createEventDispatcher, tick } from 'svelte' import { getChannelProviders } from '../utils' @@ -122,6 +122,7 @@ let addBtn: HTMLButtonElement const btns: HTMLButtonElement[] = [] let anchor: HTMLElement + let opened: number | undefined = undefined function filterUndefined (channels: AttachedData[]): AttachedData[] { return channels.filter((channel) => channel.value !== undefined) @@ -175,33 +176,41 @@ } const editChannel = (el: HTMLElement, n: number, item: Item): void => { - showTooltip( - undefined, - el, - undefined, - ChannelEditor, - { - value: item.value, - placeholder: item.placeholder, - editable - }, - anchor, - (result) => { - if (result.detail != null) { - if (result.detail === '') { - displayItems = dropItem(n) - } else { - displayItems[n].value = result.detail + if (opened !== n) { + opened = n + showPopup( + ChannelEditor, + { + value: item.value, + placeholder: item.placeholder, + editable + }, + el, + (result) => { + if (result != null) { + if (result === '') { + displayItems = dropItem(n) + } else { + displayItems[n].value = result + } + saveItems() + focusManager?.setFocusPos(focusIndex + 1 + n) + } + if (result === undefined && item.value === '') displayItems = dropItem(n) + opened = undefined + }, + (result) => { + if (result != null) { + if (result === '') { + displayItems = dropItem(n) + } else { + displayItems[n].value = result + } + saveItems() } - saveItems() - focusManager?.setFocusPos(focusIndex + 1 + n) } - } - ) - } - const _focus = (ev: Event, n: number, item: Item): void => { - const el = ev.target as HTMLButtonElement - if (el) editChannel(el, n, item) + ) + } } @@ -213,39 +222,62 @@ class:short={displayItems.length > 4 && length === 'short'} > {#each displayItems as item, i} -
diff --git a/plugins/contact-resources/src/components/ChannelsEditor.svelte b/plugins/contact-resources/src/components/ChannelsEditor.svelte index f5080ec057..f5ed7fe23f 100644 --- a/plugins/contact-resources/src/components/ChannelsEditor.svelte +++ b/plugins/contact-resources/src/components/ChannelsEditor.svelte @@ -28,6 +28,7 @@ export let integrations: Set> | undefined = undefined export let editable = true export let allowOpen = true + export let focusIndex = -1 export let kind: ButtonKind = 'link-bordered' export let size: ButtonSize = 'small' @@ -124,6 +125,7 @@ {integrations} {editable} {shape} + {focusIndex} on:change={(e) => { if (editable) save(e.detail) }} diff --git a/plugins/contact-resources/src/components/CreateOrganization.svelte b/plugins/contact-resources/src/components/CreateOrganization.svelte index d81e31e982..7d947b5b03 100644 --- a/plugins/contact-resources/src/components/CreateOrganization.svelte +++ b/plugins/contact-resources/src/components/CreateOrganization.svelte @@ -16,7 +16,7 @@ import { Channel, Organization } from '@anticrm/contact' import { AttachedData, generateId } from '@anticrm/core' import { Card, getClient } from '@anticrm/presentation' - import { Button, EditBox } from '@anticrm/ui' + import { Button, EditBox, createFocusManager, FocusHandler } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import contact from '../plugin' import ChannelsDropdown from './ChannelsDropdown.svelte' @@ -55,8 +55,12 @@ } let channels: AttachedData[] = [] + + const manager = createFocusManager() + + - + diff --git a/plugins/contact-resources/src/components/CreatePerson.svelte b/plugins/contact-resources/src/components/CreatePerson.svelte index b13ec9382a..07fa97700b 100644 --- a/plugins/contact-resources/src/components/CreatePerson.svelte +++ b/plugins/contact-resources/src/components/CreatePerson.svelte @@ -18,7 +18,7 @@ import { AttachedData, Data, generateId } from '@anticrm/core' import { getResource } from '@anticrm/platform' import { Card, EditableAvatar, getClient } from '@anticrm/presentation' - import { EditBox, IconInfo, Label } from '@anticrm/ui' + import { EditBox, IconInfo, Label, createFocusManager, FocusHandler } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import { ChannelsDropdown } from '..' import contact from '../plugin' @@ -78,8 +78,12 @@ $: findPerson(client, { ...object, name: combineName(firstName, lastName) }, channels).then((p) => { matches = p }) + + const manager = createFocusManager() + +
@@ -129,6 +136,6 @@ - +
diff --git a/plugins/contact-resources/src/components/EditOrganization.svelte b/plugins/contact-resources/src/components/EditOrganization.svelte index b6d7de1bdc..bf913f0110 100644 --- a/plugins/contact-resources/src/components/EditOrganization.svelte +++ b/plugins/contact-resources/src/components/EditOrganization.svelte @@ -16,7 +16,7 @@ + + {#if object !== undefined}
- +
diff --git a/plugins/contact-resources/src/components/EditPerson.svelte b/plugins/contact-resources/src/components/EditPerson.svelte index 95b5da238f..ff23b9ed6f 100644 --- a/plugins/contact-resources/src/components/EditPerson.svelte +++ b/plugins/contact-resources/src/components/EditPerson.svelte @@ -20,7 +20,7 @@ import { getResource } from '@anticrm/platform' import { AttributeEditor, Avatar, createQuery, EditableAvatar, getClient } from '@anticrm/presentation' import setting, { IntegrationType } from '@anticrm/setting' - import { EditBox } from '@anticrm/ui' + import { EditBox, createFocusManager, FocusHandler } from '@anticrm/ui' import { afterUpdate, createEventDispatcher, onMount } from 'svelte' import contact from '../plugin' import ChannelsEditor from './ChannelsEditor.svelte' @@ -93,8 +93,12 @@ await deleteFile(object.avatar) } } + + const manager = createFocusManager() + + {#if object !== undefined}
@@ -115,6 +119,7 @@ maxWidth="20rem" bind:value={firstName} on:change={firstNameChange} + focusIndex={1} /> {:else} {firstName} @@ -127,13 +132,21 @@ maxWidth="20rem" bind:value={lastName} on:change={lastNameChange} + focusIndex={2} /> {:else} {lastName} {/if}
- +
@@ -145,6 +158,7 @@ {editable} bind:integrations shape={'circle'} + focusIndex={10} /> diff --git a/plugins/contact-resources/src/components/EmployeePresenter.svelte b/plugins/contact-resources/src/components/EmployeePresenter.svelte index d999fb1e0d..22805059b9 100644 --- a/plugins/contact-resources/src/components/EmployeePresenter.svelte +++ b/plugins/contact-resources/src/components/EmployeePresenter.svelte @@ -10,7 +10,7 @@ let container: HTMLElement - function onEdit (event: MouseEvent) { + function onEdit () { showPopup( EmployeePreviewPopup, { diff --git a/plugins/lead-resources/src/components/CreateCustomer.svelte b/plugins/lead-resources/src/components/CreateCustomer.svelte index ea0d474449..32cee95db1 100644 --- a/plugins/lead-resources/src/components/CreateCustomer.svelte +++ b/plugins/lead-resources/src/components/CreateCustomer.svelte @@ -22,7 +22,17 @@ import type { Customer } from '@anticrm/lead' import { getResource } from '@anticrm/platform' import { Card, EditableAvatar, getClient } from '@anticrm/presentation' - import { Button, EditBox, eventToHTMLElement, IconInfo, Label, SelectPopup, showPopup } from '@anticrm/ui' + import { + Button, + EditBox, + eventToHTMLElement, + IconInfo, + Label, + SelectPopup, + showPopup, + createFocusManager, + FocusHandler + } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import lead from '../plugin' @@ -149,8 +159,12 @@ ) } $: canSave = formatName(targetClass._id, firstName, lastName, object.name).length > 0 + + const manager = createFocusManager() + + {#if targetClass._id === contact.class.Person} @@ -179,12 +194,14 @@ kind={'large-style'} maxWidth={'32rem'} focus + focusIndex={1} />
@@ -222,11 +241,12 @@ maxWidth={'37.5rem'} kind={'large-style'} focus + focusIndex={1} />
{/if} - + {#if matches.length > 0} diff --git a/plugins/setting-resources/src/components/Profile.svelte b/plugins/setting-resources/src/components/Profile.svelte index 424ffd55a0..4cba66a14f 100644 --- a/plugins/setting-resources/src/components/Profile.svelte +++ b/plugins/setting-resources/src/components/Profile.svelte @@ -16,7 +16,7 @@ import { AttributeEditor, createQuery, EditableAvatar, getClient } from '@anticrm/presentation' import setting from '@anticrm/setting' - import { EditBox, Icon, Label } from '@anticrm/ui' + import { EditBox, Icon, Label, createFocusManager, FocusHandler } from '@anticrm/ui' import contact, { Employee, EmployeeAccount, getFirstName, getLastName } from '@anticrm/contact' import contactRes from '@anticrm/contact-resources/src/plugin' import { getCurrentAccount } from '@anticrm/core' @@ -69,8 +69,12 @@ await deleteFile(employee.avatar) } } + + const manager = createFocusManager() + +
@@ -88,6 +92,8 @@ placeholder={contactRes.string.PersonFirstNamePlaceholder} maxWidth="20rem" bind:value={firstName} + focus + focusIndex={1} on:change={() => { changeName(firstName, lastName) }} @@ -98,17 +104,24 @@ placeholder={contactRes.string.PersonLastNamePlaceholder} maxWidth="20rem" bind:value={lastName} + focusIndex={2} on:change={() => { changeName(firstName, lastName) }} />
- +
- +
{/if} diff --git a/plugins/setting-resources/src/components/Settings.svelte b/plugins/setting-resources/src/components/Settings.svelte index 5256bbb246..307d22e4d1 100644 --- a/plugins/setting-resources/src/components/Settings.svelte +++ b/plugins/setting-resources/src/components/Settings.svelte @@ -84,7 +84,7 @@ -
+
{#if category} {/if} diff --git a/tests/sanity/tests/settings.spec.ts b/tests/sanity/tests/settings.spec.ts index a56fc0c652..be1e026b9e 100644 --- a/tests/sanity/tests/settings.spec.ts +++ b/tests/sanity/tests/settings.spec.ts @@ -34,10 +34,10 @@ test.describe('contact tests', () => { await page.click('[id="presentation:string:AddSocialLinks"]') await page.click('.popup button:has-text("Email")') } - await page.hover('[id="gmail:string:Email"]') + // await page.hover('[id="gmail:string:Email"]') await page.fill('[placeholder="john\\.appleseed\\@apple\\.com"]', 'wer@qwe.com') // Click text=Apply - await page.click('button:nth-child(4)') + await page.click('button:nth-child(3)') }) test('create-template', async ({ page }) => { // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp