Files
wekan/models/lib/checklistHide.js
T
Lauri Ojansivu 23c81e0b6c Tests drive the code the app runs, not copies of it nothing loads.
Ten modules were reached only from tests. Some were copies of production
logic kept beside it, so a test passed whatever production did; the rest
were re-export files that only tests imported.

Copies removed, the test now reading what runs:
- models/lib/oauth2ClientSecretJwt.js: wekan-oidc ran its own vendored copy.
  The package file is now the only one and tests/oauth2ClientSecretJwt
  drives it; tests/packageAppImportBoundary fails if a second copy returns.
- models/lib/scrollbarCss.js (#5439): tests/scrollbarCss reads the rules in
  client/components/lists/list.css.
- models/lib/createListParams.js: tests/createListParams reads the check()
  pattern of createListAfter in server/models/lists.js and runs it by the
  rules of Meteor's check, so changing the server pattern fails the test.
- server/lib/cardMatch.js (#5910): the search is a Mongo selector in
  server/publications/cards.js, which tests/boardSearchComments now reads.
- server/lib/dueDateEdits.js (#6081): Cards.getDueDateChangeCount() counts
  the a-dueAt activities itself.

Helpers that production now calls:
- models/lib/checklistHide.js (was server/lib): the Checklists helpers
  hideCheckedState() and isItemHidden() call it, with the same strict
  "checked is true" rule as before.
- models/lib/subtaskSettings.js (was server/lib): the Board Settings
  subtask pickers mark the selected board and list with it.
  resolveSubtaskLanding(), which nothing called, is removed with its tests.

Re-export files removed, the tests importing the real module:
server/lib/listColors.js, cardScope.js, announcementVisibility.js,
customNumberFormat.js and subtaskHelpers.js.

docs/DeveloperDocs/Directory-Structure.md pointed at the migrations/
directory, which no longer exists; it now names server/migrations.

Thanks to xet7 !
2026-11-21 18:17:53 +02:00

30 lines
1.5 KiB
JavaScript

// Pure helpers for the per-checklist "Hide checked items" toggle (issue #5408).
//
// Each checklist stores its own boolean field `hideCheckedChecklistItems`
// (see models/checklists.js). The toggle must:
// 1. be read PER CHECKLIST (keyed by that checklist's own document/_id),
// never from a shared card/global flag, so toggling one checklist does
// not affect the others; and
// 2. hide a checklist-item exactly when that item is checked AND the
// owning checklist's toggle is on (correct, non-inverted direction).
//
// These helpers are framework-free so they can be unit tested in isolation;
// the Checklists helpers hideCheckedState() and isItemHidden() in
// models/checklists.js call them, so the rule tested is the rule rendered.
// Read the per-checklist "hide checked items" state from the given checklist
// document. Returns a strict boolean; a missing/undefined field means "off".
// `checklist` is expected to be that specific checklist's document, so the
// state is always scoped to the checklist passed in.
export function checklistHideState(checklist) {
return !!(checklist && checklist.hideCheckedChecklistItems === true);
}
// Decide whether a single checklist-item should be hidden.
// An item is hidden only when it is checked (`isChecked`) AND its owning
// checklist's toggle is on (`hideChecked`). Checked items with the toggle off,
// and unchecked items, are always visible.
export function isItemHidden({ isChecked, hideChecked } = {}) {
return !!isChecked && !!hideChecked;
}