enketo / enketo-dristhi

Customized enketo-core to be used in hybrid Android app called Dristhi
Apache License 2.0
2 stars 10 forks source link

cascading logic not working #24

Closed MartijnR closed 10 years ago

MartijnR commented 10 years ago

seen on Tab2 both Chrome (yay! I can use a console!) and Internet App.

The main enketo.org forms still work, so it's probably a minor thing.

Now, where is that proprietary Samsung cable....

MartijnR commented 10 years ago

fe3f246c59f0286f86b0d26dd0478f17df35e6f4 fixed it @kirang20

kirang20 commented 10 years ago

Thanks for working on this @MartijnR. But have you deployed the fix on http://dristhi-dev.enketo.org, I can see the cascading selects issue happening on Internet app of Tab 3 (I am testing on Tab 3 and not Tab 2). But it works on Chrome on Tab 3 Also on Chrome on Tab 3, I can reproduce calculations and validation not working (try filling Woman's DOB as today, this should calculate age to 0 years and give an error message saying value is not valid, but that does not happen).

MartijnR commented 10 years ago

oh damn. Thx. :( I did deploy to dristhi-dev. Will check (on tab2 internet app - don't have tab3).

MartijnR commented 10 years ago

Cannot reproduce cascading select issue. It works when opening EC_Registration_EngKan on dristhi-dev.enketo.org on Internet App on Tab2. ([rant] Btw, my Tab2 has now become so slow, it takes about 2 minutes to type in a url in the browser successfully. Each key press has a 5 second lag. Wtf? It's totally unworkable. Will need to do a factory reset. [/rant])

Cannot reproduce validation issue either on same form.

@kirang20 I'm wondering if your browser still had old js files cached. Otherwise - and please let this not be the case - it may be specific to Tab3.

MartijnR commented 10 years ago

Well, guess what.... After a factory reset of my Tab2, the bugs are now present. Wonderful.

MartijnR commented 10 years ago

ab032628db6e50f2fa88be6b611730273117c9b2

MartijnR commented 10 years ago

So the issue was related to not using require.js dependency injection for the mocked modules. This meant that (erratically, sometimes) the formerly global variable modelXMLStr was not available when called in main.js. I have now removed all the inline scripts from template.html and am using dependency injection for the mocks. See the new main.js and the comments in the requirejs.config.

N.B. if we use the same naming convention for the built js file we can now probably leave template.html unchanged in ziggy.

N.B. it could be that removing document.write(androidContext.getForm()) from template.html affects performance. If androidContext is global you could bring this back and remove the new $( 'form.or' ).replaceWith( androidContext.getForm() ); from main.js.

kirang20 commented 10 years ago

Just tested and the issues have been fixed :). The form rendered and worked fine on Dristhi app!! But there is an issue with save and I have created a separate issue for that. I also tried replacing $( 'form.or' ).replaceWith( androidContext.getForm() ); with document.write(androidContext.getForm()), but once I did this change the form rendered properly but skip logic, calculations and validations broke. So I reverted it back to $( 'form.or' ).replaceWith( androidContext.getForm() );

Thanks a lot Martijn.

MartijnR commented 10 years ago

Yay!

If performance would improve (I don't know), I'm guessing you could perhaps create template.html dynamically by injecting the form html on the java side?