-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate place forms if place-types.json is supplied
Closes #4
- Loading branch information
Showing
44 changed files
with
7,414 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
const convertForms = require('../lib/convert-forms'); | ||
const fs = require('../lib/sync-fs'); | ||
|
||
module.exports = (projectDir, couchUrl, extras) => convertForms(projectDir, 'contact', { | ||
enketo: true, | ||
force_data_node: 'data', | ||
forms: extras, | ||
}); | ||
module.exports = (projectDir, couchUrl, extras) => { | ||
|
||
const dir = `${projectDir}/forms/contact`; | ||
const placeTypesJson = `${dir}/place-types.json`; | ||
|
||
let PLACE_TYPES; | ||
if(fs.exists(placeTypesJson)) { | ||
PLACE_TYPES = fs.readJson(placeTypesJson); | ||
Object.keys(PLACE_TYPES) | ||
.forEach(type => { | ||
fs.copy(`${dir}/PLACE_TYPE-create.xlsx`, `${dir}/${type}-create.xlsx`); | ||
fs.copy(`${dir}/PLACE_TYPE-edit.xlsx`, `${dir}/${type}-edit.xlsx`); | ||
}); | ||
} | ||
|
||
return convertForms(projectDir, 'contact', { | ||
enketo: true, | ||
force_data_node: 'data', | ||
forms: extras, | ||
transformer: (xml, path) => { | ||
const type = path.replace(/.*\/(.*)-(create|edit)\.xml/, '$1'); | ||
return !PLACE_TYPES ? xml : xml | ||
.replace(/PLACE_TYPE/g, type) | ||
.replace(/PLACE_NAME/g, PLACE_TYPES[type]); | ||
}, | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.