mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Match any recorded list, swimlane or incoming board move within inclusive local-day bounds, regardless of later moves. Reuse the authorized reactive ID publication for text and history, preserve lazy-loading coverage and validate history joins and live UI behavior. Thanks to neooleg and xet7 !
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { Tracker } from 'meteor/tracker';
|
|
import { Session } from 'meteor/session';
|
|
import { cardDateRangeSelector } from '/models/lib/cardDateRange';
|
|
const matches = new Mongo.Collection('boardMovementMatches');
|
|
export function movementBounds(value) {
|
|
const date = cardDateRangeSelector(value)?.createdAt;
|
|
return date ? [date.$gte?.getTime() ?? null, date.$lt?.getTime() ?? null] : null;
|
|
}
|
|
export function boardMovementSelector(value) {
|
|
const rangeKey = JSON.stringify(movementBounds(value));
|
|
return { _id: { $in: matches.find({ boardId: Session.get('currentBoard'), rangeKey },
|
|
{ fields: { cardId: 1 } }).fetch().map(row => row.cardId) } };
|
|
}
|
|
export function startBoardMovementFilter(filter) {
|
|
Meteor.startup(() => Tracker.autorun(computation => {
|
|
const boardId = Session.get('currentBoard'), bounds = movementBounds(filter.value());
|
|
if (boardId && bounds) {
|
|
const handle = Meteor.subscribe('boardMovementMatches', boardId, ...bounds);
|
|
computation.onInvalidate(() => handle.stop());
|
|
}
|
|
}));
|
|
}
|