diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index b63639e506..50bec76943 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -593,12 +593,17 @@ object = { ...object, project: projectId } } - const handleSprintIdChanged = (sprintId: Ref | null | undefined) => { + const handleSprintIdChanged = async (sprintId: Ref | null | undefined) => { if (sprintId === undefined) { return } + let projectSprintId: Ref | null + if (sprintId != null) { + const sprint = await client.findOne(tracker.class.Sprint, { _id: sprintId }) + projectSprintId = sprint && sprint.project ? sprint.project : null + } else projectSprintId = null - object = { ...object, sprint: sprintId } + object = { ...object, sprint: sprintId, project: projectSprintId } } function addTagRef (tag: TagElement): void { diff --git a/server-plugins/tracker-resources/src/index.ts b/server-plugins/tracker-resources/src/index.ts index 9c12a3d074..aea5b09f6a 100644 --- a/server-plugins/tracker-resources/src/index.ts +++ b/server-plugins/tracker-resources/src/index.ts @@ -336,6 +336,24 @@ async function doIssueUpdate ( })) ) } + + if (Object.prototype.hasOwnProperty.call(updateTx.operations, 'sprint')) { + if (updateTx.operations.sprint != null) { + const [sprint] = await control.findAll(tracker.class.Sprint, { _id: updateTx.operations.sprint }, { limit: 1 }) + res.push( + control.txFactory.createTxUpdateDoc(updateTx.objectClass, updateTx.objectSpace, updateTx.objectId, { + project: sprint.project + }) + ) + } else { + res.push( + control.txFactory.createTxUpdateDoc(updateTx.objectClass, updateTx.objectSpace, updateTx.objectId, { + project: null + }) + ) + } + } + if ( Object.prototype.hasOwnProperty.call(updateTx.operations, 'estimation') || Object.prototype.hasOwnProperty.call(updateTx.operations, 'reportedTime') diff --git a/tests/sanity/tests/tracker.layout.spec.ts b/tests/sanity/tests/tracker.layout.spec.ts index 77aa559ab2..39a11872f7 100644 --- a/tests/sanity/tests/tracker.layout.spec.ts +++ b/tests/sanity/tests/tracker.layout.spec.ts @@ -104,8 +104,6 @@ test.describe('tracker layout tests', () => { let groupLabels: any[] if (group === 'Sprint') { groupLabels = issuesProps.map((props) => props.sprint) - } else if (group === 'Project') { - groupLabels = issuesProps.map((props) => props.project) } else { groupLabels = groupsLabels[group] ?? [] }