2015-05-11 12:15:10 +09:00
|
|
|
Categories = new Mongo.Collection("categories");
|
|
|
|
|
2015-04-22 07:50:11 +09:00
|
|
|
// category schema
|
2015-05-11 12:15:10 +09:00
|
|
|
Categories.schema = new SimpleSchema({
|
2015-04-22 07:50:11 +09:00
|
|
|
name: {
|
2015-04-27 17:15:16 +09:00
|
|
|
type: String,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.admin,
|
|
|
|
editableIf: Users.is.admin,
|
|
|
|
publish: true
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.admin,
|
|
|
|
editableIf: Users.is.admin,
|
|
|
|
publish: true,
|
2015-04-22 07:50:11 +09:00
|
|
|
autoform: {
|
|
|
|
rows: 3
|
|
|
|
}
|
|
|
|
},
|
|
|
|
order: {
|
|
|
|
type: Number,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.admin,
|
|
|
|
editableIf: Users.is.admin,
|
|
|
|
publish: true
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
slug: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.admin,
|
|
|
|
editableIf: Users.is.admin,
|
|
|
|
publish: true
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
image: {
|
|
|
|
type: String,
|
2015-04-27 17:15:16 +09:00
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
insertableIf: Users.is.admin,
|
|
|
|
editableIf: Users.is.admin,
|
|
|
|
publish: true
|
2015-08-05 18:49:11 +09:00
|
|
|
},
|
|
|
|
parentId: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
2016-02-28 13:12:36 +09:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2015-04-22 07:50:11 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-17 11:28:00 +09:00
|
|
|
// Meteor.startup(function(){
|
|
|
|
// Categories.internationalize();
|
|
|
|
// });
|
2015-04-27 09:55:29 +09:00
|
|
|
|
2015-05-11 12:15:10 +09:00
|
|
|
Categories.attachSchema(Categories.schema);
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-09-11 10:51:21 +09:00
|
|
|
|
2016-02-17 11:28:00 +09:00
|
|
|
Telescope.settings.collection.addField([
|
2015-09-11 10:51:21 +09:00
|
|
|
{
|
|
|
|
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 [
|
2016-02-22 13:23:46 +09:00
|
|
|
{value: "single", label: __("categories_behavior_one_at_a_time")},
|
|
|
|
{value: "multiple", label: __("categories_behavior_multiple")}
|
2015-09-11 10:51:21 +09:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-15 10:30:10 +09:00
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'hideEmptyCategories',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'categories',
|
|
|
|
instructions: 'Hide empty categories in navigation'
|
|
|
|
}
|
|
|
|
}
|
2015-09-11 10:51:21 +09:00
|
|
|
}
|
2016-02-19 18:18:30 +09:00
|
|
|
]);
|