From fb0340eb24e10c76fc685bacad21b33a6fdf2bec Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Wed, 18 May 2022 11:04:54 +0700 Subject: [PATCH] Tracker: split "edit issue" dialog to preview / edit (#1731) --- models/tracker/src/index.ts | 4 + .../src/components/StyledTextArea.svelte | 84 ++++++ .../src/components/StyledTextEditor.svelte | 22 +- packages/text-editor/src/index.ts | 1 + plugins/tracker-assets/lang/en.json | 5 +- plugins/tracker-assets/lang/ru.json | 4 +- plugins/tracker-resources/package.json | 3 +- .../components/issues/AssigneeEditor.svelte | 53 ++++ .../components/issues/DueDateEditor.svelte | 49 ++++ .../components/issues/DueDatePresenter.svelte | 18 +- .../src/components/issues/EditIssue.svelte | 258 ------------------ .../components/issues/IssuePresenter.svelte | 4 +- .../issues/edit/ControlPanel.svelte | 93 +++++++ .../issues/edit/CopyToClipboard.svelte | 61 +++++ .../components/issues/edit/EditIssue.svelte | 197 +++++++++++++ .../{issues => projects}/ProjectEditor.svelte | 30 +- .../projects/ProjectTitlePresenter.svelte | 25 ++ plugins/tracker-resources/src/index.ts | 6 +- plugins/tracker-resources/src/plugin.ts | 6 +- plugins/tracker-resources/src/utils.ts | 19 ++ 20 files changed, 644 insertions(+), 298 deletions(-) create mode 100644 packages/text-editor/src/components/StyledTextArea.svelte create mode 100644 plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte create mode 100644 plugins/tracker-resources/src/components/issues/DueDateEditor.svelte delete mode 100644 plugins/tracker-resources/src/components/issues/EditIssue.svelte create mode 100644 plugins/tracker-resources/src/components/issues/edit/ControlPanel.svelte create mode 100644 plugins/tracker-resources/src/components/issues/edit/CopyToClipboard.svelte create mode 100644 plugins/tracker-resources/src/components/issues/edit/EditIssue.svelte rename plugins/tracker-resources/src/components/{issues => projects}/ProjectEditor.svelte (79%) create mode 100644 plugins/tracker-resources/src/components/projects/ProjectTitlePresenter.svelte diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 2f86ae9ccf..feb3e13e2b 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -327,6 +327,10 @@ export function createModel (builder: Builder): void { presenter: tracker.component.StatusPresenter }) + builder.mixin(tracker.class.Project, core.class.Class, view.mixin.AttributePresenter, { + presenter: tracker.component.ProjectTitlePresenter + }) + builder.createDoc( workbench.class.Application, core.space.Model, diff --git a/packages/text-editor/src/components/StyledTextArea.svelte b/packages/text-editor/src/components/StyledTextArea.svelte new file mode 100644 index 0000000000..a49deda443 --- /dev/null +++ b/packages/text-editor/src/components/StyledTextArea.svelte @@ -0,0 +1,84 @@ + + +
{ + if (focused) { + textEditor?.focus() + } + }} +> + {#if label} +
+ {/if} + { + focused = true + }} + on:blur={() => { + focused = false + dispatch('value', rawValue) + content = rawValue + }} + on:value={(evt) => { + rawValue = evt.detail + }} + /> +
+ + diff --git a/packages/text-editor/src/components/StyledTextEditor.svelte b/packages/text-editor/src/components/StyledTextEditor.svelte index 0866c1801f..1cd5876c43 100644 --- a/packages/text-editor/src/components/StyledTextEditor.svelte +++ b/packages/text-editor/src/components/StyledTextEditor.svelte @@ -28,6 +28,7 @@ export let content: string = '' export let placeholder: IntlString = textEditorPlugin.string.EditorPlaceholder export let showButtons = true + export let isScrollable = true let textEditor: TextEditor @@ -42,7 +43,24 @@
- + {#if isScrollable} + + { + dispatch('message', ev.detail) + content = '' + textEditor.clear() + }} + on:blur + on:focus + supportSubmit={false} + /> + + {:else} - + {/if}
{#if showButtons} diff --git a/packages/text-editor/src/index.ts b/packages/text-editor/src/index.ts index b1d4d39a78..ad7ba8f116 100644 --- a/packages/text-editor/src/index.ts +++ b/packages/text-editor/src/index.ts @@ -20,6 +20,7 @@ import { textEditorId } from './plugin' export * from '@anticrm/presentation/src/types' export { default as ReferenceInput } from './components/ReferenceInput.svelte' export { default as StyledTextBox } from './components/StyledTextBox.svelte' +export { default as StyledTextArea } from './components/StyledTextArea.svelte' export { default as StyledTextEditor } from './components/StyledTextEditor.svelte' export { default as TextEditor } from './components/TextEditor.svelte' export { default } from './plugin' diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index b98d9fa864..869fe2f834 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -96,6 +96,7 @@ "PastMonth": "Past month", "CopyIssueUrl": "Copy Issue URL to clipboard", "CopyIssueId": "Copy Issue ID to clipboard", + "CopyIssueBranch": "Copy Git branch name to clipboard", "AssetLabel": "Asset", "AddToProject": "Add to project\u2026", "MoveToProject": "Move to project\u2026", @@ -113,7 +114,9 @@ "FilterIs": "is", "FilterIsNot": "is not", "FilterIsEither": "is either of", - "FilterStatesCount": "{value, plural, =1 {1 state} other {# states}}" + "FilterStatesCount": "{value, plural, =1 {1 state} other {# states}}", + + "EditIssue": "Edit {title}" }, "status": {} } \ No newline at end of file diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index a8d9273d25..72f507d607 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -73,7 +73,9 @@ "GotoBacklog": "Перейти к пулу задач", "GotoBoard": "Перейти к канбану", "GotoProjects": "Перейти к проекту", - "GotoTrackerApplication": "Перейти к приложению Трекер" + "GotoTrackerApplication": "Перейти к приложению Трекер", + + "EditIssue": "Редактирование {title}" }, "status": {} } diff --git a/plugins/tracker-resources/package.json b/plugins/tracker-resources/package.json index 02281014ed..7d5e64a932 100644 --- a/plugins/tracker-resources/package.json +++ b/plugins/tracker-resources/package.json @@ -49,6 +49,7 @@ "@anticrm/view-resources": "~0.6.0", "@anticrm/text-editor": "~0.6.0", "@anticrm/panel": "~0.6.0", - "@anticrm/kanban": "~0.6.0" + "@anticrm/kanban": "~0.6.0", + "@anticrm/attachment-resources": "~0.6.0" } } diff --git a/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte new file mode 100644 index 0000000000..dca78f50b3 --- /dev/null +++ b/plugins/tracker-resources/src/components/issues/AssigneeEditor.svelte @@ -0,0 +1,53 @@ + + + +{#if value} + + handleAssigneeChanged(detail)} + /> + +{/if} diff --git a/plugins/tracker-resources/src/components/issues/DueDateEditor.svelte b/plugins/tracker-resources/src/components/issues/DueDateEditor.svelte new file mode 100644 index 0000000000..46270acde2 --- /dev/null +++ b/plugins/tracker-resources/src/components/issues/DueDateEditor.svelte @@ -0,0 +1,49 @@ + + + +{#if value} + + handleDueDateChanged(detail)} + /> +{/if} diff --git a/plugins/tracker-resources/src/components/issues/DueDatePresenter.svelte b/plugins/tracker-resources/src/components/issues/DueDatePresenter.svelte index a158247968..811cf5cea1 100644 --- a/plugins/tracker-resources/src/components/issues/DueDatePresenter.svelte +++ b/plugins/tracker-resources/src/components/issues/DueDatePresenter.svelte @@ -19,10 +19,10 @@ import { getClient } from '@anticrm/presentation' import DueDatePopup from './DueDatePopup.svelte' import tracker from '../../plugin' + import { getDueDateIconModifier } from '../../utils' export let value: WithLookup - const WARNING_DAYS = 7 const client = getClient() $: today = new Date(new Date(Date.now()).setHours(0, 0, 0, 0)) @@ -30,7 +30,7 @@ $: isOverdue = dueDateMs !== null && dueDateMs < today.getTime() $: dueDate = dueDateMs === null ? null : new Date(dueDateMs) $: daysDifference = dueDate === null ? null : getDaysDifference(today, dueDate) - $: iconModifier = getIconModifier(isOverdue, daysDifference) + $: iconModifier = getDueDateIconModifier(isOverdue, daysDifference) $: formattedDate = !dueDateMs ? '' : new Date(dueDateMs).toLocaleString('default', { month: 'short', day: 'numeric' }) const handleDueDateChanged = async (event: CustomEvent) => { @@ -43,20 +43,6 @@ await client.update(value, { dueDate: newDate }) } - const getIconModifier = (isOverdue: boolean, daysDifference: number | null) => { - if (isOverdue) { - return 'overdue' as 'overdue' // Fixes `DatePresenter` icon type issue - } - - if (daysDifference === 0) { - return 'critical' as 'critical' - } - - if (daysDifference !== null && daysDifference <= WARNING_DAYS) { - return 'warning' as 'warning' - } - } - $: shouldRenderPresenter = dueDateMs && value.$lookup?.status?.category !== tracker.issueStatusCategory.Completed && diff --git a/plugins/tracker-resources/src/components/issues/EditIssue.svelte b/plugins/tracker-resources/src/components/issues/EditIssue.svelte deleted file mode 100644 index cbbe214347..0000000000 --- a/plugins/tracker-resources/src/components/issues/EditIssue.svelte +++ /dev/null @@ -1,258 +0,0 @@ - - - -{#if issue !== undefined} - { - dispatch('close') - }} - > - Custom Title - -
- {#if currentTeam} - - {/if} -
-
-
-
- -
- {/if} - - -{/if} - - diff --git a/plugins/tracker-resources/src/components/issues/IssuePresenter.svelte b/plugins/tracker-resources/src/components/issues/IssuePresenter.svelte index 1d1f8da544..613c06fb48 100644 --- a/plugins/tracker-resources/src/components/issues/IssuePresenter.svelte +++ b/plugins/tracker-resources/src/components/issues/IssuePresenter.svelte @@ -27,13 +27,13 @@ $: issueName = `${currentTeam.identifier}-${value.number}` - const handleIssueEditorOpened = () => { + const handleIssuePreviewOpened = () => { showPanel(tracker.component.EditIssue, value._id, value._class, 'content') } {#if value && shortLabel} -
+
diff --git a/plugins/tracker-resources/src/components/issues/edit/ControlPanel.svelte b/plugins/tracker-resources/src/components/issues/edit/ControlPanel.svelte new file mode 100644 index 0000000000..47b3b9c820 --- /dev/null +++ b/plugins/tracker-resources/src/components/issues/edit/ControlPanel.svelte @@ -0,0 +1,93 @@ + + + +
+ + + + + + + + + + + + + + +
+
+ + +