mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
History restored a list but left deletion markers on its cards. Replay the existing soft-delete/restore modifiers across the same board/list and batch. Keep independently deleted cards untouched and refuse lifecycle rows for lists moved to another board. Preserve the deletion batch in lifecycle content and record the actual lifecycle state in history snapshots. The browser regression failed against the previous implementation. It now passes undo, redo and undo again with persisted card checks. Separate read-only rejection, pure negative cases, existing history tests and flow/time-history browser regressions pass. Thanks to rawwerks and xet7 ! Fixes #1023,
27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const { softDeleteSet, restoreModifier } = require('./softDelete');
|
|
|
|
// History replays the same list-and-cards operation as ordinary delete/restore.
|
|
// Never restore every deleted card in a list: only its deletion batch belongs
|
|
// to this operation. Previously deleted cards keep their independent state.
|
|
function listLifecyclePlan(list, row, content, now = new Date()) {
|
|
if (!list || list.boardId !== row.boardId ||
|
|
!content || typeof content.deleted !== 'boolean') return null;
|
|
const batchId = content.deleteBatchId || list.deleteBatchId || row.batchId || row._id;
|
|
const scope = { boardId: list.boardId, listId: list._id };
|
|
if (content.deleted) {
|
|
if (!batchId) return null;
|
|
const at = content.deletedAt ? new Date(content.deletedAt) : now;
|
|
if (!Number.isFinite(at.getTime())) return null;
|
|
const modifier = { $set: softDeleteSet(row.userId, batchId, at) };
|
|
return { modifier, cards: { ...scope, deletedAt: null } };
|
|
}
|
|
return {
|
|
modifier: restoreModifier(),
|
|
cards: batchId ? { ...scope, deleteBatchId: batchId } : null,
|
|
};
|
|
}
|
|
|
|
module.exports = { listLifecyclePlan };
|