Skip to content

Commit

Permalink
Update to latest enketo
Browse files Browse the repository at this point in the history
* Add jr:choice-name() demo form
* Update to latest enketo
* Patch enketo to fix jr:choice-name() issue
* Patch enketo-core's date css source file to fix imports
* Update enketo XSLT to support new style of repeat groups

Closes #3487
Closes #3804
  • Loading branch information
alxndrsn authored and garethbowen committed Sep 20, 2017
1 parent fb9bf59 commit d9ff646
Show file tree
Hide file tree
Showing 19 changed files with 1,365 additions and 182 deletions.
16 changes: 11 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ module.exports = function(grunt) {
'session': './packages/session/session',
'kujua-sms/utils': './packages/kujua-sms/kujua-sms/utils',
'views/lib/objectpath': './packages/kujua-sms/views/lib/objectpath',
'text!enketo-config': './static/js/enketo/config.json',
'enketo-config': './static/js/enketo/config.json',
'widgets': './static/js/enketo/widgets',
'./xpath-evaluator-binding':'./static/js/enketo/OpenrosaXpathEvaluatorBinding',
'extended-xpath': './node_modules/openrosa-xpath-evaluator/src/extended-xpath',
'openrosa-xpath-extensions': './node_modules/openrosa-xpath-evaluator/src/openrosa-xpath-extensions',
'translator': './static/js/enketo/translator', // translator for enketo's internal i18n
'../../js/dropdown.jquery': 'bootstrap/js/dropdown', // enketo currently duplicates bootstrap's dropdown code. working to resolve this upstream https://github.com/enketo/enketo-core/issues/454
'libphonenumber/utils': './packages/libphonenumber/libphonenumber/utils',
'libphonenumber/libphonenumber': './packages/libphonenumber/libphonenumber/libphonenumber',
'worker-pouch/workerified': './node_modules/worker-pouch/lib/workerified/',
Expand Down Expand Up @@ -143,6 +144,7 @@ module.exports = function(grunt) {
cwd: 'node_modules',
src: [
'bootstrap-daterangepicker/**',
'enketo-core/**',
'font-awesome/**',
'moment/**',
'pouchdb-adapter-idb/**',
Expand Down Expand Up @@ -173,9 +175,6 @@ module.exports = function(grunt) {
}
},
exec: {
dedupe_jquery: {
cmd: 'rm -rf node_modules/@medic/enketo-core/node_modules/jquery'
},
deploy: {
cmd: 'kanso push $COUCH_URL'
},
Expand Down Expand Up @@ -214,6 +213,7 @@ module.exports = function(grunt) {
cmd: function() {
var modulesToPatch = [
'bootstrap-daterangepicker',
'enketo-core',
'font-awesome',
'moment',
'pouchdb-adapter-idb',
Expand Down Expand Up @@ -251,6 +251,13 @@ module.exports = function(grunt) {
// patch pouch to improve safari checks
// https://github.com/medic/medic-webapp/issues/2797
'patch node_modules/pouchdb-adapter-idb/lib/index.js < patches/pouchdb-ignore-safari-check.patch',

// patch enketo to support cascading of jr:choice-name() update results
// https://github.com/medic/medic-webapp/issues/3804
'patch node_modules/enketo-core/src/js/output.js < patches/3804_jr-choice-name.patch',

// patch enketo's bootstrap-datepicker dependency so that sass compiles properly
'patch node_modules/enketo-core/src/widget/date/datepicker-extended.scss < patches/enketo-datepicker-extended-sass-import.patch',
];
return patches.join(' && ');
}
Expand Down Expand Up @@ -411,7 +418,6 @@ module.exports = function(grunt) {
grunt.registerTask('mmnpm', 'Update and patch npm dependencies', [
'exec:undopatches',
'auto_install:npm',
'exec:dedupe_jquery',
'copy:librariestopatch',
'exec:applypatches'
]);
Expand Down
56 changes: 56 additions & 0 deletions demo-forms/jr-choice-name.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<!--
This form is taken from https://github.com/enketo/enketo-core/issues/412 and
demonstrates how jr:choice-name() can create problems with property updates.
-->

<h:head>
<h:title>Test Issue 3281</h:title>
<model>
<instance>
<issue-3281 delimiter="#" id="issue_3281" prefix="J1!issue_3281!" version="2017-03-24">
<input>Default Value</input>
<translator>clinic</translator><output/><debug/>
<note/>
<meta>
<instanceID/>
</meta>
</issue-3281>
</instance>
<bind nodeset="/issue-3281/input" type="string"/>
<bind nodeset="/issue-3281/translator" type="select1"/>
<bind calculate="jr:choice-name( /issue-3281/translator ,' /issue-3281/translator ')" nodeset="/issue-3281/output" type="string"/>
<bind nodeset="/issue-3281/debug" readonly="true()" type="string"/>
<bind nodeset="/issue-3281/note" readonly="true()" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/issue-3281/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/issue-3281/input">
<label>Input</label>
</input>
<select1 ref="/issue-3281/translator">
<label>Translator</label>
<item>
<label>[<output value=" /issue-3281/input "/>] District</label>
<value>district_hospital</value>
</item>
<item>
<label>[<output value=" /issue-3281/input "/>] Health Center</label>
<value>health_center</value>
</item>
<item>
<label>[<output value=" /issue-3281/input "/>] Area</label>
<value>clinic</value>
</item>
</select1>
<input ref="/issue-3281/debug">
<label>jr:choice-name($ {translator},'$ {translator}') = **<output value=" /issue-3281/output "/>**</label>
</input>
<input ref="/issue-3281/note">
<label>The value above is stale if _Input_ is changed and you leave the textbox since it modifies the choice label for _Translator_ but not the value. The choice-name function gets updated if the choice value is modified, but should also update if the choice label changes.</label>
</input>
</h:body>
</h:html>
Loading

0 comments on commit d9ff646

Please sign in to comment.