mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Restoring an archived card whose list had reached a hard WIP limit did nothing at all: the Restore handlers checked canBeRestored() and, when it said no, returned without a word or a method call, and Restore all skipped such cards just as quietly. - Restore, in the Archive sidebar and in an open archived card, now goes through one function (restoreArchivedCard): a list that is full - or gone - opens the restore-to-list popup, which says the list has reached its WIP limit and offers only lists with room; with none left it says so instead of offering a list that would fail again. - Restore all restores every card that has room and then says how many it left out and why. Its popup opens against the link kept before the loop: after the awaits the browser has cleared evt.currentTarget. - canBeRestored() decides with models/lib/wipRestore.js, which also blocks a list that is OVER its hard limit: the old `===` let a card into a list whose limit had been lowered below its count. A soft limit still only warns. Tests: tests/wipRestore.test.cjs (the rule, over-limit and soft/disabled negatives, both Restore paths, Restore all's count, and a scan that no client code skips a blocked restore without a word); restore-wip-limit.e2e.js against the production bundle (restore into another list with the full one not offered, Restore all restoring what has room and naming the rest, a soft limit restoring at once), 12 of 12 over three repeats with the existing archive restore test. The four new strings are translated in every locale. Thanks to jullbo and xet7 ! Fixes #6772.
19 lines
721 B
JavaScript
19 lines
721 B
JavaScript
'use strict';
|
|
|
|
// Does a list's HARD WIP limit stop a card from being restored into it (#6772)?
|
|
//
|
|
// A soft limit only warns, so it never blocks. A hard one blocks once the list
|
|
// holds as many cards as the limit allows - or MORE: a limit lowered below a
|
|
// list's count left it over the limit, and the old `===` let a card in there.
|
|
//
|
|
// wip: the list's wipLimit { enabled, soft, value }; count: its cards now.
|
|
// Pure, no Meteor: tests/wipRestore.test.cjs.
|
|
function wipLimitBlocksRestore(wip, count) {
|
|
if (!wip || !wip.enabled || wip.soft) return false;
|
|
const value = Number(wip.value);
|
|
if (!Number.isFinite(value)) return false;
|
|
return Number(count) >= value;
|
|
}
|
|
|
|
module.exports = { wipLimitBlocksRestore };
|