Hi guys,
can you recon an elegant&stable solution for creating custom filters for aldeed:tabular created by the famous @aldeed
I want to do about 4-6 custom filter-fields searching in different rows and basically generating a mongo-style selector which I then pass over to aldeed:tabular.
Right now I am doing it manual and feels like too much manual work:
This code sucks as it gets much more complex with more filters (right now I have 2 custom filters):
Template.exampleThirdPartiesTablesFilters.onCreated(function () {
this.theFilter = new ReactiveVar();
this.nameFilterValue = new ReactiveVar();
this.scoopFilterValue = new ReactiveVar();
this.autorun(function() {
var theFilter = {};
// build a Mongo-Style Selector
// this SUCKS!!!!
var nameFilterValue = Template.instance().nameFilterValue.get();
var scoopFilterValue = Template.instance().scoopFilterValue.get();
if (nameFilterValue && scoopFilterValue) {
theFilter = {
$and: [
{customerName: {$regex: Template.instance().nameFilterValue.get(), $options: 'i'}},
{'scoopItems.scoopId': Template.instance().scoopFilterValue.get()},
]
};
} else if (nameFilterValue && !scoopFilterValue) {
theFilter = {
customerName: {$regex: Template.instance().nameFilterValue.get(), $options: 'i'},
};
} else if (!nameFilterValue && scoopFilterValue) {
theFilter = {
'scoopItems.scoopId': Template.instance().scoopFilterValue.get()
};
}
Template.instance().theFilter.set(theFilter);
// ...
Can you guys recon a stable package to use?