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}}
{{> quickForm collection="Settings" id="updateSettingsForm" type="update" doc=this.settings label-class="control-label" input-col-class="controls" template="test"}}
{{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}}
</div>
</template>

View file

@ -4,7 +4,7 @@
{{#each afFieldsets}}
<fieldset>
<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>
{{/each}}
@ -14,9 +14,9 @@
<div class="{{inputClass}}">
<button {{submitButtonAtts}}>
{{#with ../atts.buttonContent}}
{{this}}
{{this}}
{{else}}
Submit
Submit
{{/with}}
</button>
</div>
@ -36,6 +36,9 @@
{{/if}}
<div class="{{rightColumnClass}}">
{{> afFieldInput afFieldInputAtts}}
{{#if afFieldInstructions}}
<span class="instructions-block">{{afFieldInstructions}}</span>
{{/if}}
<span class="help-block">{{{afFieldMessage name=this.atts.name}}}</span>
</div>
</div>

View file

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

View file

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

View file

@ -10,9 +10,10 @@ settingsSchemaObject = {
siteUrl: {
type: String,
optional: true,
label: 'Site URL (with trailing "/")',
label: 'Site URL',
autoform: {
group: 'general'
group: 'general',
instructions: 'Your site\'s URL (with trailing "/"). Will default to Meteor.absoluteUrl()'
}
},
tagline: {
@ -28,7 +29,7 @@ settingsSchemaObject = {
label: "Require invite to view",
optional: true,
autoform: {
group: 'access'
group: 'invites'
}
},
requirePostInvite: {
@ -36,7 +37,7 @@ settingsSchemaObject = {
label: "Require invite to post",
optional: true,
autoform: {
group: 'access'
group: 'invites'
}
},
requirePostsApproval: {
@ -47,42 +48,37 @@ settingsSchemaObject = {
group: 'access'
}
},
emailNotifications: {
type: Boolean,
label: "Enable email notifications",
optional: true,
autoform: {
group: 'email'
}
},
nestedComments: {
type: Boolean,
label: "Enable nested comments",
optional: true,
autoform: {
group: 'comments'
}
},
redistributeKarma: {
type: Boolean,
label: "Enable redistributed karma",
optional: true,
autoform: {
group: 'general'
}
},
// nestedComments: {
// type: Boolean,
// label: "Enable nested comments",
// optional: true,
// autoform: {
// group: 'comments'
// }
// },
// redistributeKarma: {
// type: Boolean,
// label: "Enable redistributed karma",
// optional: true,
// autoform: {
// group: 'general'
// }
// },
defaultEmail: {
type: String,
optional: true,
autoform: {
group: 'email'
group: 'email',
instructions: 'The address all outgoing emails will be sent from.'
}
},
scoreUpdateInterval: {
type: Number,
optional: true,
defaultValue: 30,
autoform: {
group: 'scoring'
group: 'scoring',
instructions: 'How often to recalculate scores, in seconds (default to 30)'
}
},
defaultView: {
@ -101,22 +97,28 @@ settingsSchemaObject = {
postInterval: {
type: Number,
optional: true,
defaultValue: 30,
autoform: {
group: 'posts'
group: 'posts',
instructions: 'Minimum time between posts, in seconds (defaults to 30)'
}
},
commentInterval: {
type: Number,
optional: true,
defaultValue: 15,
autoform: {
group: 'comments'
group: 'comments',
instructions: 'Minimum time between comments, in seconds (defaults to 15)'
}
},
maxPostsPerDay: {
type: Number,
optional: true,
defaultValue: 30,
autoform: {
group: 'posts'
group: 'posts',
instructions: 'Maximum number of posts a user can post in a day (default to 30).'
}
},
startInvitesCount: {
@ -124,7 +126,7 @@ settingsSchemaObject = {
defaultValue: 3,
optional: true,
autoform: {
group: 'general'
group: 'invites'
}
},
postsPerPage: {
@ -161,15 +163,16 @@ settingsSchemaObject = {
defaultValue: 'en',
optional: true,
autoform: {
group: 'general'
group: 'internationalization'
}
},
backgroundCSS: {
type: String,
optional: true,
label: "Background CSS: color, image, etc.",
label: "Background CSS",
autoform: {
group: 'extras'
group: 'extras',
instructions: 'CSS code for the &lt;body&gt;\'s "background" property'
}
},
// secondaryColor: {
@ -236,28 +239,32 @@ settingsSchemaObject = {
type: String,
optional: true,
autoform: {
group: 'extras'
group: 'extras',
instructions: 'Footer content (accepts HTML).'
}
},
extraCode: {
type: String,
optional: true,
autoform: {
group: 'extras'
group: 'extras',
instructions: 'Any extra HTML code you want to include on every page.'
}
},
emailFooter: {
type: String,
optional: true,
autoform: {
group: 'email'
group: 'email',
instructions: 'Content that will appear at the bottom of outgoing emails (accepts HTML).'
}
},
notes: {
type: String,
optional: true,
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,
label: 'Show newsletter sign-up banner',
autoform: {
group: 'newsletter'
group: 'newsletter',
instructions: 'Show newsletter sign-up form on the front page.'
}
}
}
@ -74,7 +75,8 @@ var mailChimpListId = {
type: String,
optional: true,
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
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
Meteor.setTimeout(function () {
newPostNotification(post, [post.userId])
@ -112,7 +112,7 @@ postAfterSubmitMethodCallbacks.push(function (post) {
// add new comment notification callback on comment submit
commentAfterSubmitMethodCallbacks.push(function (comment) {
if(Meteor.isServer){
if(Meteor.isServer && !!getSetting('emailNotifications', true)){
var parentCommentId = comment.parentCommentId;
var user = Meteor.user();
@ -151,3 +151,17 @@ commentAfterSubmitMethodCallbacks.push(function (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 {
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 */
a {
text-decoration: none; }

View file

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