-
Notifications
You must be signed in to change notification settings - Fork 82
fix(web-forms#883): allow users to recover from xpath errors #1908
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
Open
garethbowen
wants to merge
42
commits into
getodk:master
Choose a base branch
from
garethbowen:883-node-value-result-type
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
a724843
wip
garethbowen 6c8c970
more progress
garethbowen adb1328
everything works
garethbowen 9f25e79
fix tests
garethbowen 48ad33a
fix some tests
garethbowen 59de05e
lint
garethbowen e526211
fix tests and isSelfRelevant inside scope
garethbowen 29a1254
make xforms-engine evaluator
garethbowen dea8517
fix test helpers
garethbowen a4f02e5
resolve todos
garethbowen 05239c9
fix test
garethbowen 55e5ada
improve and translate error message
garethbowen 4edbfa6
changeset
garethbowen 02752b9
lint
garethbowen af884f9
revert format date to throw again
garethbowen 6c9a8f6
cleanup
garethbowen 9c73af9
check for violations in groups, repeats, attributes
garethbowen a7527fc
use property names to hold different errors
garethbowen d475771
fix pagination blocking
garethbowen 0f0cbe8
replace the actual root element rather than hardcoding /data
garethbowen 28b953a
fix error message
garethbowen 040b6e8
fix tests
garethbowen ed46eef
don't forget about node attribute violations
garethbowen 4b520a8
use correct node for attribute violations
garethbowen 6e5c5fb
be more reactive
garethbowen 19dca79
lint warnings
garethbowen 67d9f6e
fix some tests
garethbowen 1068f27
more testas
garethbowen 6cb72f4
tests
garethbowen cfe1831
fix smoke test
garethbowen 9647a29
don't spam example.com
garethbowen 4cf9e96
revert change
garethbowen 9d7a39e
add memo for value
garethbowen 3b128b6
various cleanups and a performance improvement
garethbowen cd615b9
cache errors in memo
latin-panda 67682a5
proposal: cache expression errors in the memo
garethbowen fbc9cb6
use result minimally
garethbowen 36a44ae
missed one call
garethbowen bc856f1
add tests
garethbowen 0311bc2
more tests
garethbowen a826b71
remove error fn on accessor
garethbowen fe73e46
catch errors in itemset labels
garethbowen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@getodk/xforms-engine": minor | ||
| "@getodk/web-forms": minor | ||
| "@getodk/xpath": minor | ||
| --- | ||
|
|
||
| Improved error messages for invalid forms. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,10 +322,28 @@ provide(REVEAL_VIOLATIONS, revealViolations); | |
| // It returns violations for questions the user has seen. | ||
| const revealedViolations = computed(() => { | ||
| const violations = state.value.root?.validationState.violations ?? []; | ||
| const nonErrorViolations = violations.filter((violation) => violation.violation.condition !== 'error'); | ||
| if (submitPressed.value) { | ||
| return violations; | ||
| return nonErrorViolations; | ||
| } | ||
| return violations.filter(({ nodeId }) => touchedQuestions.has(nodeId)); | ||
| return nonErrorViolations.filter((violation) => touchedQuestions.has(violation.nodeId)); | ||
| }); | ||
|
|
||
| const errorViolations = computed(() => { | ||
| const violations = state.value.root?.validationState.violations ?? []; | ||
| const grouped = new Map<string, string[]>(); | ||
| violations.forEach(error => { | ||
| const key = error.violation.condition === 'error' && error.violation.message; | ||
| if (!key) { | ||
| return; | ||
| } | ||
| const fieldReferences = grouped.get(key) ?? []; | ||
| const rootNodeName = state.value.root?.definition.nodeset; | ||
| const fieldReference = error.reference.replace(rootNodeName + '/', ''); | ||
| fieldReferences.push(fieldReference); | ||
| grouped.set(key, fieldReferences); | ||
| }); | ||
| return grouped; | ||
| }); | ||
|
|
||
| const validationErrorMessage = computed(() => { | ||
|
|
@@ -339,7 +357,11 @@ const showValidationError = computed(() => { | |
| if (errorBannerDismissed.value) { | ||
| return false; | ||
| } | ||
| return !!(validationErrorMessage.value.length || geolocationErrorMessage.value?.length); | ||
| return ( | ||
| !!validationErrorMessage.value.length || | ||
| !!geolocationErrorMessage.value?.length || | ||
| !!errorViolations.value.size | ||
| ); | ||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
|
|
@@ -389,6 +411,13 @@ onUnmounted(() => { | |
| > | ||
| <IconSVG name="mdiAlertCircleOutline" variant="error" /> | ||
| <ul class="form-error-text-wrap"> | ||
| <li v-for="[message, references] in errorViolations" :key="message"> | ||
| {{ t('odk_web_forms.evaluation.error', { | ||
| message, | ||
| fields: references.join(', '), | ||
| count: references.length | ||
| }) }} | ||
| </li> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most common case is a single error violation, potentially impacting multiple fields, so I've optimised the UX for that case. |
||
| <li v-if="validationErrorMessage?.length"> | ||
| {{ validationErrorMessage }} | ||
| </li> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 haven't tested it, but I think
errorBannerDismissedshould be set tofalsehere so that new evaluations with errors display the banner.Uh oh!
There was an error while loading. Please reload this page.
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.
We don't currently do that for other violations until you hit the next page or submit button, right? I feel like it would just be annoying if you have explicitly dismissed it for it to pop up again, even if now the message is different.