Adding instructions to settings form

This commit is contained in:
Sacha Greif 2014-09-29 10:15:21 +09:00
parent 2a0c545757
commit f00ffd8498
9 changed files with 163 additions and 120 deletions

View file

@ -3,7 +3,7 @@
{{#if this.hasSettings}} {{#if this.hasSettings}}
{{> quickForm collection="Settings" id="updateSettingsForm" type="update" doc=this.settings label-class="control-label" input-col-class="controls" template="test"}} {{> quickForm collection="Settings" id="updateSettingsForm" type="update" doc=this.settings label-class="control-label" input-col-class="controls" template="test"}}
{{else}} {{else}}
{{> quickForm collection="Settings" id="updateSettingsForm" type="insert" template="bootstrap3-horizontal" label-class="control-label" input-col-class="controls"}} {{> quickForm collection="Settings" id="updateSettingsForm" type="insert" template="test" label-class="control-label" input-col-class="controls"}}
{{/if}} {{/if}}
</div> </div>
</template> </template>

View file

@ -4,7 +4,7 @@
{{#each afFieldsets}} {{#each afFieldsets}}
<fieldset> <fieldset>
<h3 class="fieldset-heading">{{this}}</h3> <h3 class="fieldset-heading">{{this}}</h3>
{{> afQuickFields fields=fieldsForFieldset omitFields=../atts.omitFields template="bootstrap3-horizontal" input-col-class=inputClass label-class=labelClass}} {{> afQuickFields fields=fieldsForFieldset omitFields=../atts.omitFields template="test" input-col-class=inputClass label-class=labelClass}}
</fieldset> </fieldset>
{{/each}} {{/each}}
@ -14,9 +14,9 @@
<div class="{{inputClass}}"> <div class="{{inputClass}}">
<button {{submitButtonAtts}}> <button {{submitButtonAtts}}>
{{#with ../atts.buttonContent}} {{#with ../atts.buttonContent}}
{{this}} {{this}}
{{else}} {{else}}
Submit Submit
{{/with}} {{/with}}
</button> </button>
</div> </div>
@ -36,6 +36,9 @@
{{/if}} {{/if}}
<div class="{{rightColumnClass}}"> <div class="{{rightColumnClass}}">
{{> afFieldInput afFieldInputAtts}} {{> afFieldInput afFieldInputAtts}}
{{#if afFieldInstructions}}
<span class="instructions-block">{{afFieldInstructions}}</span>
{{/if}}
<span class="help-block">{{{afFieldMessage name=this.atts.name}}}</span> <span class="help-block">{{{afFieldMessage name=this.atts.name}}}</span>
</div> </div>
</div> </div>

View file

@ -17,7 +17,7 @@ Template[getTemplate('quickForm_test')].helpers({
}, },
fieldsForFieldset: function () { fieldsForFieldset: function () {
var fieldset = this.toLowerCase(); var fieldset = this.toLowerCase();
var schema = Template.parentData(1)._af.ss._schema; var schema = AutoForm.find().ss._schema;
// decorate schema with key names // decorate schema with key names
schema = _.map(schema, function (field, key) { schema = _.map(schema, function (field, key) {
@ -101,6 +101,10 @@ Template["afFormGroup_test"].rightColumnClass = function () {
return atts['input-col-class'] || ""; return atts['input-col-class'] || "";
}; };
Template["afFormGroup_test"].afFieldInstructions = function () {
return this.afFieldInputAtts.instructions;
};
Template["afObjectField_test"].rightColumnClass = function () { Template["afObjectField_test"].rightColumnClass = function () {
var atts = this.atts || {}; var atts = this.atts || {};
return atts['input-col-class'] || ""; return atts['input-col-class'] || "";

View file

@ -1,73 +1,73 @@
CommentSchema = new SimpleSchema({ CommentSchema = new SimpleSchema({
_id: { _id: {
type: String, type: String,
optional: true optional: true
}, },
parentCommentId: { parentCommentId: {
type: String, type: String,
optional: true optional: true
}, },
createdAt: { createdAt: {
type: Date, type: Date,
optional: true optional: true
}, },
postedAt: { // for now, comments are always created and posted at the same time postedAt: { // for now, comments are always created and posted at the same time
type: Date, type: Date,
optional: true optional: true
}, },
body: { body: {
type: String type: String
}, },
htmlBody: { htmlBody: {
type: String, type: String,
optional: true optional: true
}, },
baseScore: { baseScore: {
type: Number, type: Number,
decimal: true, decimal: true,
optional: true optional: true
}, },
score: { score: {
type: Number, type: Number,
decimal: true, decimal: true,
optional: true optional: true
}, },
upvotes: { upvotes: {
type: Number, type: Number,
optional: true optional: true
}, },
upvoters: { upvoters: {
type: [String], // XXX type: [String], // XXX
optional: true optional: true
}, },
downvotes: { downvotes: {
type: Number, type: Number,
optional: true optional: true
}, },
downvoters: { downvoters: {
type: [String], // XXX type: [String], // XXX
optional: true optional: true
}, },
author: { author: {
type: String, type: String,
optional: true optional: true
}, },
inactive: { inactive: {
type: Boolean, type: Boolean,
optional: true optional: true
}, },
postId: { postId: {
type: String, // XXX type: String, // XXX
optional: true optional: true
}, },
userId: { userId: {
type: String, // XXX type: String, // XXX
optional: true optional: true
}, },
isDeleted: { isDeleted: {
type: Boolean, type: Boolean,
optional: true optional: true
} }
}); });
Comments = new Meteor.Collection("comments"); Comments = new Meteor.Collection("comments");

View file

@ -10,9 +10,10 @@ settingsSchemaObject = {
siteUrl: { siteUrl: {
type: String, type: String,
optional: true, optional: true,
label: 'Site URL (with trailing "/")', label: 'Site URL',
autoform: { autoform: {
group: 'general' group: 'general',
instructions: 'Your site\'s URL (with trailing "/"). Will default to Meteor.absoluteUrl()'
} }
}, },
tagline: { tagline: {
@ -28,7 +29,7 @@ settingsSchemaObject = {
label: "Require invite to view", label: "Require invite to view",
optional: true, optional: true,
autoform: { autoform: {
group: 'access' group: 'invites'
} }
}, },
requirePostInvite: { requirePostInvite: {
@ -36,7 +37,7 @@ settingsSchemaObject = {
label: "Require invite to post", label: "Require invite to post",
optional: true, optional: true,
autoform: { autoform: {
group: 'access' group: 'invites'
} }
}, },
requirePostsApproval: { requirePostsApproval: {
@ -47,42 +48,37 @@ settingsSchemaObject = {
group: 'access' group: 'access'
} }
}, },
emailNotifications: { // nestedComments: {
type: Boolean, // type: Boolean,
label: "Enable email notifications", // label: "Enable nested comments",
optional: true, // optional: true,
autoform: { // autoform: {
group: 'email' // group: 'comments'
} // }
}, // },
nestedComments: { // redistributeKarma: {
type: Boolean, // type: Boolean,
label: "Enable nested comments", // label: "Enable redistributed karma",
optional: true, // optional: true,
autoform: { // autoform: {
group: 'comments' // group: 'general'
} // }
}, // },
redistributeKarma: {
type: Boolean,
label: "Enable redistributed karma",
optional: true,
autoform: {
group: 'general'
}
},
defaultEmail: { defaultEmail: {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'email' group: 'email',
instructions: 'The address all outgoing emails will be sent from.'
} }
}, },
scoreUpdateInterval: { scoreUpdateInterval: {
type: Number, type: Number,
optional: true, optional: true,
defaultValue: 30,
autoform: { autoform: {
group: 'scoring' group: 'scoring',
instructions: 'How often to recalculate scores, in seconds (default to 30)'
} }
}, },
defaultView: { defaultView: {
@ -101,22 +97,28 @@ settingsSchemaObject = {
postInterval: { postInterval: {
type: Number, type: Number,
optional: true, optional: true,
defaultValue: 30,
autoform: { autoform: {
group: 'posts' group: 'posts',
instructions: 'Minimum time between posts, in seconds (defaults to 30)'
} }
}, },
commentInterval: { commentInterval: {
type: Number, type: Number,
optional: true, optional: true,
defaultValue: 15,
autoform: { autoform: {
group: 'comments' group: 'comments',
instructions: 'Minimum time between comments, in seconds (defaults to 15)'
} }
}, },
maxPostsPerDay: { maxPostsPerDay: {
type: Number, type: Number,
optional: true, optional: true,
defaultValue: 30,
autoform: { autoform: {
group: 'posts' group: 'posts',
instructions: 'Maximum number of posts a user can post in a day (default to 30).'
} }
}, },
startInvitesCount: { startInvitesCount: {
@ -124,7 +126,7 @@ settingsSchemaObject = {
defaultValue: 3, defaultValue: 3,
optional: true, optional: true,
autoform: { autoform: {
group: 'general' group: 'invites'
} }
}, },
postsPerPage: { postsPerPage: {
@ -161,15 +163,16 @@ settingsSchemaObject = {
defaultValue: 'en', defaultValue: 'en',
optional: true, optional: true,
autoform: { autoform: {
group: 'general' group: 'internationalization'
} }
}, },
backgroundCSS: { backgroundCSS: {
type: String, type: String,
optional: true, optional: true,
label: "Background CSS: color, image, etc.", label: "Background CSS",
autoform: { autoform: {
group: 'extras' group: 'extras',
instructions: 'CSS code for the &lt;body&gt;\'s "background" property'
} }
}, },
// secondaryColor: { // secondaryColor: {
@ -236,28 +239,32 @@ settingsSchemaObject = {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'extras' group: 'extras',
instructions: 'Footer content (accepts HTML).'
} }
}, },
extraCode: { extraCode: {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'extras' group: 'extras',
instructions: 'Any extra HTML code you want to include on every page.'
} }
}, },
emailFooter: { emailFooter: {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'email' group: 'email',
instructions: 'Content that will appear at the bottom of outgoing emails (accepts HTML).'
} }
}, },
notes: { notes: {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'extras' group: 'extras',
instructions: 'You can store any notes or extra information here.'
} }
}, },
}; };

View file

@ -50,7 +50,8 @@ var showBanner = {
optional: true, optional: true,
label: 'Show newsletter sign-up banner', label: 'Show newsletter sign-up banner',
autoform: { autoform: {
group: 'newsletter' group: 'newsletter',
instructions: 'Show newsletter sign-up form on the front page.'
} }
} }
} }
@ -74,7 +75,8 @@ var mailChimpListId = {
type: String, type: String,
optional: true, optional: true,
autoform: { autoform: {
group: 'newsletter' group: 'newsletter',
instructions: 'The ID of the list you want to send to.'
} }
} }
} }

View file

@ -101,7 +101,7 @@ Meteor.methods({
// add new post notification callback on post submit // add new post notification callback on post submit
postAfterSubmitMethodCallbacks.push(function (post) { postAfterSubmitMethodCallbacks.push(function (post) {
if(Meteor.isServer && !!getSetting('emailNotifications', false)){ if(Meteor.isServer && !!getSetting('emailNotifications', true)){
// we don't want emails to hold up the post submission, so we make the whole thing async with setTimeout // we don't want emails to hold up the post submission, so we make the whole thing async with setTimeout
Meteor.setTimeout(function () { Meteor.setTimeout(function () {
newPostNotification(post, [post.userId]) newPostNotification(post, [post.userId])
@ -112,7 +112,7 @@ postAfterSubmitMethodCallbacks.push(function (post) {
// add new comment notification callback on comment submit // add new comment notification callback on comment submit
commentAfterSubmitMethodCallbacks.push(function (comment) { commentAfterSubmitMethodCallbacks.push(function (comment) {
if(Meteor.isServer){ if(Meteor.isServer && !!getSetting('emailNotifications', true)){
var parentCommentId = comment.parentCommentId; var parentCommentId = comment.parentCommentId;
var user = Meteor.user(); var user = Meteor.user();
@ -150,4 +150,18 @@ commentAfterSubmitMethodCallbacks.push(function (comment) {
} }
return comment; return comment;
}); });
var emailNotifications = {
propertyName: 'emailNotifications',
propertySchema: {
type: Boolean,
optional: true,
defaultValue: true,
autoform: {
group: 'notifications',
instructions: 'Enable email notifications for new posts and new comments.'
}
}
}
addToSettingsSchema.push(emailNotifications);

View file

@ -322,6 +322,13 @@ input[type="search"] {
fieldset { fieldset {
margin-bottom: 30px; } margin-bottom: 30px; }
/* line 181, ../scss/global/_forms.scss */
.instructions-block {
margin-top: 5px;
display: block;
font-size: 80%;
color: rgba(0, 0, 0, 0.6); }
/* line 1, ../scss/global/_links.scss */ /* line 1, ../scss/global/_links.scss */
a { a {
text-decoration: none; } text-decoration: none; }

View file

@ -177,4 +177,10 @@ input[type="search"]{
} }
fieldset{ fieldset{
margin-bottom: 30px; margin-bottom: 30px;
}
.instructions-block{
margin-top: 5px;
display: block;
font-size: 80%;
color: black(0.6);
} }