diff --git a/src/commcareConnect.js b/src/commcareConnect.js
index 8ab31f4d6..ff6b76311 100644
--- a/src/commcareConnect.js
+++ b/src/commcareConnect.js
@@ -62,6 +62,20 @@ define([
// allows the parser to know which mug to associate with this node
"vellum:role": mug.__className,
}),
+ getBindList: mug => {
+ // return list of bind elements to add to the form
+ let mugConfig = mugConfigs[mug.__className];
+ let binds = [{
+ nodeset: mug.hashtagPath,
+ relevant: mug.p.relevantAttr,
+ }];
+ return binds.concat(mugConfig.childNodes.filter(child => !child.writeToData).map(child => {
+ return {
+ nodeset: `${mug.absolutePath}/${mugConfig.rootName}/${child.id}`,
+ calculate: mug.p[child.id],
+ };
+ }));
+ },
parseDataNode: (mug, node) => {
let children = node.children(),
mugConfig = mugConfigs[mug.__className];
@@ -122,7 +136,6 @@ define([
mug.p.description = "";
mug.p.time_estimate = "";
},
- getBindList: () => [],
spec: util.extend(baseSpec, {
nodeID: {
lstring: gettext('Module ID'),
@@ -149,17 +162,29 @@ define([
return val && val.match(/^\d+$/) ? "pass" : gettext("Must be an integer");
},
help: gettext('Estimated time to complete the module in hours.'),
+ },
+ relevantAttr: {
+ visibility: 'visible',
+ presence: 'optional',
+ widget: widgets.xPath,
+ xpathType: "bool",
+ serialize: mugs.serializeXPath,
+ deserialize: mugs.deserializeXPath,
+ lstring: gettext('Display Condition'),
}
})
}),
- sections: [_.extend({}, baseSection, {
- properties: [
- "nodeID",
- "name",
- "description",
- "time_estimate",
- ],
- })],
+ sections: [
+ _.extend({}, baseSection, {
+ properties: [
+ "nodeID",
+ "name",
+ "description",
+ "time_estimate",
+ ],
+ }),
+ _.clone(logicSection),
+ ],
},
ConnectAssessment: {
rootName: "assessment",
@@ -172,20 +197,6 @@ define([
init: mug => {
mug.p.user_score = "";
},
- getBindList: mug => {
- // return list of bind elements to add to the form
- let mugConfig = mugConfigs[mug.__className];
- let binds = [{
- nodeset: mug.hashtagPath,
- relevant: mug.p.relevantAttr,
- }];
- return binds.concat(mugConfig.childNodes.map(child => {
- return {
- nodeset: `${mug.absolutePath}/${mugConfig.rootName}/${child.id}`,
- calculate: mug.p[child.id],
- };
- }));
- },
spec: util.extend(baseSpec, {
nodeID: {
lstring: gettext('Assessment ID'),
@@ -235,20 +246,6 @@ define([
mug.p.entity_id = "";
mug.p.entity_name = "";
},
- getBindList: mug => {
- // return list of bind elements to add to the form
- let mugConfig = mugConfigs[mug.__className];
- let binds = [{
- nodeset: mug.hashtagPath,
- relevant: mug.p.relevantAttr,
- }];
- return binds.concat(mugConfig.childNodes.filter(child => !child.writeToData).map(child => {
- return {
- nodeset: `${mug.absolutePath}/${mugConfig.rootName}/${child.id}`,
- calculate: mug.p[child.id],
- };
- }));
- },
spec: util.extend(baseSpec, {
nodeID: {
lstring: gettext('Delivery Unit ID'),
diff --git a/tests/commcareConnect.js b/tests/commcareConnect.js
index 8a729ed16..37960de61 100644
--- a/tests/commcareConnect.js
+++ b/tests/commcareConnect.js
@@ -36,6 +36,7 @@ define([
assert.equal(module.p.name, "module 1");
assert.equal(module.p.description, "Module 1 is fun\nLearning is fun");
assert.equal(module.p.time_estimate, "2");
+ assert.equal(module.p.relevantAttr, "x = 2");
util.assertXmlEqual(call("createXML"), LEARN_MODULE_XML);
});
diff --git a/tests/static/commcareConnect/learn_module.xml b/tests/static/commcareConnect/learn_module.xml
index c3bdd567f..a19a50b16 100644
--- a/tests/static/commcareConnect/learn_module.xml
+++ b/tests/static/commcareConnect/learn_module.xml
@@ -16,6 +16,7 @@
+