From ee0a1204509b3be8af577ac4f512a90576dd194d Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Fri, 12 May 2023 21:01:04 +0400 Subject: [PATCH] [TSK-1491] Fix empty sprint status on popup close (#3175) Signed-off-by: Sergei Ogorelkov --- models/tracker/src/migration.ts | 12 ++++++++++++ .../components/sprints/SprintStatusPresenter.svelte | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index d5c7076815..2608d1ddc0 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -40,6 +40,8 @@ import { IssueTemplate, IssueTemplateChild, Project, + Sprint, + SprintStatus, TimeReportDayType } from '@hcengineering/tracker' import { DOMAIN_TRACKER } from '.' @@ -730,6 +732,14 @@ async function setCreate (client: MigrationClient): Promise { } } +async function fixSprintEmptyStatuses (client: MigrationClient): Promise { + await client.update( + DOMAIN_TRACKER, + { _class: tracker.class.Sprint, $or: [{ status: null }, { status: undefined }] }, + { status: SprintStatus.Planned } + ) +} + export const trackerOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise { await client.update( @@ -762,6 +772,8 @@ export const trackerOperation: MigrateOperation = { ofAttribute: tracker.attribute.IssueStatus } ) + + await fixSprintEmptyStatuses(client) }, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) diff --git a/plugins/tracker-resources/src/components/sprints/SprintStatusPresenter.svelte b/plugins/tracker-resources/src/components/sprints/SprintStatusPresenter.svelte index 247e14fa20..1420fe1dca 100644 --- a/plugins/tracker-resources/src/components/sprints/SprintStatusPresenter.svelte +++ b/plugins/tracker-resources/src/components/sprints/SprintStatusPresenter.svelte @@ -20,12 +20,20 @@ import SprintStatusSelector from './SprintStatusSelector.svelte' export let value: SprintStatus - export let onChange: ((value: SprintStatus | undefined) => void) | undefined = undefined + export let onChange: ((value: SprintStatus) => void) | undefined = undefined export let kind: ButtonKind = 'link' export let size: ButtonSize = 'large' export let justify: 'left' | 'center' = 'left' export let width: string | undefined = '100%' + function handleComponentStatusChange (newSprintStatus: SprintStatus | undefined) { + if (newSprintStatus === undefined || onChange === undefined) { + return + } + + onChange(newSprintStatus) + } + $: isEditable = onChange !== undefined @@ -37,5 +45,5 @@ {isEditable} showTooltip={isEditable ? { label: tracker.string.SetStatus } : undefined} selectedSprintStatus={value} - onSprintStatusChange={onChange} + onSprintStatusChange={handleComponentStatusChange} />