2016-11-26 11:17:01 +09:00
|
|
|
/*
|
|
|
|
|
|
|
|
A SimpleSchema-compatible JSON schema
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-11-18 16:01:27 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-11-21 19:23:43 +09:00
|
|
|
import mutations from './mutations.js';
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
const alwaysPublic = user => true;
|
|
|
|
const isLoggedIn = user => !!user;
|
2016-11-21 19:23:43 +09:00
|
|
|
const canEdit = mutations.edit.check;
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
// define schema
|
2016-11-22 16:15:00 +09:00
|
|
|
const schema = {
|
2016-11-18 16:01:27 +09:00
|
|
|
_id: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
2016-11-21 19:23:43 +09:00
|
|
|
viewableIf: alwaysPublic,
|
2016-11-18 16:01:27 +09:00
|
|
|
},
|
|
|
|
name: {
|
2016-11-21 19:23:43 +09:00
|
|
|
label: 'Name',
|
2016-11-18 16:01:27 +09:00
|
|
|
type: String,
|
|
|
|
control: "text",
|
|
|
|
viewableIf: alwaysPublic,
|
|
|
|
insertableIf: isLoggedIn,
|
|
|
|
editableIf: canEdit
|
|
|
|
},
|
|
|
|
createdAt: {
|
|
|
|
type: Date,
|
|
|
|
viewableIf: alwaysPublic,
|
|
|
|
autoValue: (documentOrModifier) => {
|
|
|
|
if (documentOrModifier && !documentOrModifier.$set) return new Date() // if this is an insert, set createdAt to current timestamp
|
|
|
|
}
|
|
|
|
},
|
|
|
|
year: {
|
2016-11-21 19:23:43 +09:00
|
|
|
label: 'Year',
|
2016-11-18 16:01:27 +09:00
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
control: "text",
|
|
|
|
viewableIf: alwaysPublic,
|
|
|
|
insertableIf: isLoggedIn,
|
|
|
|
editableIf: canEdit
|
|
|
|
},
|
|
|
|
review: {
|
2016-11-21 19:23:43 +09:00
|
|
|
label: 'Review',
|
2016-11-18 16:01:27 +09:00
|
|
|
type: String,
|
|
|
|
control: "textarea",
|
|
|
|
viewableIf: alwaysPublic,
|
|
|
|
insertableIf: isLoggedIn,
|
|
|
|
editableIf: canEdit
|
|
|
|
},
|
|
|
|
privateComments: {
|
2016-11-21 19:23:43 +09:00
|
|
|
label: 'Private Comments',
|
2016-11-18 16:01:27 +09:00
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
control: "textarea",
|
|
|
|
viewableIf: alwaysPublic, //fixme
|
|
|
|
insertableIf: isLoggedIn,
|
|
|
|
editableIf: canEdit
|
|
|
|
},
|
|
|
|
userId: {
|
|
|
|
type: String,
|
2016-11-22 16:15:00 +09:00
|
|
|
optional: true,
|
2016-11-18 16:01:27 +09:00
|
|
|
viewableIf: alwaysPublic,
|
2016-11-18 09:28:32 +01:00
|
|
|
insertableIf: isLoggedIn,
|
2016-11-18 10:03:01 +01:00
|
|
|
hidden: true,
|
2016-11-18 09:28:32 +01:00
|
|
|
resolveAs: 'user: User',
|
2016-11-18 16:01:27 +09:00
|
|
|
}
|
2016-11-22 16:15:00 +09:00
|
|
|
};
|
2016-11-18 16:01:27 +09:00
|
|
|
|
2016-11-24 15:47:51 +09:00
|
|
|
export default schema;
|
|
|
|
|
|
|
|
|
|
|
|
const termsSchema = `
|
|
|
|
input Terms {
|
|
|
|
view: String
|
|
|
|
userId: String
|
|
|
|
cat: String
|
|
|
|
date: String
|
|
|
|
after: String
|
|
|
|
before: String
|
|
|
|
enableCache: Boolean
|
|
|
|
listId: String
|
|
|
|
query: String # search query
|
|
|
|
postId: String
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
Telescope.graphQL.addSchema(termsSchema);
|