mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-22 17:45:02 +02:00
TSK-1335 Improve draft (#3092)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -83,15 +83,15 @@
|
||||
value: ValueType,
|
||||
defaultStatus: Ref<IssueStatus> | undefined
|
||||
): WithLookup<IssueStatus> | undefined {
|
||||
if (defaultStatus !== undefined) {
|
||||
defaultIssueStatus = undefined
|
||||
changeStatus(defaultStatus, false)
|
||||
return statuses?.find((status) => status._id === defaultStatus)
|
||||
if (value.status !== undefined) {
|
||||
const current = statuses?.find((status) => status._id === value.status)
|
||||
if (current) return current
|
||||
}
|
||||
if (defaultIssueStatus !== undefined) {
|
||||
const res = statuses?.find((status) => status._id === defaultStatus)
|
||||
changeStatus(res?._id, false)
|
||||
return res
|
||||
}
|
||||
const current = statuses?.find((status) => status._id === value.status)
|
||||
if (current) return current
|
||||
changeStatus(statuses?.[0]?._id, false)
|
||||
return statuses?.[0]
|
||||
}
|
||||
|
||||
$: selectedStatus = getSelectedStatus(statuses, value, defaultIssueStatus)
|
||||
|
||||
@@ -19,25 +19,26 @@
|
||||
import presentation, { DraftController, getClient, KeyedAttribute } from '@hcengineering/presentation'
|
||||
import tags, { TagElement, TagReference } from '@hcengineering/tags'
|
||||
import { calcRank, Issue, IssueDraft, IssuePriority, Project } from '@hcengineering/tracker'
|
||||
import { addNotification, Button, Component, EditBox, deviceOptionsStore, ButtonSize } from '@hcengineering/ui'
|
||||
import { createEventDispatcher, onDestroy } from 'svelte'
|
||||
import { addNotification, Button, ButtonSize, Component, deviceOptionsStore, EditBox } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { generateIssueShortLink, getIssueId } from '../../../issues'
|
||||
import tracker from '../../../plugin'
|
||||
import AssigneeEditor from '../AssigneeEditor.svelte'
|
||||
import IssueNotification from '../IssueNotification.svelte'
|
||||
import PriorityEditor from '../PriorityEditor.svelte'
|
||||
import StatusEditor from '../StatusEditor.svelte'
|
||||
import EstimationEditor from '../timereport/EstimationEditor.svelte'
|
||||
import { generateIssueShortLink, getIssueId } from '../../../issues'
|
||||
import { onDestroy } from 'svelte'
|
||||
|
||||
export let parentIssue: Issue
|
||||
export let currentProject: Project
|
||||
export let shouldSaveDraft: boolean = false
|
||||
|
||||
const draftController = new DraftController<IssueDraft>(parentIssue._id)
|
||||
const draftController = new DraftController<IssueDraft>(`${parentIssue._id}_subIssue`)
|
||||
const draft = shouldSaveDraft ? draftController.get() : undefined
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
onDestroy(() => draftController.unsubscribe())
|
||||
onDestroy(() => draftController.destroy())
|
||||
|
||||
let object = draft ?? getIssueDefaults()
|
||||
|
||||
@@ -77,10 +78,14 @@
|
||||
sprint: parentIssue.sprint
|
||||
}
|
||||
|
||||
if (shouldSaveDraft) {
|
||||
draftController.watch(object, empty)
|
||||
function objectChange (object: IssueDraft, empty: any) {
|
||||
if (shouldSaveDraft) {
|
||||
draftController.save(object, empty)
|
||||
}
|
||||
}
|
||||
|
||||
$: objectChange(object, empty)
|
||||
|
||||
function resetToDefaults () {
|
||||
object = getIssueDefaults()
|
||||
focusIssueTitle?.()
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
let subIssueEditorRef: HTMLDivElement
|
||||
let isCollapsed = false
|
||||
let isCreating = $draftsStore[issue._id] !== undefined
|
||||
let isCreating = $draftsStore[`${issue._id}_subIssue`] !== undefined
|
||||
|
||||
$: hasSubIssues = issue.subIssues > 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user