Files
wekan/models/lib/subtaskCopy.js
T
Lauri Ojansivu 823dc94715 Link a copied or moved item to the other board's sprint and release of the same name.
As decided on 2026-10-02, a card or swimlane copied or moved to another
board now takes that board's sprint and release of the same name when
exactly one matches: a planned or active sprint, or a release that is
not cancelled. Otherwise they are dropped, as before. Past sprints and
backlog rank always go. This applies to card and swimlane copies,
subtasks copied with their parent, the server hooks behind every move,
and the durable rule copy and move. A move that sets the Scrum revision
itself, as the durable rule move does, is left alone by the hook.

Thanks to xet7 !
2026-10-02 20:53:38 +03:00

43 lines
1.8 KiB
JavaScript

'use strict';
import { copiedCardScrum } from './scrumCopy.js';
// #3185 "Template with subtasks and checklists". When a card is copied (e.g.
// generating a card from a template), each subtask was inserted as a BARE card
// document — its checklists (and their items) were never copied, so the new
// card's subtasks came out empty. The parent card's own checklists were copied,
// but the per-subtask copy skipped them.
//
// buildCopiedSubtaskFields() builds the card document for a copied subtask
// (re-homed under the new parent and onto the destination board), and
// subtaskCopyChildKinds() declares the child records a subtask copy must also
// reproduce — 'checklists' being the one that was missing in #3185. Meteor-free
// so the re-homing and the copy contract are unit tested; the caller then runs
// Checklist.copy() for each kind.
function buildCopiedSubtaskFields(subtask, { newParentId, boardId, swimlaneId, listId, planning = null } = {}) {
const fields = Object.assign({}, subtask);
delete fields._id;
delete fields.__id;
delete fields.syncExternalId;
delete fields.syncSourceType;
delete fields.syncLastSource;
delete fields.syncSourceKey;
delete fields.scrum;
delete fields.scrumRevision;
// On another board, its sprint and release by name (scrumCopy.js).
Object.assign(fields, copiedCardScrum(subtask, boardId, { planning }));
fields.parentId = newParentId;
fields.boardId = boardId;
fields.swimlaneId = swimlaneId;
fields.listId = listId;
return fields;
}
// The child-record kinds a full subtask copy must reproduce. Guards #3185: a
// subtask copy that reproduces only the card (this list empty / missing
// 'checklists') is the regression.
function subtaskCopyChildKinds() {
return ['checklists'];
}
export { buildCopiedSubtaskFields, subtaskCopyChildKinds };