mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 02:52:33 -05:00
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,
23 lines
999 B
JavaScript
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 };
|