From c606a037f1587b162884437e08b7194a08085baa Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Thu, 4 May 2023 20:21:06 +0700 Subject: [PATCH] TSK-831: Edit issue fixes (#3140) Signed-off-by: Andrey Sobolev --- packages/panel/src/components/Panel.svelte | 6 +-- .../src/components/ReferenceInput.svelte | 40 ++++++++++++++++++- .../src/components/StyledTextBox.svelte | 6 ++- .../src/components/SvelteRenderer.ts | 4 +- .../src/components/TextEditor.svelte | 4 +- packages/ui/src/components/Panel.svelte | 12 ++++-- .../src/components/Activity.svelte | 3 +- .../src/components/AttachmentRefInput.svelte | 2 + .../src/components/AttachmentStyledBox.svelte | 5 ++- .../src/components/CommentInput.svelte | 2 + .../components/issues/edit/EditIssue.svelte | 35 ++++++++++++++-- .../issues/edit/SubIssueList.svelte | 21 ++++++++++ .../components/issues/edit/SubIssues.svelte | 10 ++++- plugins/view-resources/src/actionImpl.ts | 14 +++---- .../src/components/UpDownNavigator.svelte | 17 +++++++- 15 files changed, 151 insertions(+), 30 deletions(-) diff --git a/packages/panel/src/components/Panel.svelte b/packages/panel/src/components/Panel.svelte index 16fb676b66..c2f7bfb8c4 100644 --- a/packages/panel/src/components/Panel.svelte +++ b/packages/panel/src/components/Panel.svelte @@ -95,7 +95,7 @@ - + {#if isUtils && $$slots.utils}
@@ -145,7 +145,7 @@ {#if !withoutActivity} {/if}
@@ -156,7 +156,7 @@ {#if !withoutActivity} {/if} diff --git a/packages/text-editor/src/components/ReferenceInput.svelte b/packages/text-editor/src/components/ReferenceInput.svelte index 0f51e7b945..b0f1c604ad 100644 --- a/packages/text-editor/src/components/ReferenceInput.svelte +++ b/packages/text-editor/src/components/ReferenceInput.svelte @@ -15,8 +15,18 @@
@@ -292,6 +321,13 @@ textEditor.clear() } }} + on:on:blur={() => { + focused = false + }} + on:focus={() => { + focused = true + updateFocus() + }} extensions={editorExtensions} on:selection-update={updateFormattingState} on:update diff --git a/packages/text-editor/src/components/StyledTextBox.svelte b/packages/text-editor/src/components/StyledTextBox.svelte index 55e59567c7..5bd6cfba44 100644 --- a/packages/text-editor/src/components/StyledTextBox.svelte +++ b/packages/text-editor/src/components/StyledTextBox.svelte @@ -86,6 +86,9 @@ const dispatch = createEventDispatcher() let focused = false + export function isFocused (): boolean { + return focused + } let needFocus = false $: if (textEditor && needFocus) { @@ -101,8 +104,9 @@ export let focusIndex = -1 const { idx, focusManager } = registerFocus(focusIndex, { focus: () => { + focused = true focus() - return false + return textEditor.isEditable() }, isFocus: () => focused }) diff --git a/packages/text-editor/src/components/SvelteRenderer.ts b/packages/text-editor/src/components/SvelteRenderer.ts index bd8d6421b2..5ee87dd944 100644 --- a/packages/text-editor/src/components/SvelteRenderer.ts +++ b/packages/text-editor/src/components/SvelteRenderer.ts @@ -14,12 +14,12 @@ // limitations under the License. // -import { SvelteComponent } from 'svelte' +import { ComponentType, SvelteComponent } from 'svelte' export class SvelteRenderer { private readonly component: SvelteComponent - constructor (comp: typeof SvelteComponent, props: any) { + constructor (comp: typeof SvelteComponent | ComponentType, props: any) { const options = { target: document.body, props } this.component = new (comp as any)(options) } diff --git a/packages/text-editor/src/components/TextEditor.svelte b/packages/text-editor/src/components/TextEditor.svelte index e8850bffac..84ee1693a3 100644 --- a/packages/text-editor/src/components/TextEditor.svelte +++ b/packages/text-editor/src/components/TextEditor.svelte @@ -16,15 +16,15 @@ { dispatch('open', { ignoreKeys: ['comments', 'name', 'description', 'number'] }) }) + + const manager = createFocusManager() + export function canClose (): boolean { + if (descriptionBox.isFocused()) { + return false + } + return true + } + + + {#if issue !== undefined} {/if} - +
{#key issue._id} {#key issue._id && currentProject !== undefined} {#if currentProject !== undefined} - + {/if} {/key}
diff --git a/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte b/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte index 76bbe9fc94..10736d5aa7 100644 --- a/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte @@ -15,6 +15,7 @@ { + docs = evt.detail listProvider.update(evt.detail) }} /> diff --git a/plugins/tracker-resources/src/components/issues/edit/SubIssues.svelte b/plugins/tracker-resources/src/components/issues/edit/SubIssues.svelte index aeaaa8b087..efe471a8a5 100644 --- a/plugins/tracker-resources/src/components/issues/edit/SubIssues.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/SubIssues.svelte @@ -70,6 +70,8 @@ } $: viewOptions = viewlet !== undefined ? getViewOptions(viewlet, $viewOptionStore) : undefined + + export let focusIndex = -1
@@ -139,7 +141,13 @@ {#if !isCollapsed}
- +
{/if} diff --git a/plugins/view-resources/src/actionImpl.ts b/plugins/view-resources/src/actionImpl.ts index 6be79b3709..654892b791 100644 --- a/plugins/view-resources/src/actionImpl.ts +++ b/plugins/view-resources/src/actionImpl.ts @@ -156,11 +156,12 @@ async function Open ( | undefined ): Promise { evt.preventDefault() + const d = Array.isArray(doc) ? doc[0] : doc const client = getClient() const hierarchy = client.getHierarchy() - const panelComponent = hierarchy.classHierarchyMixin(doc._class, view.mixin.ObjectPanel) + const panelComponent = hierarchy.classHierarchyMixin(d._class, view.mixin.ObjectPanel) const component = props?.component ?? panelComponent?.component ?? view.component.EditDoc - const loc = await getObjectLinkFragment(hierarchy, doc, {}, component) + const loc = await getObjectLinkFragment(hierarchy, d, {}, component) navigate(loc) } @@ -180,15 +181,12 @@ function ShowPanel ( rightSection?: AnyComponent } ): void { - if (Array.isArray(doc)) { - console.error('Wrong show Panel parameters') - return - } + const d = Array.isArray(doc) ? doc[0] : doc evt.preventDefault() showPanel( props.component ?? view.component.EditDoc, - doc._id, - Hierarchy.mixinOrClass(doc), + d._id, + Hierarchy.mixinOrClass(d), props.element ?? 'content', props.rightSection ) diff --git a/plugins/view-resources/src/components/UpDownNavigator.svelte b/plugins/view-resources/src/components/UpDownNavigator.svelte index 1553f8fb48..250ecddee6 100644 --- a/plugins/view-resources/src/components/UpDownNavigator.svelte +++ b/plugins/view-resources/src/components/UpDownNavigator.svelte @@ -39,9 +39,22 @@ $: select(undefined, 0, element, 'vertical') -