From 314e79061acfa3447fce1a05a784a928a0cf4459 Mon Sep 17 00:00:00 2001 From: Mokhtar Date: Wed, 6 Dec 2023 12:18:35 +0100 Subject: [PATCH] feat(#7599): uplift enketo-core to v7 (#8528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mokhtar Co-authored-by: Tatiana Lépiz <94494491+tatilepizs@users.noreply.github.com> Co-authored-by: tatilepizs Co-authored-by: Joshua Kuestersteffen --- ...egnancy-danger-sign-follow-up.wdio-spec.js | 4 +- webapp/package-lock.json | 168 ++++++++++-------- webapp/package.json | 2 +- webapp/patches/enketo-core+5.18.1.patch | 49 ----- webapp/patches/enketo-core+7.2.5.patch | 60 +++++++ webapp/src/css/enketo/_widgets.scss | 1 - webapp/src/js/enketo/config.js | 6 +- webapp/src/js/enketo/widgets.js | 1 - webapp/src/ts/services/enketo.service.ts | 9 - 9 files changed, 160 insertions(+), 140 deletions(-) delete mode 100644 webapp/patches/enketo-core+5.18.1.patch create mode 100644 webapp/patches/enketo-core+7.2.5.patch diff --git a/tests/e2e/default/enketo/pregnancy-danger-sign-follow-up.wdio-spec.js b/tests/e2e/default/enketo/pregnancy-danger-sign-follow-up.wdio-spec.js index fdebad30b48..f09044a93af 100644 --- a/tests/e2e/default/enketo/pregnancy-danger-sign-follow-up.wdio-spec.js +++ b/tests/e2e/default/enketo/pregnancy-danger-sign-follow-up.wdio-spec.js @@ -46,7 +46,7 @@ describe('Pregnancy danger sign follow-up form', () => { await reportsPage.submitForm(); const updatedReport = await utils.getDoc(reportId); - expect(updatedReport.fields).excludingEvery('instanceID').to.deep.equal(initialReport.fields); + expect(updatedReport.fields).excludingEvery(['instanceID', 'deprecatedID']).to.deep.equal(initialReport.fields); }); @@ -84,6 +84,6 @@ describe('Pregnancy danger sign follow-up form', () => { const compareReportId = await reportsPage.getCurrentReportId(); const compareReport = await utils.getDoc(compareReportId); - expect(updatedReport.fields).excludingEvery('instanceID').to.deep.equal(compareReport.fields); + expect(updatedReport.fields).excludingEvery(['instanceID', 'deprecatedID']).to.deep.equal(compareReport.fields); }); }); diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 37fe2f75778..e8f86c696f5 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -32,7 +32,7 @@ "bootstrap-daterangepicker": "^2.1.30", "bowser": "^2.11.0", "core-js": "^3.30.2", - "enketo-core": "^5.18.1", + "enketo-core": "^7.2.5", "eurodigit": "^3.1.3", "font-awesome": "^4.7.0", "google-libphonenumber": "^3.2.31", @@ -1246,6 +1246,14 @@ "resolved": "https://registry.npmjs.org/@webcomponents/webcomponentsjs/-/webcomponentsjs-2.8.0.tgz", "integrity": "sha512-loGD63sacRzOzSJgQnB9ZAhaQGkN7wl2Zuw7tsphI5Isa0irijrRo6EnJii/GgjGefIFO8AIO7UivzRhFaEk9w==" }, + "node_modules/@xmldom/xmldom": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.13.tgz", + "integrity": "sha512-lm2GW5PkosIzccsaZIz7tp8cPADSIlIHWDFTR1N0SzfinhhYgeIQjFMz4rYzanCScr3DqQLeomUDArp6MWKm+g==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/almond": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/almond/-/almond-0.3.3.tgz", @@ -1329,10 +1337,16 @@ "ms": "2.0.0" } }, + "node_modules/drag-drop-touch": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/drag-drop-touch/-/drag-drop-touch-1.3.1.tgz", + "integrity": "sha512-Q0/ZgsnW7VUjn+YqSnp1rvxjjPnZX5YLyVaw28einood+eTMcLzgOgHk8nyqIF9O18J68l+2htlEnbw5GsyTvQ==" + }, "node_modules/enketo-core": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/enketo-core/-/enketo-core-5.18.1.tgz", - "integrity": "sha512-hk3l+EVghy1KTKUr01C5x0Ps3cr8nQMPxwx65E1qpOLuH3mY8TtpiWIy1XXJo4fkX4Wc8dLek8o9YYsVcNripg==", + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/enketo-core/-/enketo-core-7.2.5.tgz", + "integrity": "sha512-YYIVh8iqiXydwCfe2GkFxVtwxrAkrt4jOjpszwZvSYIkek4T2Z6Qs5T/8v0Lr54+1o65i3eQSHlWJ/g1VyVCqw==", + "hasInstallScript": true, "os": [ "darwin", "linux", @@ -1340,30 +1354,27 @@ ], "dependencies": { "bootstrap-datepicker": "1.9.x", - "html5sortable": "^0.13.2", - "jquery": "^3.6.0", + "drag-drop-touch": "^1.3.1", + "html5sortable": "^0.13.3", + "jquery": "3.6.3", "jquery-touchswipe": "^1.6.19", - "leaflet": "^1.7.1", + "leaflet": "^1.9.4", "leaflet-draw": "github:enketo/Leaflet.draw#ff73078", - "leaflet.gridlayer.googlemutant": "^0.13.4", - "mergexml": "1.2.1", - "node-forge": "^0.10.0", - "openrosa-xpath-evaluator": "^2.0.7", - "signature_pad": "2.3.x" + "leaflet.gridlayer.googlemutant": "^0.13.5", + "mergexml": "1.2.3", + "node-forge": "^1.3.1", + "openrosa-xpath-evaluator": "^2.0.13", + "signature_pad": "^4.1.6" + }, + "engines": { + "node": ">=14 <17", + "npm": ">=6 <7" } }, "node_modules/enketo-core/node_modules/jquery": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.1.tgz", - "integrity": "sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==" - }, - "node_modules/enketo-core/node_modules/node-forge": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", - "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==", - "engines": { - "node": ">= 6.0.0" - } + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.3.tgz", + "integrity": "sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg==" }, "node_modules/entities": { "version": "4.4.0", @@ -1443,9 +1454,9 @@ "integrity": "sha512-b0BGje9reNRU3u6ksAK9QqnX7yBRgLNe/wYG7DOfyDlhBlYjayIT8bSOHmcuvptIDW/ubM9CTW/mnZf9Rohuow==" }, "node_modules/leaflet": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.8.0.tgz", - "integrity": "sha512-gwhMjFCQiYs3x/Sf+d49f10ERXaEFCPr+nVTryhAW8DWbMGqJqt9G4XuIaHmFW08zYvhgdzqXGr8AlW8v8dQkA==" + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==" }, "node_modules/leaflet-draw": { "version": "1.0.4", @@ -1473,12 +1484,12 @@ "integrity": "sha512-/K3BC0KIsO+WK2i94LkMPv3wslMrazrQhfi5We9fMbLlLjzoOSJWr7TAdupLlDWaJcWxwoNosBkhFDejiu5VDw==" }, "node_modules/mergexml": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/mergexml/-/mergexml-1.2.1.tgz", - "integrity": "sha512-IOW62CoY+QfpzsVrDhNG8hKAZnIRhmMldKfbl6/VAUecW6tUNWWtkWroCW4wSXaZp46GRwtUmZjGWCeK4FTS2w==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/mergexml/-/mergexml-1.2.3.tgz", + "integrity": "sha512-sNc9qswtLUoGmN0MB3dY+MCIJqCGEZZrtYp0Z5Iwsk6ELc/V96SFIuv5Y6O6tYAsFtdpJcPFV0FgOSHSciJLbA==", "dependencies": { + "@xmldom/xmldom": "^0.7.0", "formidable": "^1.2.1", - "xmldom": "^0.1.27", "xpath": "0.0.27" } }, @@ -1543,6 +1554,14 @@ "@angular/core": "^15.0.0" } }, + "node_modules/node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", + "engines": { + "node": ">= 6.13.0" + } + }, "node_modules/object-path": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.8.tgz", @@ -1666,9 +1685,9 @@ } }, "node_modules/signature_pad": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/signature_pad/-/signature_pad-2.3.2.tgz", - "integrity": "sha512-peYXLxOsIY6MES2TrRLDiNg2T++8gGbpP2yaC+6Ohtxr+a2dzoaqWosWDY9sWqTAAk6E/TyQO+LJw9zQwyu5kA==" + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/signature_pad/-/signature_pad-4.1.6.tgz", + "integrity": "sha512-eoZB8qFPfCs7o00weajp5roNnE2gY2kTNjZsh805L8V+lYPagxoZi9qrBFS3A6sgbVq++ukdzgruK7tuv3JFXQ==" }, "node_modules/simple-password-tester": { "version": "1.0.0", @@ -1698,15 +1717,6 @@ "resolved": "https://registry.npmjs.org/vuvuzela/-/vuvuzela-1.0.3.tgz", "integrity": "sha1-O+FF5YJxxzylUnndhR8SpoIRSws=" }, - "node_modules/xmldom": { - "version": "0.1.31", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", - "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==", - "deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0", - "engines": { - "node": ">=0.1" - } - }, "node_modules/xpath": { "version": "0.0.27", "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.27.tgz", @@ -2681,6 +2691,11 @@ "resolved": "https://registry.npmjs.org/@webcomponents/webcomponentsjs/-/webcomponentsjs-2.8.0.tgz", "integrity": "sha512-loGD63sacRzOzSJgQnB9ZAhaQGkN7wl2Zuw7tsphI5Isa0irijrRo6EnJii/GgjGefIFO8AIO7UivzRhFaEk9w==" }, + "@xmldom/xmldom": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.13.tgz", + "integrity": "sha512-lm2GW5PkosIzccsaZIz7tp8cPADSIlIHWDFTR1N0SzfinhhYgeIQjFMz4rYzanCScr3DqQLeomUDArp6MWKm+g==" + }, "almond": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/almond/-/almond-0.3.3.tgz", @@ -2753,33 +2768,34 @@ "ms": "2.0.0" } }, + "drag-drop-touch": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/drag-drop-touch/-/drag-drop-touch-1.3.1.tgz", + "integrity": "sha512-Q0/ZgsnW7VUjn+YqSnp1rvxjjPnZX5YLyVaw28einood+eTMcLzgOgHk8nyqIF9O18J68l+2htlEnbw5GsyTvQ==" + }, "enketo-core": { - "version": "5.18.1", - "resolved": "https://registry.npmjs.org/enketo-core/-/enketo-core-5.18.1.tgz", - "integrity": "sha512-hk3l+EVghy1KTKUr01C5x0Ps3cr8nQMPxwx65E1qpOLuH3mY8TtpiWIy1XXJo4fkX4Wc8dLek8o9YYsVcNripg==", + "version": "7.2.5", + "resolved": "https://registry.npmjs.org/enketo-core/-/enketo-core-7.2.5.tgz", + "integrity": "sha512-YYIVh8iqiXydwCfe2GkFxVtwxrAkrt4jOjpszwZvSYIkek4T2Z6Qs5T/8v0Lr54+1o65i3eQSHlWJ/g1VyVCqw==", "requires": { "bootstrap-datepicker": "1.9.x", - "html5sortable": "^0.13.2", - "jquery": "^3.6.0", + "drag-drop-touch": "^1.3.1", + "html5sortable": "^0.13.3", + "jquery": "3.6.3", "jquery-touchswipe": "^1.6.19", - "leaflet": "^1.7.1", + "leaflet": "^1.9.4", "leaflet-draw": "github:enketo/Leaflet.draw#ff73078", - "leaflet.gridlayer.googlemutant": "^0.13.4", - "mergexml": "1.2.1", - "node-forge": "^0.10.0", - "openrosa-xpath-evaluator": "^2.0.7", - "signature_pad": "2.3.x" + "leaflet.gridlayer.googlemutant": "^0.13.5", + "mergexml": "1.2.3", + "node-forge": "^1.3.1", + "openrosa-xpath-evaluator": "^2.0.13", + "signature_pad": "^4.1.6" }, "dependencies": { "jquery": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.1.tgz", - "integrity": "sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==" - }, - "node-forge": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", - "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.3.tgz", + "integrity": "sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg==" } } }, @@ -2845,9 +2861,9 @@ "integrity": "sha512-b0BGje9reNRU3u6ksAK9QqnX7yBRgLNe/wYG7DOfyDlhBlYjayIT8bSOHmcuvptIDW/ubM9CTW/mnZf9Rohuow==" }, "leaflet": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.8.0.tgz", - "integrity": "sha512-gwhMjFCQiYs3x/Sf+d49f10ERXaEFCPr+nVTryhAW8DWbMGqJqt9G4XuIaHmFW08zYvhgdzqXGr8AlW8v8dQkA==" + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", + "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==" }, "leaflet-draw": { "version": "git+ssh://git@github.com/enketo/Leaflet.draw.git#ff730785db7fcccbf2485ffcf4dffe1238a7c617", @@ -2874,12 +2890,12 @@ "integrity": "sha512-/K3BC0KIsO+WK2i94LkMPv3wslMrazrQhfi5We9fMbLlLjzoOSJWr7TAdupLlDWaJcWxwoNosBkhFDejiu5VDw==" }, "mergexml": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/mergexml/-/mergexml-1.2.1.tgz", - "integrity": "sha512-IOW62CoY+QfpzsVrDhNG8hKAZnIRhmMldKfbl6/VAUecW6tUNWWtkWroCW4wSXaZp46GRwtUmZjGWCeK4FTS2w==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/mergexml/-/mergexml-1.2.3.tgz", + "integrity": "sha512-sNc9qswtLUoGmN0MB3dY+MCIJqCGEZZrtYp0Z5Iwsk6ELc/V96SFIuv5Y6O6tYAsFtdpJcPFV0FgOSHSciJLbA==", "requires": { + "@xmldom/xmldom": "^0.7.0", "formidable": "^1.2.1", - "xmldom": "^0.1.27", "xpath": "0.0.27" } }, @@ -2924,6 +2940,11 @@ "tslib": "^2.0.0" } }, + "node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==" + }, "object-path": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/object-path/-/object-path-0.11.8.tgz", @@ -3038,9 +3059,9 @@ } }, "signature_pad": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/signature_pad/-/signature_pad-2.3.2.tgz", - "integrity": "sha512-peYXLxOsIY6MES2TrRLDiNg2T++8gGbpP2yaC+6Ohtxr+a2dzoaqWosWDY9sWqTAAk6E/TyQO+LJw9zQwyu5kA==" + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/signature_pad/-/signature_pad-4.1.6.tgz", + "integrity": "sha512-eoZB8qFPfCs7o00weajp5roNnE2gY2kTNjZsh805L8V+lYPagxoZi9qrBFS3A6sgbVq++ukdzgruK7tuv3JFXQ==" }, "simple-password-tester": { "version": "1.0.0", @@ -3067,11 +3088,6 @@ "resolved": "https://registry.npmjs.org/vuvuzela/-/vuvuzela-1.0.3.tgz", "integrity": "sha1-O+FF5YJxxzylUnndhR8SpoIRSws=" }, - "xmldom": { - "version": "0.1.31", - "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz", - "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==" - }, "xpath": { "version": "0.0.27", "resolved": "https://registry.npmjs.org/xpath/-/xpath-0.0.27.tgz", diff --git a/webapp/package.json b/webapp/package.json index f1037493b1f..20504297eed 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -47,7 +47,7 @@ "bootstrap-daterangepicker": "^2.1.30", "bowser": "^2.11.0", "core-js": "^3.30.2", - "enketo-core": "^5.18.1", + "enketo-core": "^7.2.5", "eurodigit": "^3.1.3", "font-awesome": "^4.7.0", "google-libphonenumber": "^3.2.31", diff --git a/webapp/patches/enketo-core+5.18.1.patch b/webapp/patches/enketo-core+5.18.1.patch deleted file mode 100644 index cbd68214f06..00000000000 --- a/webapp/patches/enketo-core+5.18.1.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/node_modules/enketo-core/src/js/calculate.js b/node_modules/enketo-core/src/js/calculate.js -index 09f2e5a..c7f6ae5 100644 ---- a/node_modules/enketo-core/src/js/calculate.js -+++ b/node_modules/enketo-core/src/js/calculate.js -@@ -58,7 +58,13 @@ export default { - * and the dependent node is inside the same repeat, we can prevent the expensive index determination - */ - const dataNodeName = ( name.lastIndexOf( '/' ) !== -1 ) ? name.substring( name.lastIndexOf( '/' ) + 1 ) : name; -- const dataNode = this.form.model.node( updated.repeatPath, updated.repeatIndex ).getElement().querySelector( dataNodeName ); -+ -+ // CHT-CORE PATCH -+ // patch enketo to fix repeat name collision bug -+ // this should be removed when upgrading to a new version of enketo-core -+ // https://github.com/enketo/enketo-core/issues/815 -+ const childNodeList = this.form.model.node( updated.repeatPath, updated.repeatIndex ).getElement().querySelectorAll( dataNodeName ); -+ const dataNode = Array.from( childNodeList ).filter( node => dataNodes.includes( node ) )[0]; - props.index = dataNodes.indexOf( dataNode ); - this._updateCalc( control, props, emptyNonRelevant ); - } else if ( control.type === 'hidden' ) { -diff --git a/node_modules/enketo-core/src/js/form.js b/node_modules/enketo-core/src/js/form.js -index 399d5b0..54e525e 100644 ---- a/node_modules/enketo-core/src/js/form.js -+++ b/node_modules/enketo-core/src/js/form.js -@@ -662,6 +662,10 @@ Form.prototype.getDataStrWithoutIrrelevantNodes = function() { - const path = that.input.getName( node ); - let target; - -+ // CHT-CORE PATCH -+ // /inputs is ALWAYS relevant #4875 -+ if(/\/inputs$/.test(path)) return; -+ - /* - * Copied from relevant.js: - * -diff --git a/node_modules/enketo-core/src/js/relevant.js b/node_modules/enketo-core/src/js/relevant.js -index 971d9ce..2623f7d 100644 ---- a/node_modules/enketo-core/src/js/relevant.js -+++ b/node_modules/enketo-core/src/js/relevant.js -@@ -216,7 +216,9 @@ export default { - - if ( neverEnabled || this.selfRelevant( branchNode ) || forceClearNonRelevant ) { - changed = true; -- if ( forceClearNonRelevant ) { -+ // CHT PATCH -+ // /inputs is ALWAYS relevant #4875 -+ if ( forceClearNonRelevant && !path.endsWith('/inputs') ) { - this.clear( branchNode, path ); - } - diff --git a/webapp/patches/enketo-core+7.2.5.patch b/webapp/patches/enketo-core+7.2.5.patch new file mode 100644 index 00000000000..ed3792f0435 --- /dev/null +++ b/webapp/patches/enketo-core+7.2.5.patch @@ -0,0 +1,60 @@ +diff --git a/node_modules/enketo-core/src/js/form.js b/node_modules/enketo-core/src/js/form.js +index 62003af..db02cba 100644 +--- a/node_modules/enketo-core/src/js/form.js ++++ b/node_modules/enketo-core/src/js/form.js +@@ -939,6 +939,10 @@ Form.prototype.getDataStrWithoutIrrelevantNodes = function () { + const path = that.input.getName(node); + let target; + ++ // CHT-CORE PATCH ++ // /inputs is ALWAYS relevant #4875 ++ if(/\/inputs$/.test(path)) return; ++ + /* + * Copied from relevant.js: + * +diff --git a/node_modules/enketo-core/src/js/relevant.js b/node_modules/enketo-core/src/js/relevant.js +index 463af2c..f7dbe4d 100644 +--- a/node_modules/enketo-core/src/js/relevant.js ++++ b/node_modules/enketo-core/src/js/relevant.js +@@ -458,7 +458,9 @@ export default { + : currentValue, + }); + } else { +- if (isLeafNode && textContent !== '') { ++ // CHT PATCH ++ // /inputs is ALWAYS relevant #4875 ++ if (isLeafNode && textContent !== '' && !path.endsWith('/inputs')) { + node.textContent = ''; + } + +diff --git a/node_modules/enketo-core/src/widget/date/datepicker-extended.js b/node_modules/enketo-core/src/widget/date/datepicker-extended.js +index 6febee3..afbf8df 100644 +--- a/node_modules/enketo-core/src/widget/date/datepicker-extended.js ++++ b/node_modules/enketo-core/src/widget/date/datepicker-extended.js +@@ -149,6 +149,10 @@ class DatepickerExtended extends Widget { + // Handle focus on original input (goTo functionality) + $(this.element).on('applyfocus', () => { + $fakeDateI[0].focus(); ++ // CHT - https://github.com/enketo/enketo-core/issues/1002 ++ // Do not automatically pop open the datepicker when just focusing on outer element ++ $fakeDateI.datepicker('hide'); ++ $fakeDateI.blur(); + }); + } + +diff --git a/node_modules/enketo-core/src/widget/datetime/datetimepicker-extended.js b/node_modules/enketo-core/src/widget/datetime/datetimepicker-extended.js +index 4a71bfa..7c72f94 100644 +--- a/node_modules/enketo-core/src/widget/datetime/datetimepicker-extended.js ++++ b/node_modules/enketo-core/src/widget/datetime/datetimepicker-extended.js +@@ -127,6 +127,10 @@ class DatetimepickerExtended extends Widget { + // Handle focus on original input (goTo functionality) + this.element.addEventListener(events.ApplyFocus().type, () => { + $els.eq(0).focus(); ++ // CHT - https://github.com/enketo/enketo-core/issues/1002 ++ // Do not automatically pop open the datepicker when just focusing on outer element ++ $els.eq(0).datepicker('hide'); ++ $els.eq(0).blur(); + }); + } + diff --git a/webapp/src/css/enketo/_widgets.scss b/webapp/src/css/enketo/_widgets.scss index 9bc33362d00..780396f3cbf 100644 --- a/webapp/src/css/enketo/_widgets.scss +++ b/webapp/src/css/enketo/_widgets.scss @@ -15,6 +15,5 @@ @import "../../../node_modules/enketo-core/src/widget/select-likert/likertitem.scss"; @import "../../../node_modules/enketo-core/src/widget/select-desktop/selectpicker.scss"; @import "../../../node_modules/enketo-core/src/widget/select-mobile/selectpicker.scss"; -@import "../../../node_modules/enketo-core/src/widget/analog-scale/analog-scalepicker.scss"; @import "../../../node_modules/enketo-core/src/widget/textarea/textarea.scss"; @import "../../../node_modules/enketo-core/src/widget/select-autocomplete/autocomplete.scss"; diff --git a/webapp/src/js/enketo/config.js b/webapp/src/js/enketo/config.js index 8d8c1d0df33..fcfe0b7504f 100644 --- a/webapp/src/js/enketo/config.js +++ b/webapp/src/js/enketo/config.js @@ -10,5 +10,9 @@ module.exports = { 'validateContinuously': false, 'validatePage': true, 'swipePage': false, - 'textMaxChars': 2000 + 'textMaxChars': 2000, + 'excludeNonRelevant': true, + 'experimentalOptimizations': { + 'computeAsync': false, + }, }; diff --git a/webapp/src/js/enketo/widgets.js b/webapp/src/js/enketo/widgets.js index 3687fb590f3..133f829fc96 100644 --- a/webapp/src/js/enketo/widgets.js +++ b/webapp/src/js/enketo/widgets.js @@ -18,7 +18,6 @@ require( 'enketo-core/src/widget/select-likert/likertitem' ).default, require( 'enketo-core/src/widget/select-desktop/selectpicker' ).default, require( 'enketo-core/src/widget/select-mobile/selectpicker' ).default, - require( 'enketo-core/src/widget/analog-scale/analog-scalepicker' ).default, require( 'enketo-core/src/widget/textarea/textarea' ).default, require( 'enketo-core/src/widget/select-autocomplete/autocomplete' ).default, require( './widgets/countdown-widget' ), diff --git a/webapp/src/ts/services/enketo.service.ts b/webapp/src/ts/services/enketo.service.ts index 4026d025b96..62868cded91 100644 --- a/webapp/src/ts/services/enketo.service.ts +++ b/webapp/src/ts/services/enketo.service.ts @@ -241,7 +241,6 @@ export class EnketoService { window.history.pushState({ enketo_page_number: currentIndex }, ''); } this.setupNavButtons($wrapper, currentIndex); - this.pauseMultimedia($wrapper); } this.forceRecalculate(form); }); @@ -264,18 +263,10 @@ export class EnketoService { this.setupNavButtons($wrapper, pageIndex); this.forceRecalculate(form); - this.pauseMultimedia($wrapper); return false; }); } - // This code can be removed once this issue is fixed: https://github.com/enketo/enketo-core/issues/816 - private pauseMultimedia($wrapper) { - $wrapper - .find('audio, video') - .each((idx, element) => element.pause()); - } - private addPopStateHandler(form, $wrapper) { $(window).on('popstate.enketo-pagemode', (event: any) => { if (event.originalEvent &&