mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -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 !
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { check } from 'meteor/check';
|
|
import Cards from '/models/cards';
|
|
import CardComments from '/models/cardComments';
|
|
import Checklists from '/models/checklists';
|
|
import ChecklistItems from '/models/checklistItems';
|
|
import { boardTextSearch } from '/server/lib/boardTextSearch';
|
|
import { publishBoardMatches } from '/server/lib/publishBoardMatches';
|
|
|
|
Meteor.publish('boardTextMatches', async function(boardId, term) {
|
|
check(boardId, String); check(term, String);
|
|
if (!boardId || !term.trim() || term.length > 512) return this.ready();
|
|
const sources = [
|
|
{ model: CardComments, field: 'text' },
|
|
{ model: Checklists, field: 'title' },
|
|
{ model: ChecklistItems, field: 'title' },
|
|
];
|
|
return publishBoardMatches({ publication: this, boardId, key: term, identity: { term },
|
|
collectionName: 'boardTextMatches', cardFields: { title: 1, description: 1 },
|
|
children: sources.map(({ model, field }) => ({ model, fields: { [field]: 1 } })),
|
|
findMatches: ({ scope, stopped }) => boardTextSearch({ cards: Cards.rawCollection(),
|
|
children: sources.map(({ model, field }) => ({ collection: model.rawCollection(), field })),
|
|
scope, term, stopped }),
|
|
});
|
|
});
|