Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6345 - Uplift to enketo-core version 5.18.1 #7256

Merged
merged 201 commits into from
Aug 16, 2022
Merged
Changes from 1 commit
Commits
Show all changes
201 commits
Select commit Hold shift + click to select a range
6a41820
Switch enketo-xslt to enketo-transformer
jkuester Aug 16, 2021
0f04c84
Update enketo-core and jquery versions
jkuester Aug 16, 2021
74d0c1b
Fix Enketo css/js hacks to work with new version
jkuester Aug 13, 2021
c858b66
Remove unused webapp patches
jkuester Aug 16, 2021
ac16e4b
Bump up the bundle size of main.js
jkuester Aug 16, 2021
b424840
Update the enketo service in webapp to actually be able to load a form
jkuester Aug 17, 2021
57aa8a1
Bump openrosa-xpath-evaluator version
jkuester Aug 17, 2021
cb7cb2d
Fix up hacking for openrosa stuff
jkuester Aug 17, 2021
ba8c6fb
Clean up functions copied from openrosa and add unit tests
jkuester Aug 18, 2021
351b30b
Fix override language
jkuester Aug 18, 2021
3f59f16
Fix forward button functionality
jkuester Aug 18, 2021
f1f62bc
Re-introduce the updated enketo-inputs-always-relevant.patch
jkuester Aug 18, 2021
660456c
Remove the notewidget from the webapp and move markdown logic to api
jkuester Aug 23, 2021
ce1c6d1
Update CSS (remove .note, hide language picker, etc)
jkuester Aug 23, 2021
240efcc
Fix word-breaking in option labels
jkuester Aug 23, 2021
ce93925
Update wdio selector for phone input
jkuester Aug 25, 2021
eb8b474
Update Protractor selector for phone input
jkuester Aug 25, 2021
322fac7
Fix widgets and add new datepicker-widget
jkuester Aug 25, 2021
c11b7ef
Fix phone-widget unit tests
jkuester Aug 26, 2021
3e1cc17
Convert Enketo config.json to config.js
jkuester Aug 26, 2021
6a9ba75
Add custom Enketo file-manager
jkuester Aug 26, 2021
0bfcf9e
Add horizonal-choices widget
jkuester Aug 26, 2021
a6e2afa
Fix up the db-object-widget
jkuester Aug 27, 2021
2436174
Uplift OpenrosaXpathEvaluatorBinding
jkuester Aug 27, 2021
131b67c
Remove concat-xpath-string test
jkuester Aug 27, 2021
6254ff2
Fix z-score functionality/tests
jkuester Aug 30, 2021
68c84ae
Add custom filepicker-widget
jkuester Aug 30, 2021
693a8a8
Try going back to older style of OpenrosaXpathEvaluatorBInding
jkuester Aug 31, 2021
126878b
Use TAB to close date picker during default delivery tests
jkuester Sep 1, 2021
f9b0dd1
See if anything magical happens when adding the dynamic URL listener
jkuester Sep 1, 2021
72b3cf1
Reset the Submit button when going to previous page
jkuester Sep 1, 2021
731f3e1
Fix default delivery test
jkuester Sep 2, 2021
450cd7e
Clean up custom xpath functions and add tests
jkuester Sep 7, 2021
c967023
Revert "See if anything magical happens when adding the dynamic URL l…
jkuester Sep 2, 2021
aaa5e11
Add note about headless to TESTING doc
jkuester Sep 7, 2021
39aaaf7
Clean up Openrosa Xpath binding
jkuester Sep 7, 2021
cb78fa4
Add test for Enketo language
jkuester Sep 8, 2021
fa0aca0
Reset default delivery form
jkuester Sep 8, 2021
72d9184
Clean up Openrosa Xpath binding
jkuester Sep 8, 2021
75bfb80
Remove unnecessary datepicker and filepicker widgets
jkuester Sep 8, 2021
41feb8f
Remove unnecessary horizontal-choices widget
jkuester Sep 8, 2021
aa2d205
Convert all widgets to classes that extend Widget
jkuester Sep 8, 2021
b56d555
Fix phone widget issues
jkuester Sep 8, 2021
cb88e10
Fix flaking contact summary test
jkuester Sep 9, 2021
d5dda2a
Refactor phone-widget to return promise from constructor
jkuester Sep 9, 2021
d1701d1
Remove weird function code from widgets and see what breaks
jkuester Sep 8, 2021
c2ad0a3
Add additional enketo widgets
jkuester Sep 8, 2021
5b2a354
Add in all widget translactions
jkuester Sep 8, 2021
de6840f
Bump up enketo-transformer and node-html-parser to latest versions
jkuester Sep 9, 2021
9eace41
Reset the maxSize for the main.js bundle
jkuester Sep 10, 2021
e1f8fca
Update z-score function to properly load value from input node
jkuester Sep 10, 2021
abf6976
Revert "Reset the maxSize for the main.js bundle"
jkuester Sep 10, 2021
69a3c22
Go to 950 kB on bundle size
jkuester Sep 10, 2021
87f8b26
Add additional enketo widgets
jkuester Sep 13, 2021
c035718
Remove autocomplete widget
jkuester Sep 13, 2021
b8c375d
Update xsl to support new enketo types
jkuester Sep 13, 2021
2e8aa47
Add new widgets demo form
jkuester Sep 13, 2021
1d4db03
Update readme doc
jkuester Sep 16, 2021
1d619ce
Dedupe webapp
jkuester Sep 17, 2021
9c75516
Try building without extra widgets
jkuester Sep 17, 2021
c559bdb
Drop the CSS too
jkuester Sep 17, 2021
6e3fbc4
dedupe the webapp dependencies
jkuester Sep 17, 2021
6b27627
Add alias to exclude node-forge from bundle
jkuester Sep 17, 2021
1921b97
Bump the bundle size back up to 820 just to get a build
jkuester Sep 17, 2021
7b6c7eb
Bump the bundleSize to 825 kB and add widgets back in except draw/rank
jkuester Sep 20, 2021
9f68e29
Reset non-english translation files
jkuester Sep 20, 2021
d78b75f
Re-add the autocomplete widget
jkuester Sep 21, 2021
ef71ca0
Clean up demo forms
jkuester Sep 21, 2021
da16779
More cleanup on the demo form add proper public domain images
jkuester Sep 21, 2021
b722e00
Add dynamic-url widget
jkuester Sep 24, 2021
a6ed0f3
Remove translations for removed widgets
jkuester Sep 24, 2021
6893b47
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Sep 24, 2021
532c9a2
Update new Enketo widgets to match new format
jkuester Sep 27, 2021
68c4a19
Bump buildSize from 825 -> 830
jkuester Sep 27, 2021
1ab3e9e
Fix bugs in xpath functions
jkuester Sep 27, 2021
df08b9c
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Oct 12, 2021
845b6f0
Remove unnecessary language code
jkuester Oct 12, 2021
3cb901c
Add patch for enketo-repeat-name-collision
jkuester Oct 12, 2021
c2054f9
Add polyfils from core-js-pure and webcomponentsjs
jkuester Oct 22, 2021
d5b5db2
Fix linting issue in polyfills.ts
jkuester Oct 22, 2021
5e74a8f
Change core-js-pure to just be core-js
jkuester Oct 22, 2021
73461a2
Increase polyfill bundle size
jkuester Oct 22, 2021
84fc7d3
Remove unnecessary Promise.finally polyfill
jkuester Oct 25, 2021
8e688d2
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Oct 26, 2021
6a47a54
Update package-lock files
jkuester Oct 26, 2021
c62ee21
Fix package files
jkuester Oct 26, 2021
0963a7a
Fix medic-xpath-extensions
jkuester Oct 26, 2021
b6f71ce
Calibrate new bundle sizes
jkuester Oct 26, 2021
aa7129d
Add missing newline at the end of package-lock.json
jkuester Oct 26, 2021
75b64ee
Remove unnecessary indentation from widget files
jkuester Oct 26, 2021
cf09c9a
Fix medic-xpath-extensions test
jkuester Oct 26, 2021
acc16ab
Fix reports tests
jkuester Oct 27, 2021
209aa6a
Update TESTING doc for debugging wdio tests with Intellij
jkuester Oct 27, 2021
cfd1d27
Revert DEVELOPMENT doc changes
jkuester Oct 28, 2021
6e080fc
Revert Intellij markdown auto-corrections
jkuester Oct 28, 2021
accff65
Clean up markdown code in api
jkuester Nov 4, 2021
bad58d1
Fix linting issues in Markdown
jkuester Nov 4, 2021
a7aac57
Use replaceNode function that is compatible with Node < 11
jkuester Nov 5, 2021
2280b6c
FIx formatting in generate-xform and medic-xpath-extensions
jkuester Nov 5, 2021
9a3eeef
Fix dynamic-url handling in API
jkuester Nov 8, 2021
c6e7c86
Fix linting issues in medic-xpath-extensions
jkuester Nov 9, 2021
3b35852
Clean up date logic in medic-xpath-extensions
jkuester Nov 9, 2021
a4b0c1c
Clean up service code for enketo and z-score
jkuester Nov 9, 2021
5aef37c
Fix more linting issues
jkuester Nov 9, 2021
77c37ab
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Nov 12, 2021
9c7723f
Add test for phone widget selector
jkuester Nov 12, 2021
7c542b5
Clean up test
jkuester Nov 12, 2021
365d0c4
Fix jquery version
jkuester Nov 12, 2021
d50e4bc
Manually remove jquery from enketo block of package-lock
jkuester Nov 12, 2021
04bccff
Use npm-force-resolutions to force version of jquery
jkuester Nov 17, 2021
8f0210f
Remove unnecessary code from db-object-widget
jkuester Nov 17, 2021
86da179
Fix dynamic-url to open properly in xWalk
jkuester Nov 17, 2021
77ff144
ignore-scripts when running npm ci from grunt
jkuester Nov 18, 2021
2e36c13
Roll back npm-force-resolutions changes and use webpack alias
jkuester Nov 18, 2021
0dd3d05
Fix linting issues in dynamic-url
jkuester Nov 18, 2021
ca635f3
Block display of the input in the countdown widget
jkuester Nov 18, 2021
64ba0b5
Update to use new enketo event names
jkuester Nov 19, 2021
d7acb8d
Add a valuechanged listener to refresh navButtons
jkuester Nov 19, 2021
afce881
Update custom xsl to make notes never required
jkuester Nov 19, 2021
c5609a3
Merge branch 'master' into 6345-enketo-uplift
jkuester Nov 23, 2021
ea1d132
Remove isNil from medic-xpath-extensions
jkuester Nov 23, 2021
9b7e8dd
Try just disabling the delivery test to see if others fail
jkuester Nov 23, 2021
2eb1ae1
Wait for form button to be ready before trying to click it
jkuester Nov 23, 2021
1b78a19
Merge branch 'master' into 6345-enketo-uplift
jkuester Nov 24, 2021
7410a55
Move enketo-widgets demo form to support-scripts repo
jkuester Nov 24, 2021
d134926
Clean up generate-xform code and tests
jkuester Nov 29, 2021
0f2c21d
Add e2e test for required notes
jkuester Dec 1, 2021
782d211
Correct behavior of asDate in xpath-entensions
jkuester Dec 6, 2021
484ffb8
Properly import DynamicUrlWidget in tests
jkuester Dec 10, 2021
a5d69ba
Add comment about webpack jquery alias
jkuester Dec 10, 2021
184c21b
Fix db-object-widget selector
jkuester Dec 16, 2021
29096c0
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Dec 16, 2021
dc7bd4f
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Dec 20, 2021
8d7d2d4
Try seeding data for generate-xform test after login
jkuester Dec 20, 2021
ffdda66
Move required note test to submit-enketo-form file
jkuester Dec 20, 2021
4444137
Fix bug with Previous button getting improperly displayed
jkuester Dec 23, 2021
db5c397
Tweak CSS for backwards consistency
jkuester Dec 23, 2021
4a59cb4
Cleanup generate-xform.js
jkuester Jan 7, 2022
04e0bf7
Cleanup default delivery form e2e test
jkuester Jan 7, 2022
c7386d4
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Jan 7, 2022
d09fcfd
Fix removing from a repeat popping a confirmation dialog
jkuester Jan 7, 2022
f1ba7d0
Add patch for openrosa to use old behavior
jkuester Jan 19, 2022
389dd89
Fix css so that notes are not bold
jkuester Jan 21, 2022
2f1df27
Fix issue where form inputs are not always relevant
jkuester Jan 25, 2022
e0a0357
Revert "Add patch for openrosa to use old behavior"
jkuester Feb 24, 2022
2a5da45
Update default contact forms to coalesce unanswered birth month values
jkuester Feb 24, 2022
9a4b36b
Update standard collect delivery form to coalesce number properly
jkuester Feb 25, 2022
8fadc16
Update covid-19 contact forms to coalesce number properly
jkuester Feb 25, 2022
b4505a6
Fix calc in pregnancy_home_visit
jkuester Mar 1, 2022
a6e6b09
Remove unnecessary and broken logic from xPath evaluate
jkuester Mar 1, 2022
410789b
Side-load contact-summary as XmlDocument instead of string
jkuester Mar 1, 2022
652b7ab
Fix selector for inputs to be less restrictive when making relevant
jkuester Mar 2, 2022
d6f8ce3
Refactor standard forms with non-relevant questions with defaults
jkuester Mar 4, 2022
af5bd3e
Update embedded html logic to clear invalid whitespace from html tags
jkuester Mar 4, 2022
e89d571
Fix phone-widget selector so not applied to numbers string questions
jkuester Mar 8, 2022
0372a16
Add custom implementation for format-date xPath function
jkuester Mar 10, 2022
7c69f7f
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Mar 11, 2022
9af7b3d
Update webapp package-lock after merge
jkuester Mar 11, 2022
8debd10
Update api package-lock after merge
jkuester Mar 11, 2022
fe16217
Update default place create forms after merge
jkuester Mar 11, 2022
f07de14
Fix linting
jkuester Mar 14, 2022
1674637
Make android-datepicker text input readonly
jkuester Mar 16, 2022
d63ed71
Fix inputs validation logic to reset relevant if fails validation
jkuester Mar 28, 2022
c0b7da0
Merge branch 'master' into 6345-enketo-uplift
jkuester Mar 28, 2022
6d52eee
Improve regex readability (for real)
jkuester Apr 5, 2022
10e0a5e
Clean up a few things in the webapp
jkuester Apr 5, 2022
b7522bf
Update logic for inputs section to fix constraint issues
jkuester Apr 5, 2022
ab5594e
More updates for inputs section logic to just move back to patches
jkuester Apr 5, 2022
e340b2c
Fix standard delivery form to move still_pregnant field
jkuester Apr 5, 2022
7baac9c
Merge branch 'master' into 6345-enketo-uplift
jkuester Apr 5, 2022
657a5ec
Remove `data-required` from phone input to prevent
jkuester Apr 7, 2022
18bf9af
Merge branch 'master' into 6345-enketo-uplift
jkuester Apr 7, 2022
38514dd
Add custom impl for format-date-time
jkuester Apr 8, 2022
096809c
Clean up enketo service test
jkuester Apr 12, 2022
9baff20
Improve performance on enketo relevant patch
jkuester Apr 12, 2022
2cbb947
Merge branch 'master' into 6345-enketo-uplift
jkuester Apr 12, 2022
9ea7820
Fix loading contact-summary data into forms by polyfilling jQuery
jkuester Apr 14, 2022
530d139
Fix mrdt widget
jkuester Apr 14, 2022
c3b532a
Merge branch 'master' into 6345-enketo-uplift
jkuester Apr 14, 2022
8be75c7
Move jQuery fix out of polyfills so it does not get loaded in polyfills
jkuester Apr 14, 2022
772a4fe
Pause multimedia when navigating between form's pages (#7341)
latin-panda Apr 22, 2022
f1411b3
Merge branch 'master' into 6345-enketo-uplift
jkuester Apr 25, 2022
062cdbc
Merge branch 'master' into 6345-enketo-uplift
jkuester May 13, 2022
bfddfe7
Remove custom date format xpath functions
jkuester May 25, 2022
84f7c5a
Merge branch 'master' into 6345-enketo-uplift
jkuester May 26, 2022
5c09d56
Fix dob_approx calculations in default forms
jkuester Jun 13, 2022
8344c85
Merge branch 'master' into 6345-enketo-uplift
jkuester Jun 14, 2022
1edfb59
Fix decimal-date-time calculations in default delivery form
jkuester Jun 14, 2022
5832b3f
Update delivery and pregnancy-visit tests with new selectors
jkuester Jun 14, 2022
cab004f
Update Enketo file-manager to properly use maxAttachmentSize
jkuester Jun 21, 2022
94ec863
Update db-object-widget to trigger a re-validation of the field's con…
jkuester Jun 24, 2022
693508b
Remove extra line
jkuester Jun 24, 2022
4307554
Update db-object-widget to handle nested db-objects
jkuester Jul 13, 2022
48333c9
Update db-object-widget to proxy from select to input
jkuester Jul 19, 2022
bf328fb
Merge branch 'master' into 6345-enketo-uplift
jkuester Jul 19, 2022
fbc1844
Create brand new select in db-object-widget instead of cloning input
jkuester Jul 21, 2022
d0b19b6
Merge branch 'master' into 6345-enketo-uplift
jkuester Jul 22, 2022
4bfddb8
Fix merge conflict in standard immunization_visit form
jkuester Jul 22, 2022
3a02072
Merge remote-tracking branch 'origin/master' into 6345-enketo-uplift
jkuester Aug 12, 2022
bf71528
Fix api package-lock.json
jkuester Aug 12, 2022
d6b338b
Fix immunization visit e2e test selectors to work with new enketo
jkuester Aug 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions webapp/src/js/enketo/widgets/db-object-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,38 @@ function construct(element) {

const Select2Search = window.CHTCore.Select2Search;

let $textInput = $question.find('input');

const value = $textInput.val();
const disabled = $textInput.prop('readonly');
$textInput.replaceWith($textInput[0].outerHTML.replace(/^<input /, '<select ').replace(/<\/input>/, '</select>'));
$textInput = $question.find('select');
const preSelectedOption = $('<option></option>')
.attr('value', value)
.text(value);
$textInput.append(preSelectedOption);

const contactTypes = getContactTypes($question, $textInput);
const $textInput = $question.find('input');
const $proxyInput = $textInput.clone();

const $option = $('<option></option>');
const setOptionValue = value => $option.attr('value', value).text(value);
setOptionValue($textInput.val());
$textInput.on('inputupdate', () => setOptionValue($textInput.val()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all intents and purposes, I like this refactor.
Turning an input into a select just makes me nervous ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not meaning to add more work on your plate but, since we're already refactoring this, what is the value of cloning the input and then changing the tag versus just making a new select element?
Is it because there are classes and attributes to copy? Are they actually needed on the select?
This is similar to my question above about the duplicated name.

Could there be bugs if we suddenly have two elements that match an old query, be it an attribute or name search?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on the cloning! I had forgotten to circle back to that after I got everything else cleaned up. I went back and did some more testing and found that I could just use a brand new select element without copying anything (besides the name as discussed above).

I think the only thing we need to decide here is what we should use as the name for the the selects. I have left the name of the select the same as the input for now since it simplifies logic downstream in the changeHandler, but we can change that (as I mentioned above). I would just need to include some other way of getting the field path into the changeHandler function...


$textInput.hide();
$textInput.after($proxyInput);
$proxyInput.replaceWith(
$proxyInput[0].outerHTML
.replace(/^<input /, '<select ')
.replace(/<\/input>/, '</select>')
);

const $selectInput = $question.find('select');
$selectInput.append($option);
$selectInput.on('change.dbobjectwidget', () => {
const selected = $selectInput.select2('data');
const id = selected && selected[0] && selected[0].id;
$textInput.val(id);
});

if (!$question.hasClass('or-appearance-bind-id-only')) {
$textInput.on('change.dbobjectwidget', changeHandler);
$selectInput.on('change.dbobjectwidget', changeHandler);
}
const contactTypes = getContactTypes($question, $selectInput);
const allowNew = $question.hasClass('or-appearance-allow-new');
Select2Search.init($textInput, contactTypes, { allowNew }).then(function() {
Select2Search.init($selectInput, contactTypes, { allowNew }).then(function() {
// select2 doesn't understand readonly
$textInput.prop('disabled', disabled);
$selectInput.prop('disabled', $textInput.prop('readonly'));
});
}

Expand All @@ -75,7 +87,7 @@ const changeHandler = function() {
const doc = selected && selected[0] && selected[0].doc;
if (doc) {
const field = $this.attr('name');
const index = $('[name="' + field + '"]').index(this);
const index = $('select[name="' + field + '"]').index(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we end up having one hidden input and a select with the same name?
Is that required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is where things sit now.

Is that required?

It is not required that they have the same name. Things go bad in the Enketo logic if I change the name on the input (which is to be expected). However, I do not have to set the same name onto the select. I do have to set some kind of name on the select or other weird behavior happens in Enekto (a select with no name confuses the Enekto node resolution logic in ways that I do not fully understand...). But as far as I can tell it works fine to just set any random value as the name on the select. I am currently just copying the name from the input, (and am not really seeing any adverse effects), but let me know if you think it would be better to set a static name for all the db-object selects (or to create some kind of dynamic name for each...).

const keyRoot = field.substring(0, field.lastIndexOf('/'));
updateFields(doc, keyRoot, index, field);
// https://github.com/enketo/enketo-core/issues/910
Expand Down