diff --git a/Gruntfile.js b/Gruntfile.js index e4bf9244aa9..1edf361a10d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -254,10 +254,6 @@ 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', ]; return patches.join(' && '); } diff --git a/patches/3804_jr-choice-name.patch b/patches/3804_jr-choice-name.patch deleted file mode 100644 index c9e8e15901a..00000000000 --- a/patches/3804_jr-choice-name.patch +++ /dev/null @@ -1,20 +0,0 @@ -*** node_modules/enketo-core/src/js/output.js 2017-04-20 00:28:05.000000000 +0200 ---- static/js/enketo/core/output.js 2017-08-23 15:35:19.000000000 +0200 -*************** -*** 64,69 **** ---- 64,78 ---- - } - if ( $output.text() !== val ) { - $output.text( val ); -+ -+ // MEDIC CHANGES : BEGIN -+ // For s that are children of choice-groups, trigger -+ // dependent calculations in case one is using a jr:choice-name. -+ var owName = $output.closest( '.option-wrapper' ).find( 'input' ).attr( 'name' ); -+ if ( owName ) { -+ that.form.calc.update( owName ); -+ } -+ // MEDIC CHANGES : END - } - } ); - } diff --git a/static/js/services/enketo.js b/static/js/services/enketo.js index 823798d486c..ff05b3be65f 100644 --- a/static/js/services/enketo.js +++ b/static/js/services/enketo.js @@ -258,6 +258,7 @@ angular.module('inboxServices').service('Enketo', window.history.replaceState({ enketo_page_number: 0 }, ''); overrideNavigationButtons(form, wrapper); addPopStateHandler(form, wrapper); + forceRecalculate(form); return form; }); @@ -268,10 +269,16 @@ angular.module('inboxServices').service('Enketo', .off('.pagemode') .on('click.pagemode', function() { form.pages.next() + .then(function() { + forceRecalculate(form); + }) .then(function(newPageIndex) { if(typeof newPageIndex === 'number') { window.history.pushState({ enketo_page_number: newPageIndex }, ''); } + }) + .then(function() { + forceRecalculate(form); }); return false; }); @@ -280,6 +287,7 @@ angular.module('inboxServices').service('Enketo', .off('.pagemode') .on('click.pagemode', function() { window.history.back(); + forceRecalculate(form); return false; }); }; @@ -464,6 +472,10 @@ angular.module('inboxServices').service('Enketo', }); }; + var forceRecalculate = function(form) { + form.calc.update(); + }; + this.save = function(formInternalId, form, geolocation, docId) { return $q.resolve(form.validate()) .then(function(valid) {