timw:filters

v0.0.1Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Some reusable filters

Write your FilterGroups schema like this:

FilterGroups = new Mongo.Collection('filterGroups');

FilterGroups.attachBehaviour('timestampable');

var schema = {
    name: {
        type: String
    },
    filters: {
        type: [Object],
        optional: true
    },
    'filters.$.value': {
        type: String,
        optional: true
    }
};

Meteor.startup(function () {
    _.each(Languages.find().fetch(), function (language) {
        var obj = {};

        obj['filters.$.label_' + language.languageCode] =  {
                type: String,
                label: 'label_' + language.languageCode,
                optional: true
        };

        _.extend(schema, obj);
    });

    FilterGroups.attachSchema(new SimpleSchema(
        schema
    ));
});

Then, use the filter component.

{{> dropdownFilter _id=doc._id}}

Attach the _id from a document of the FilterGroups collection.