The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
wekan/server/lib/checklistHide.js

28 lines
1.4 KiB

// 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
// and reused by the client template logic.
// 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;
}