Files
wekan/server/lib/ruleCardScrum.js
T
Lauri Ojansivu 727ceedd01 Let a card be in more than one release.
A card had exactly one release, scrum.releaseId. Jira import kept only the
first fix version of an issue and reported the rest as lost, Jira export
wrote no fix versions at all, and the card UI could not show or pick more
than one release.

A card's releases are now a list, scrum.releaseIds, with releaseId kept as
its first entry so older servers, importers and REST readers still see one.
Existing cards are not migrated: every reader goes through cardReleaseIds(),
which reads the list and the old single field the same way, so cards saved
either way work side by side, and a card moves to the new form on its next
Scrum save. A save with releaseIds replaces the list; a save with only
releaseId, from an older client, replaces the first release and keeps the
others, and null clears them. Every release must belong to the board,
checked in one query; duplicates collapse and a releaseId that contradicts
the list is refused.

Copies and moves to another board link each release by name. The native
transfer writes one release exactly as before and adds releaseIds only for
cards with several, and remaps each of them on import. Jira import maps every
fix version and Jira export writes them all as fixVersions. Board View /
Sprints shows each release's cards and how many are done, counting a card in
each of its releases. Scrum History checks and guards every release, and
rule e-mails name them all. The Product Backlog and card details use a
multiple select.

tests/scrumMultipleReleases.test.cjs covers the rules and fails if any code
reads the single field directly; a Playwright spec drives the UI. New text is
in English, pending Transifex.

Thanks to xet7 !
2026-10-08 11:51:44 +03:00

39 lines
2.0 KiB
JavaScript

'use strict';
const { cardReleaseIds } = require('../../models/lib/scrum');
const fields = [
['Sprint', 'sprintId', 'Scrum sprint'], ['PastSprints', 'pastSprintIds', 'Past Scrum sprints'],
['Release', 'releaseId', 'Scrum release'], ['IssueType', 'issueType', 'Scrum issue type'],
['AcceptanceCriteria', 'acceptanceCriteria', 'Scrum acceptance criteria'], ['BacklogRank', 'backlogRank', 'Scrum backlog rank'],
];
const scrumVisibility = board => fields.map(([suffix]) => board?.scrum?.visibility?.[`card${suffix}`] === true);
async function appendRuleCardScrum({ card, board, readRecord, add }) {
const visibility = scrumVisibility(board), references = [];
for (let index = 0; index < fields.length; index++) {
if (!visibility[index]) continue;
const [, field, label] = fields[index], value = card.scrum?.[field];
if (!['sprintId', 'pastSprintIds', 'releaseId'].includes(field)) { add(label, value); continue; }
// A card's releases are a list (models/lib/scrum.js cardReleaseIds), its
// legacy single `releaseId` included.
const ids = field === 'pastSprintIds' ? (Array.isArray(value) ? value : [])
: field === 'releaseId' ? cardReleaseIds(card.scrum) : [value];
const names = [], kind = field === 'releaseId' ? 'release' : 'sprint';
for (const id of [...new Set(ids)]) {
if (typeof id !== 'string' || !id) continue;
const record = await readRecord(kind, id, card.boardId);
if (!record || record._id !== id || record.boardId !== card.boardId || record.deletedAt) continue;
if (typeof record.name !== 'string') continue;
names.push(record.name); references.push({ kind, id, name: record.name });
}
add(label, names);
}
return async () => {
for (const { kind, id, name } of references) {
const record = await readRecord(kind, id, card.boardId);
if (!record || record._id !== id || record.boardId !== card.boardId || record.deletedAt || record.name !== name) {
throw new Error('rule-email-scrum-changed');
}
}
};
}
module.exports = { scrumVisibility, appendRuleCardScrum };