Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Using document.write(androidContext.getForm()) in template.html #36

Open
kirang20 opened this issue Feb 24, 2014 · 11 comments
Open

Using document.write(androidContext.getForm()) in template.html #36

kirang20 opened this issue Feb 24, 2014 · 11 comments

Comments

@kirang20
Copy link
Contributor

Hi Martijn,

We tried inlining document.write(androidContext.getForm()); in template.html (as before) but we cannot get forms to work correctly after that.

Some issues we are facing:

  • On Browser, this does not work as androidContext object is not available globally. We tried to work around this issue by using mocks (by using require('androidContext')), but we get the below error:
    Module name "androidContext" has not been loaded yet for context: _. Use require([]).
    Is this because RequireJS is not yet loaded?
  • On Dristhi app, the form loads correctly but skip logics, calculations and validations do not work.

Any suggestions (if you need, we can send you an APK with these changes)?

@MartijnR
Copy link
Member

Thanks @kirang20

yes, we probably need to un-requirjsify androidContext.mock.js, add it as a script to template.html (and then only set this global variable if it doesn't exist)

since it worked previously, we should be able to detect when the inline html has been added to the DOM, and wait for that before instantiating the new Form() in main.js.

I can have a look as well, but it will be next week probably.

@kirang20
Copy link
Contributor Author

I can wait till next week :). Sorry, Dristhi Training/Research is starting in March and we there are lot of things to complete by then. So thanks for the help.

@MartijnR
Copy link
Member

Ah, well, I'll try to look at it sooner! Otherwise, we can leave it as-is for the training/research, right?

fwiw, what I'm working on this week, may very well be more significant in terms of performance.... :). Let's temper expectations though. Also, the new enketo-core includes a lot of css changes, so merging is going to take time too.

@MartijnR
Copy link
Member

EC_Registration is the slowest form in Dristhi right?

@kirang20
Copy link
Contributor Author

Yes, it is okay for the research/training to start without this change (this is a nice to have feature not a must have).
Not sure which is the slowest but some of the slow forms are:

  • PNC Registration - Out of Area (most likely due to length, cascading selects and repeat. This may be the slowest form)
  • EC Registration, ANC Registration - Out of Area (most likely due to length and cascading selects)
  • Delivery Outcome (most likely due to length and repeat)

@MartijnR
Copy link
Member

@Kiran20 I think I may have nailed bringing back the inline script now... It was indeed pretty hard...

I had to disable ziggy in the web view. This should happen automatically. If you have trouble using this in Drishti, these lines may not work: https://github.com/MartijnR/enketo-dristhi/blob/inline_form_injection/src/js/FormDataController.js#L3-L6

If it works, I'm curious if this speeds up loading.

I kept this in a separate branch (inline_form_injection)

cc @dpapathanasiou @prabhasp

@MartijnR
Copy link
Member

@kirang20 just checking if you've seen this. Once you confirm it works, I'll merge it into master

@kirang20
Copy link
Contributor Author

As I said in another comment, we did merge this. Forms are working but I
did not get time to check the performance, I will get back to you soon
about performance.

On Wednesday, March 19, 2014, Martijn van de Rijdt notifications@github.com
wrote:

@kirang20 https://github.com/kirang20 just checking if you've seen
this. Once you confirm it works, I'll merge it into master

Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-38060460
.

Regards,
Kiran
Nagu naguta nali nali ene agali

@MartijnR
Copy link
Member

Cool! I'll merge the branch. Thx

@kirang20
Copy link
Contributor Author

Extremely sorry Martijn, I did not realise that this change was in a different branch (this is what juggling two or three tasks at the same time does!). So this was never merged onto Dristhi app, as we only updated from the master branch.

We did merge it today. We are finding that the forms are much slower now (EC registration form is taking close to 8 seconds more to load)!
Not sure if it is due to this change alone. Thoughts?

@kirang20 kirang20 reopened this Mar 20, 2014
@MartijnR
Copy link
Member

No worries. It forced me to learn how to reverse a merge. Interesting it was slower! So either inline is slower after all, or I made some mistake.

If the forms seemed otherwise fully functional, I think inline injection may be slower after all.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants