[UBER-179] Fix issue draft cleanup after switching a project (#3258)

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@icloud.com>
This commit is contained in:
Sergei Ogorelkov 2023-05-26 20:39:47 +04:00 committed by GitHub
parent 73169ff987
commit 9e85271fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,9 +99,10 @@
const client = getClient()
const hierarchy = client.getHierarchy()
const parentQuery = createQuery()
let _space = space
let _space = draft?.space ?? space
let object = draft ?? getDefaultObject(id)
let isAssigneeTouched = false
function objectChange (object: IssueDraft, empty: any) {
if (shouldSaveDraft) {
@ -188,7 +189,7 @@
component,
milestone,
priority,
space
space: _space
}
$: if (object.space !== _space) {
@ -278,6 +279,7 @@
}
$: spaceQuery.query(tracker.class.Project, { _id: _space }, (res) => {
resetDefaultAssigneeId()
currentProject = res.shift()
})
@ -287,8 +289,14 @@
}
}
function resetDefaultAssigneeId () {
if (!isAssigneeTouched && !!object.assignee && object.assignee === currentProject?.defaultAssignee) {
object = { ...object, assignee: assignee ?? null }
}
}
function updateAssigneeId (object: IssueDraft, currentProject: Project | undefined) {
if (object.assignee == null && currentProject !== undefined) {
if (!isAssigneeTouched && object.assignee == null && currentProject !== undefined) {
if (currentProject.defaultAssignee !== undefined) {
object.assignee = currentProject.defaultAssignee
} else {
@ -405,6 +413,7 @@
draftController.remove()
resetObject()
descriptionBox?.removeDraft(false)
isAssigneeTouched = false
}
async function setParentIssue () {
@ -658,6 +667,7 @@
width={'min-content'}
short
on:change={({ detail }) => {
isAssigneeTouched = true
object.assignee = detail
manager.setFocusPos(5)
}}