Vulcan/packages/nova-categories/lib/custom_fields.js
Xavier Cazalot 7f99b48953 devel - revert commits related to simpl-schema (#1537)
* Revert "add note link to issue in collection2 on mutation insert, remove debug console logs on mutation edit"

This reverts commit 7a15103de7.

* Revert "node simpl-schema + collection2-core: fix vote by specifying the right type of the array (dont use blackbox in the end!)"

This reverts commit e894c3224c.

* Revert "add graphql date type (fix problem with node simple schema), fix an update bug on date picker,  add edit check on custom post item, add `blackbox: true` for arrays field (validation problem with simple-schema)"

This reverts commit 9d84fbec98.

* Revert "use node `simpl-schema` by aldeed to replace `meteor/aldeed:simple-schema` ; use the meteor collection2 core package as recommended"

This reverts commit 016935f4fa.

* revert before node-simple-schema, fix obj.hasOwnProperty undefined error thrown by simple-schema & collection2

* CustomPostsItem: check on renderActions; withDocument/List: pollInterval 20seconds by default; DateTime form component enhancement + GraphQLDate type
2017-01-11 18:02:12 +01:00

49 lines
1.3 KiB
JavaScript

import Posts from "meteor/nova:posts";
Posts.addField(
{
fieldName: 'categories',
fieldSchema: {
type: [String],
control: "checkboxgroup",
optional: true,
insertableBy: ['members'],
editableBy: ['members'],
viewableBy: ['guests'],
form: {
noselect: true,
type: "bootstrap-category",
order: 50,
options: function (formProps) {
// catch the ApolloClient from the form props
const {client} = formProps;
// get the current data of the store
const apolloData = client.store.getState().apollo.data;
// filter these data based on their typename: we are interested in the categories data
const categories = _.filter(apolloData, (object, key) => {
return object.__typename === 'Category'
});
// give the form component (here: checkboxgroup) exploitable data
const categoriesOptions = categories.map(function (category) {
return {
value: category._id,
label: category.name
};
});
return categoriesOptions;
}
},
// publish: true,
// join: {
// joinAs: "categoriesArray",
// collection: () => Categories
// },
resolveAs: 'categories: [Category]'
}
}
);