-
Notifications
You must be signed in to change notification settings - Fork 19
feat(#122): add support for jr:preload #571
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 9ff6c01 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| const input = container.locator('input'); | ||
| const input = this.page.locator( | ||
| `.question-container:has(.control-text label:text-is("${label}")) input` | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is within the margin of error but in my testing speeds up the suite by around 4%
| export interface OdkWebFormsProps { | ||
| readonly formXml: string; | ||
| readonly fetchFormAttachment: FetchFormAttachment; | ||
| readonly preloadProperties?: PreloadProperties; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now optionally pass in properties in to the vue component, specifically the users email, phone number, and username. Additionally you can pass in the deviceid - if you don't then one will be generated for you.
| email: 'fake@fake.fake', | ||
| phoneNumber: '+1235556789', | ||
| username: 'nousername', | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed something for the e2e testing to work with.
| return id; | ||
| } | ||
| const deviceId = DEVICE_ID_PREFIX + crypto.randomUUID(); | ||
| localStorage.setItem(DEVICE_ID_KEY, deviceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default this will get generated and stored in the browser. However it won't get used unless you specify the bind in the xform. I think this is acceptable from a tracking perspective, because the part that goes to the server is opt-in.
|
|
||
| return rest; | ||
| triggerXformsRevalidateListeners() { | ||
| this.listeners.forEach((listener: XformsRevalidateListener) => listener()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using listeners in this way feels slightly awkward. An alternative would be to iterate through the binds looking for revalidate actions which would be cleaner but be a performance hit. I'm open to suggestions here...
Closes #122
I have verified this PR works in these browsers (latest versions):
What else has been done to verify that this works as intended?
Testing.
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Introduces new functionality.
Do we need any specific form for testing your changes? If so, please attach one.
From this PR: packages/common/src/fixtures/test-javarosa/resources/preload.xml
What's changed
When loading the form, check for bind preloads, and set the value as appropriate.
When preparing for submission, check for
endbinds and set the value.