Files
wekan/models/lib/tableViewFilter.js
Lauri Ojansivu c273b12e23 Resolve authorized linked dates for lazy Table pages
Use one-hop source dates for ordering and badges, observe source data and permissions, and recheck them after each scan. Handle partial linked-board member metadata without breaking row rendering.

Cover source edits, access revocation/restoration, assigned-only readers, source moves, all four date fields and ordinary lazy pagination.

Thanks to ghost, neooleg, Creanimo, GusevVictor, avatar1024 and xet7 !

Fixes #935,
2026-09-28 19:19:26 +03:00

23 lines
999 B
JavaScript

'use strict';
// Pure selector builder for the per-board Table view. The active Filter owns a
// top-level $or, so always combine it with the board boundary through $and.
function tableViewCardsSelector(boardId, filterSelector) {
const base = { boardId, archived: false };
if (!filterSelector || Object.keys(filterSelector).length === 0) return base;
return { $and: [filterSelector, base] };
}
// Preserve card identity/mutators, but use the page's authorized dates for
// badges as well as ordering. Never write source dates onto a local link card.
function tableCardWithDates(card, dates) {
if (!dates) return card;
const view = Object.assign(Object.create(Object.getPrototypeOf(card)), card);
for (const [getter, field] of [['getReceived', 'receivedAt'], ['getStart', 'startAt'], ['getDue', 'dueAt'], ['getEnd', 'endAt']]) {
Object.defineProperty(view, getter, { value: () => dates[field] ?? null });
}
return view;
}
export { tableViewCardsSelector, tableCardWithDates };