Vulcan/packages/nova-categories/lib/collection.js

98 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-05-11 12:15:10 +09:00
Categories = new Mongo.Collection("categories");
// category schema
2015-05-11 12:15:10 +09:00
Categories.schema = new SimpleSchema({
name: {
type: String,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true
},
description: {
type: String,
optional: true,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true,
autoform: {
rows: 3
}
},
order: {
type: Number,
optional: true,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true
},
slug: {
type: String,
optional: true,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true
},
image: {
type: String,
optional: true,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true
2015-08-05 18:49:11 +09:00
},
parentId: {
type: String,
optional: true,
insertableIf: Users.is.admin,
editableIf: Users.is.admin,
publish: true,
2015-08-05 18:49:11 +09:00
autoform: {
options: function () {
var categories = Categories.find().map(function (category) {
return {
value: category._id,
label: category.name
};
});
return categories;
}
}
}
});
2016-02-17 11:28:00 +09:00
// Meteor.startup(function(){
// Categories.internationalize();
// });
2015-05-11 12:15:10 +09:00
Categories.attachSchema(Categories.schema);
2016-02-17 11:28:00 +09:00
Telescope.settings.collection.addField([
{
fieldName: 'categoriesBehavior',
fieldSchema: {
type: String,
optional: true,
autoform: {
group: 'categories',
instructions: 'Let users filter by one or multiple categories at a time.',
options: function () {
return [
{value: "single", label: __("categories_behavior_one_at_a_time")},
{value: "multiple", label: __("categories_behavior_multiple")}
];
}
}
}
},
{
fieldName: 'hideEmptyCategories',
fieldSchema: {
type: Boolean,
optional: true,
autoform: {
group: 'categories',
instructions: 'Hide empty categories in navigation'
}
}
}
]);