TSK-1114: fix default issue status (#3044)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-04-25 23:32:55 +05:00 committed by GitHub
parent 3cd606ad21
commit 40d13681d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -624,6 +624,7 @@
value={object}
kind={'secondary'}
size={'large'}
defaultIssueStatus={draft ? undefined : currentProject?.defaultIssueStatus}
shouldShowLabel={true}
on:change={({ detail }) => (object.status = detail)}
/>

View File

@ -38,6 +38,7 @@
export let size: ButtonSize = 'large'
export let justify: 'left' | 'center' = 'left'
export let width: string | undefined = undefined
export let defaultIssueStatus: Ref<IssueStatus> | undefined = undefined
const client = getClient()
const dispatch = createEventDispatcher()
@ -75,15 +76,21 @@
function getSelectedStatus (
statuses: WithLookup<IssueStatus>[] | undefined,
value: ValueType
value: ValueType,
defaultStatus: Ref<IssueStatus> | undefined
): WithLookup<IssueStatus> | undefined {
if (defaultStatus !== undefined) {
defaultIssueStatus = undefined
changeStatus(defaultStatus)
return statuses?.find((status) => status._id === defaultStatus)
}
const current = statuses?.find((status) => status._id === value.status)
if (current) return current
changeStatus(statuses?.[0]?._id)
return statuses?.[0]
}
$: selectedStatus = getSelectedStatus(statuses, value)
$: selectedStatus = getSelectedStatus(statuses, value, defaultIssueStatus)
$: selectedStatusLabel = shouldShowLabel ? selectedStatus?.name : undefined
$: statusesInfo = statuses?.map((s) => {
return {