2015-06-02 11:53:18 +09:00
|
|
|
AutoForm.hooks({
|
|
|
|
completeUserForm: {
|
|
|
|
onError: function(operation, error) {
|
|
|
|
this.template.$('button[type=submit]').removeClass('loading');
|
|
|
|
Messages.flash(error.message.split('|')[0], 'error'); // workaround because error.details returns undefined
|
|
|
|
Messages.clearSeen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-06 12:56:59 +09:00
|
|
|
Template.user_complete.helpers({
|
|
|
|
user: function () {
|
|
|
|
return Meteor.user();
|
|
|
|
},
|
|
|
|
requiredFields: function () {
|
|
|
|
// return fields that are required by the schema but haven't been filled out yet
|
|
|
|
var schema = Users.simpleSchema()._schema;
|
|
|
|
var requiredFields = _.filter(_.keys(schema), function (fieldName) {
|
|
|
|
var field = schema[fieldName];
|
|
|
|
return !!field.required && !Telescope.getNestedProperty(Meteor.user(), fieldName);
|
|
|
|
});
|
|
|
|
return requiredFields;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-06 16:41:15 +09:00
|
|
|
// TODO: handle error case when user validates form with blank fields
|