Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker: split "edit issue" dialog to preview / edit #1731

Merged
merged 19 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
84 changes: 84 additions & 0 deletions packages/text-editor/src/components/StyledTextArea.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<script lang="ts">
import { IntlString } from '@anticrm/platform'
import { Label } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import textEditorPlugin from '../plugin'
import StyledTextEditor from './StyledTextEditor.svelte'

export let label: IntlString | undefined = undefined
export let content: string
export let placeholder: IntlString = textEditorPlugin.string.EditorPlaceholder

export let showButtons = true
export let focus = false

let rawValue: string
let oldContent = ''

$: if (oldContent !== content) {
oldContent = content
rawValue = content
}

let textEditor: StyledTextEditor

export function submit (): void {
textEditor.submit()
}
const dispatch = createEventDispatcher()
let focused = false

let needFocus = focus

$: if (textEditor && needFocus) {
textEditor.focus()
needFocus = false
}
</script>

<div
class="antiComponent styled-box"
on:click={() => {
if (focused) {
textEditor?.focus()
}
}}
>
{#if label}
<div class="label"><Label {label} /></div>
{/if}
<StyledTextEditor
{placeholder}
{showButtons}
isScrollable={false}
bind:content={rawValue}
bind:this={textEditor}
on:focus={() => {
focused = true
}}
on:blur={() => {
focused = false
dispatch('value', rawValue)
content = rawValue
}}
on:value={(evt) => {
rawValue = evt.detail
}}
/>
</div>

<style lang="scss">
.styled-box {
flex-grow: 1;

.label {
padding-bottom: 0.25rem;
font-size: 0.75rem;
color: var(--theme-caption-color);
opacity: 0.3;
transition: top 200ms;
pointer-events: none;
user-select: none;
}
}
</style>
22 changes: 20 additions & 2 deletions packages/text-editor/src/components/StyledTextEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -42,7 +43,24 @@
<div class="ref-container">
<div class="textInput">
<div class="inputMsg">
<ScrollBox bothScroll stretch>
{#if isScrollable}
<ScrollBox bothScroll stretch>
<TextEditor
bind:content
{placeholder}
bind:this={textEditor}
on:value
on:content={(ev) => {
dispatch('message', ev.detail)
content = ''
textEditor.clear()
}}
on:blur
on:focus
supportSubmit={false}
/>
</ScrollBox>
{:else}
<TextEditor
bind:content
{placeholder}
Expand All @@ -57,7 +75,7 @@
on:focus
supportSubmit={false}
/>
</ScrollBox>
{/if}
</div>
</div>
{#if showButtons}
Expand Down
1 change: 1 addition & 0 deletions packages/text-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion plugins/tracker-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {}
}
4 changes: 3 additions & 1 deletion plugins/tracker-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
"GotoBacklog": "Перейти к пулу задач",
"GotoBoard": "Перейти к канбану",
"GotoProjects": "Перейти к проекту",
"GotoTrackerApplication": "Перейти к приложению Трекер"
"GotoTrackerApplication": "Перейти к приложению Трекер",

"EditIssue": "Редактирование {title}"
},
"status": {}
}
3 changes: 2 additions & 1 deletion plugins/tracker-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
// Copyright © 2022 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { Employee } from '@anticrm/contact'
import { Ref } from '@anticrm/core'
import { getClient, UserBox } from '@anticrm/presentation'
import { Issue } from '@anticrm/tracker'
import { Tooltip } from '@anticrm/ui'
import contact from '@anticrm/contact'
import tracker from '../../plugin'

export let value: Issue

const client = getClient()

const handleAssigneeChanged = async (newAssignee: Ref<Employee> | undefined) => {
if (newAssignee === undefined || value.assignee === newAssignee) {
return
}

await client.update(value, { assignee: newAssignee })
}
</script>

{#if value}
<Tooltip label={tracker.string.AssignTo} fill>
<UserBox
_class={contact.class.Employee}
label={tracker.string.Assignee}
placeholder={tracker.string.Assignee}
value={value.assignee}
allowDeselect
titleDeselect={tracker.string.Unassigned}
size="large"
kind="link"
width="100%"
justify="left"
on:change={({ detail }) => handleAssigneeChanged(detail)}
/>
</Tooltip>
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--
// Copyright © 2022 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { getClient } from '@anticrm/presentation'
import { Issue } from '@anticrm/tracker'
import { DatePresenter, getDaysDifference } from '@anticrm/ui'
import { getDueDateIconModifier } from '../../utils'

export let value: Issue

const client = getClient()

const handleDueDateChanged = async (newDueDate: number | undefined) => {
if (newDueDate === undefined || value.dueDate === newDueDate) {
return
}

await client.update(value, { dueDate: newDueDate })
}

$: today = new Date(new Date(Date.now()).setHours(0, 0, 0, 0))
$: isOverdue = value.dueDate !== null && value.dueDate < today.getTime()
$: dueDate = value.dueDate === null ? null : new Date(value.dueDate)
$: daysDifference = dueDate === null ? null : getDaysDifference(today, dueDate)
$: iconModifier = getDueDateIconModifier(isOverdue, daysDifference)
</script>

{#if value}
<!-- TODO: fix button style and alignment -->
<DatePresenter
kind="transparent"
value={value.dueDate}
icon={iconModifier}
editable
on:change={({ detail }) => handleDueDateChanged(detail)}
/>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
import { getClient } from '@anticrm/presentation'
import DueDatePopup from './DueDatePopup.svelte'
import tracker from '../../plugin'
import { getDueDateIconModifier } from '../../utils'

export let value: WithLookup<Issue>

const WARNING_DAYS = 7
const client = getClient()

$: today = new Date(new Date(Date.now()).setHours(0, 0, 0, 0))
$: dueDateMs = value.dueDate
$: 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<Timestamp>) => {
Expand All @@ -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 &&
Expand Down
Loading