Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Fixing bug on submitXLS function to use expandReferences
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias W. BA authored and Elias W. BA committed Sep 28, 2021
1 parent 62bd3a4 commit 638ff5a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions lib/Adaptor.js
Expand Up @@ -182,6 +182,7 @@ function submitXls(formData, params) {
username,
password
} = state.configuration;
const json = (0, _languageCommon.expandReferences)(formData)(state);
const {
case_type,
search_field,
Expand All @@ -191,7 +192,7 @@ function submitXls(formData, params) {

const workbook = _xlsx.default.utils.book_new();

const worksheet = _xlsx.default.utils.json_to_sheet(formData);
const worksheet = _xlsx.default.utils.json_to_sheet(json);

const ws_name = 'SheetJS';

Expand Down Expand Up @@ -325,4 +326,4 @@ function fetchReportData(reportId, params, postUrl) {
});
}
});
}
}
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -14,4 +14,4 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var _default = Adaptor;
exports.default = _default;
exports.default = _default;
8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -9,10 +9,12 @@
},
"main": "lib/index.js",
"scripts": {
"build": "make",
"ast": "simple-ast --adaptor ./src/Adaptor.js --output ast.json",
"build": "node_modules/.bin/babel src -d lib && npm run ast",
"postversion": "git push && git push --tags",
"test": "mocha --require @babel/register",
"test:watch": "mocha -w --require @babel/register",
"prepack": "npx @openfn/simple-ast --adaptor ./lib/Adaptor.js --output ast.json"
"version": "npm run build && git add -A lib ast.json"
},
"author": "Open Function Group",
"license": "LGPLv3",
Expand All @@ -21,7 +23,7 @@
"ast.json"
],
"dependencies": {
"@openfn/language-common": "1.4.1",
"@openfn/language-common": "1.4.2",
"form-data": "^4.0.0",
"js2xmlparser": "^1.0.0",
"JSONPath": "^0.10.0",
Expand Down
4 changes: 3 additions & 1 deletion src/Adaptor.js
Expand Up @@ -89,6 +89,8 @@ export function submitXls(formData, params) {
username,
password,
} = state.configuration;

const json = expandReferences(formData)(state);
const { case_type, search_field, create_new_cases } = params;

const url = (hostUrl || 'https://www.commcarehq.org').concat(
Expand All @@ -98,7 +100,7 @@ export function submitXls(formData, params) {
);

const workbook = xlsx.utils.book_new();
const worksheet = xlsx.utils.json_to_sheet(formData);
const worksheet = xlsx.utils.json_to_sheet(json);
const ws_name = 'SheetJS';
xlsx.utils.book_append_sheet(workbook, worksheet, ws_name);

Expand Down

0 comments on commit 638ff5a

Please sign in to comment.