apostrophe-forms
Advanced tools
Comparing version 0.5.21 to 0.5.22
19
index.js
@@ -116,2 +116,8 @@ /* jshint node:true */ | ||
// This takes an array of objects that have a label and a name value. | ||
// i.e. [ label: 'IP Address', name: 'ipAddress' ] | ||
// They'll be added to the exported CSV. This allows you to display fields | ||
// that might not be in the form itself. | ||
self.addExportColumns = options.addExportColumns || []; | ||
snippets.Snippets.call(this, options, null); | ||
@@ -484,3 +490,10 @@ self._apos.mixinModuleEmail(self); | ||
return self.submissions.insert(result, callback); | ||
// Adding an asynchronous hook here to make changes to a form submission | ||
// before it is stored - Jimmy | ||
self.beforeStore(req, result, function(err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return self.submissions.insert(result, callback); | ||
}); | ||
}, | ||
@@ -524,2 +537,6 @@ email: function(callback) { | ||
self.beforeStore = function(req, result, callback) { | ||
return setImmediate(callback); | ||
}; | ||
// A convenient method to override to do something special when a | ||
@@ -526,0 +543,0 @@ // form has been submitted |
@@ -25,3 +25,3 @@ /* | ||
var formsCollection = self._apos.db.collection('aposFormSubmissions'); | ||
// ================================================================ | ||
@@ -95,4 +95,4 @@ // CRITERIA & FORM | ||
var formItems = _.get(form[0], "body.items"); | ||
var labels = _.pluck(formItems, "label"); | ||
var labelIds = _.pluck(formItems, "fieldId"); | ||
var labels = _.pluck(formItems, "label").concat(_.pluck(self.addExportColumns, 'label')); | ||
var labelIds = _.pluck(formItems, "fieldId").concat(_.pluck(self.addExportColumns, 'name')); | ||
@@ -127,3 +127,3 @@ // make your first call to stringifier.write([]) in order to write | ||
// length (i.e. if a field has no value, you still need to write '') | ||
// grab some submissions | ||
@@ -130,0 +130,0 @@ function convertAndStream(callback) { |
{ | ||
"name": "apostrophe-forms", | ||
"version": "0.5.21", | ||
"version": "0.5.22", | ||
"description": "Allow your users to build forms on the fly on their Apostrophe sites", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
71304
1079
1