2016-06-03 11:03:36 +09:00
|
|
|
import NewsletterSubscribe from './components/NewsletterSubscribe.jsx';
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from 'meteor/nova:users';
|
2016-06-03 11:03:36 +09:00
|
|
|
|
2016-07-21 09:40:05 +09:00
|
|
|
// check if user can create a new account
|
|
|
|
const canInsert = user => Users.canDo(user, "users.new");
|
|
|
|
// check if user can edit a user
|
|
|
|
const canEdit = Users.canEdit;
|
|
|
|
|
2016-02-17 20:44:52 +09:00
|
|
|
Posts.addField({
|
|
|
|
fieldName: 'scheduledAt',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Date,
|
2016-04-05 16:27:48 +09:00
|
|
|
optional: true
|
2016-02-17 20:44:52 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Users.addField([
|
|
|
|
{
|
2016-02-25 17:44:43 +09:00
|
|
|
fieldName: 'telescope.newsletter_subscribeToNewsletter',
|
2016-02-17 20:44:52 +09:00
|
|
|
fieldSchema: {
|
|
|
|
label: 'Subscribe to newsletter',
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
2016-05-22 14:29:04 +02:00
|
|
|
publish: true,
|
2016-07-21 09:40:05 +09:00
|
|
|
insertableIf: canInsert,
|
|
|
|
editableIf: canEdit,
|
2016-06-03 11:03:36 +09:00
|
|
|
control: NewsletterSubscribe,
|
|
|
|
group: {
|
|
|
|
name: "newsletter",
|
|
|
|
label: "Newsletter",
|
|
|
|
order: 3
|
|
|
|
}
|
2016-05-22 14:29:04 +02:00
|
|
|
}
|
|
|
|
},
|
2016-02-17 20:44:52 +09:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
|
2016-04-04 14:39:08 +09:00
|
|
|
if (typeof Telescope.settings.collection !== "undefined") {
|
|
|
|
Telescope.settings.collection.addField([
|
2016-02-17 20:44:52 +09:00
|
|
|
{
|
|
|
|
fieldName: 'enableNewsletter',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
|
|
|
instructions: 'Enable newsletter (requires restart).'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-06-28 17:33:30 +09:00
|
|
|
{
|
|
|
|
fieldName: 'enableNewsletterInDev',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
|
|
|
instructions: 'Enable newsletter in development too (requires restart).'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2016-02-17 20:44:52 +09:00
|
|
|
{
|
|
|
|
fieldName: "mailChimpAPIKey",
|
|
|
|
fieldSchema: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
private: true,
|
|
|
|
autoform: {
|
|
|
|
group: "newsletter",
|
|
|
|
class: "private-field"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'mailChimpListId',
|
|
|
|
fieldSchema: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
private: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
|
|
|
instructions: 'The ID of the list you want to send to.',
|
|
|
|
class: "private-field"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'postsPerNewsletter',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Number,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'newsletterFrequency',
|
|
|
|
fieldSchema: {
|
|
|
|
type: [Number],
|
|
|
|
optional: true,
|
2016-04-04 14:39:08 +09:00
|
|
|
defaultValue: [2,4,6],
|
2016-02-17 20:44:52 +09:00
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
|
|
|
instructions: 'Defaults to once a week on Monday. Changes require restarting your app to take effect.',
|
|
|
|
noselect: true,
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
value: 1,
|
|
|
|
label: 'Sunday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 2,
|
|
|
|
label: 'Monday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 3,
|
|
|
|
label: 'Tuesday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 4,
|
|
|
|
label: 'Wednesday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 5,
|
|
|
|
label: 'Thursday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 6,
|
|
|
|
label: 'Friday'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 7,
|
|
|
|
label: 'Saturday'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'newsletterTime',
|
|
|
|
fieldSchema: {
|
|
|
|
type: String,
|
|
|
|
optional: true,
|
|
|
|
defaultValue: '00:00',
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
2016-06-28 17:33:30 +09:00
|
|
|
instructions: 'Defaults to 00:00/12:00 AM. Time to send out newsletter if enabled (GMT).',
|
2016-02-17 20:44:52 +09:00
|
|
|
type: 'time'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldName: 'autoSubscribe',
|
|
|
|
fieldSchema: {
|
|
|
|
type: Boolean,
|
|
|
|
optional: true,
|
|
|
|
autoform: {
|
|
|
|
group: 'newsletter',
|
|
|
|
instructions: 'Automatically subscribe new users on sign-up.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2016-05-22 14:29:04 +02:00
|
|
|
}
|