Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the addFields breakage at project level, fix the docs for where t… #10

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.4, 2020-07-01

- Documentation was incorrect re: where to put `credentials.json`. Because this module uses `improve`, it should go in the project level `lib/modules/apostrophe-forms/credentials.json` file, not `lib/modules/apostrophe-forms-submit-google/credentials.json`.
- Previously this module broke project level use of `addFields` for `apostrophe-forms`. This has been fixed.

## 1.0.3, 2020-06-17

- Works properly when no sheet name is specified.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This module adds an additional form submission option to Apostrophe Forms. It al

1. Create a project in [the Google Cloud Platform API console](https://console.developers.google.com/apis/dashboard). Enable the Google Sheets API on the project in the API Library.
2. Create an [API service account](https://cloud.google.com/iam/docs/service-accounts) in the Google API Console service.
3. Save the credentials JSON file provided with the new service account. *You may not be able to download this again.* Add this file to the `lib/modules/apostrophe-forms-submit-google` directory in your Apostrophe project as `credentials.json`.
3. Save the credentials JSON file provided with the new service account. *You may not be able to download this again.* Add this file to the `lib/modules/apostrophe-forms` directory in your Apostrophe project as `credentials.json`.
1. Note: We do not recommend committing this file to version control if your code is public, in which case you should so add it to the `.gitignore file` (for Git) and put it directly on your production server. *Alternately* you can provide the file as JSON in an environment variable named `GOOGLE_APPLICATION_CREDENTIALS`.
4. Copy the service account email address. You will need to add this as an "Edit"-level user on your Google spreadsheet as you would a human editor.
5. Plan for the service account credentials to expire in 10 years. The service account credentials have a long life span, but it is not infinite.
Expand Down
54 changes: 27 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ const has = require('lodash.has');

module.exports = {
improve: 'apostrophe-forms',
addFields: [
{
name: 'googleSheetSubmissions',
label: 'Submit to Google Spreadsheets',
type: 'boolean',
choices: [
{
label: 'Yes',
value: true,
showFields: [ 'googleSpreadsheetId', 'googleSheetName' ]
}
]
},
{
name: 'googleSpreadsheetId',
label: 'Google Spreadsheet ID',
type: 'string',
required: true,
htmlHelp: '<a href="https://developers.google.com/sheets/api/guides/concepts#spreadsheet_id">The ID is found in the spreadsheet URL</a>: https://docs.google.com/spreadsheets/d/<strong>spreadsheetId</strong>/edit#gid=0'
},
{
name: 'googleSheetName',
label: 'Google Spreadsheet Sheet Name',
type: 'string',
help: 'The name of the sheet tab in your Google spreadsheet where you want the submission appended. If not provided, the first sheet of the spreadsheet will be used.'
}
],
construct: function (self, options) {
options.addFields = [
{
name: 'googleSheetSubmissions',
label: 'Submit to Google Spreadsheets',
type: 'boolean',
choices: [
{
label: 'Yes',
value: true,
showFields: [ 'googleSpreadsheetId', 'googleSheetName' ]
}
]
},
{
name: 'googleSpreadsheetId',
label: 'Google Spreadsheet ID',
type: 'string',
required: true,
htmlHelp: '<a href="https://developers.google.com/sheets/api/guides/concepts#spreadsheet_id">The ID is found in the spreadsheet URL</a>: https://docs.google.com/spreadsheets/d/<strong>spreadsheetId</strong>/edit#gid=0'
},
{
name: 'googleSheetName',
label: 'Google Spreadsheet Sheet Name',
type: 'string',
help: 'The name of the sheet tab in your Google spreadsheet where you want the submission appended. If not provided, the first sheet of the spreadsheet will be used.'
}
].concat(options.addFields || []);
options.arrangeFields = options.arrangeFields.map(group => {
if (group.name === 'afterSubmit') {
group.fields.push(
Expand Down