From d770acb77a2008ee141c18185d08987915da39c7 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 21 Mar 2023 19:16:45 +0700 Subject: [PATCH] TSK-831: Edit Title and Description inline (#2788) Signed-off-by: Andrey Sobolev --- dev/upgrade.sh | 8 + .../src/components/AttachmentStyledBox.svelte | 32 ++-- plugins/tracker-assets/lang/en.json | 3 +- plugins/tracker-assets/lang/ru.json | 3 +- .../issues/edit/CreateSubIssue.svelte | 2 +- .../components/issues/edit/EditIssue.svelte | 148 +++++++----------- .../templates/DraftIssueChildEditor.svelte | 7 +- plugins/tracker-resources/src/plugin.ts | 3 +- .../src/components/NumberPresenter.svelte | 2 +- tests/sanity/tests/tracker.utils.ts | 15 +- 10 files changed, 111 insertions(+), 112 deletions(-) create mode 100755 dev/upgrade.sh diff --git a/dev/upgrade.sh b/dev/upgrade.sh new file mode 100755 index 0000000000..2410e44198 --- /dev/null +++ b/dev/upgrade.sh @@ -0,0 +1,8 @@ + docker run -ti -e SERVER_SECRET=secret \ + -e MONGO_URL=mongodb://127.0.0.1:27017 \ + -e TRANSACTOR_URL=ws://127.0.0.1:3333 \ + -e MINIO_ENDPOINT=minio \ + -e MINIO_ACCESS_KEY=minioadmin \ + -e MINIO_SECRET_KEY=minioadmin \ + --rm --network host \ + hardcoreeng/tool node ./bundle upgrade \ No newline at end of file diff --git a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte index afabb824d2..681e84fad0 100644 --- a/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte +++ b/plugins/attachment-resources/src/components/AttachmentStyledBox.svelte @@ -23,6 +23,7 @@ import attachment from '../plugin' import { deleteFile, uploadFile } from '../utils' import AttachmentPresenter from './AttachmentPresenter.svelte' + import AttachmentPreview from './AttachmentPreview.svelte' export let objectId: Ref | undefined = undefined export let space: Ref | undefined = undefined @@ -38,6 +39,7 @@ export let fakeAttach: 'fake' | 'hidden' | 'normal' = 'normal' export let refContainer: HTMLElement | undefined = undefined export let shouldSaveDraft: boolean = false + export let useAttachmentPreview = false const dispatch = createEventDispatcher() @@ -131,6 +133,8 @@ }) newAttachments.add(_id) attachments = attachments + saved = false + dispatch('attached', _id) saveDraft() } catch (err: any) { setPlatformStatus(unknownError(err)) @@ -165,6 +169,7 @@ async function removeAttachment (attachment: Attachment): Promise { removedAttachments.add(attachment) attachments.delete(attachment._id) + dispatch('detached', attachment._id) attachments = attachments saveDraft() } @@ -179,6 +184,7 @@ attachment.attachedToClass, 'attachments' ) + dispatch('detached', attachment._id) } else { await deleteFile(attachment.file) } @@ -209,7 +215,10 @@ } } - export function createAttachments (): Promise { + export async function createAttachments (): Promise { + if (saved) { + return + } saved = true const promises: Promise[] = [] newAttachments.forEach((p) => { @@ -221,7 +230,8 @@ removedAttachments.forEach((p) => { promises.push(deleteAttachment(p)) }) - return Promise.all(promises).then() + await Promise.all(promises) + saveDraft() } $: if (attachments.size || newAttachments.size || removedAttachments.size) { @@ -313,13 +323,17 @@
{#each Array.from(attachments.values()) as attachment}
- { - if (result !== undefined) removeAttachment(attachment) - }} - /> + {#if useAttachmentPreview} + + {:else} + { + if (result !== undefined) removeAttachment(attachment) + }} + /> + {/if}
{/each}
diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index 3dead91735..0e8e2a6840 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -284,7 +284,8 @@ "SevenHoursLength": "Seven Hours", "EightHoursLength": "Eight Hours", "CreatedOn": "Created on", - "HourLabel": "h" + "HourLabel": "h", + "Saved": "Saved..." }, "status": {} } diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index 01f4cc13b6..d556a26cef 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -284,7 +284,8 @@ "SevenHoursLength": "Семь Часов", "EightHoursLength": "Восемь Часов", "CreatedOn": "Создана", - "HourLabel": "ч" + "HourLabel": "ч", + "Saved": "Сохранено..." }, "status": {} } diff --git a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte index e391553919..f57eee610c 100644 --- a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte @@ -168,7 +168,7 @@ } -
+
-
+
-{value ? value : ''} +{value || ''} diff --git a/tests/sanity/tests/tracker.utils.ts b/tests/sanity/tests/tracker.utils.ts index f40629c507..6bfa7188d9 100644 --- a/tests/sanity/tests/tracker.utils.ts +++ b/tests/sanity/tests/tracker.utils.ts @@ -1,4 +1,4 @@ -import { Page, expect } from '@playwright/test' +import { expect, Page } from '@playwright/test' import { PlatformURI } from './utils' export interface IssueProps { @@ -45,12 +45,17 @@ export async function setViewOrder (page: Page, orderName: string): Promise { +export async function fillIssueForm (page: Page, props: IssueProps, issue: boolean): Promise { const { name, description, status, assignee, labels, priority, component, sprint } = props - const af = addForm ? 'form ' : '' - await page.fill(af + '[placeholder="Issue\\ title"]', name) + const af = issue ? 'form ' : '[id="sub-issue-child-editor"] ' + const issueTitle = page.locator(af + '[placeholder="Issue\\ title"]') + await issueTitle.fill(name) + await issueTitle.evaluate((e) => e.blur()) + if (description !== undefined) { - await page.fill('.ProseMirror', description) + const pm = await page.locator(af + '.ProseMirror') + await pm.fill(description) + await pm.evaluate((e) => e.blur()) } if (status !== undefined) { await page.click(af + '#status-editor')