-
Notifications
You must be signed in to change notification settings - Fork 14
Add stepper-layout
prop to OdkWebForm component for Collect-like experience
#329
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
Draft
spwoodcock
wants to merge
9
commits into
getodk:main
Choose a base branch
from
hotosm:feat/submission-stepper
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c669951
feat(FormGroup): make underlying FormPanel toggleable prop user confi…
spwoodcock 5d68959
feat(QuestionStepper): add stepper component enabled by OdkWebForm st…
spwoodcock 10e0522
feat(QuestionStepper): update stepper layout to be closer to ODK Collect
spwoodcock 87e4baa
fix(stepper): pass state to handleSubmit to match list view submit
spwoodcock 252ffe5
bug fix: recompute final step when number of steps change
DanielJDufour c0a747f
fix: tweak stepper web form setup after rebase to latest
spwoodcock 91567f7
test: add tests for stepper layout OdkWebForm logic
spwoodcock e232a30
fixed issue #2414 (part 1), replacing text with icons
DanielJDufour a56f9fc
Merge pull request #7 from DanielJDufour/hotosm/feat/submission-stepp…
spwoodcock 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,38 @@ | ||
<?xml version="1.0"?> | ||
<h:html xmlns="http://www.w3.org/2002/xforms" | ||
xmlns:ev="http://www.w3.org/2001/xml-events" | ||
xmlns:h="http://www.w3.org/1999/xhtml" | ||
xmlns:jr="http://openrosa.org/javarosa" | ||
xmlns:orx="http://openrosa.org/xforms/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<h:head> | ||
<h:title>Multi Step XForm</h:title> | ||
<model> | ||
<instance> | ||
<root id="minimal"> | ||
<first-question/> | ||
<second-question/> | ||
<third-question/> | ||
<meta> | ||
<instanceID/> | ||
</meta> | ||
</root> | ||
</instance> | ||
<bind nodeset="/root/first-question" type="string" required="true()"/> | ||
<bind nodeset="/root/second-question" type="string" required="true()"/> | ||
<bind nodeset="/root/third-question" type="string" required="true()"/> | ||
<bind nodeset="/root/meta/instanceID" type="string"/> | ||
</model> | ||
</h:head> | ||
<h:body> | ||
<input ref="/root/first-question"> | ||
<label>First question</label> | ||
</input> | ||
<input ref="/root/second-question"> | ||
<label>Second question</label> | ||
</input> | ||
<input ref="/root/third-question"> | ||
<label>Third question</label> | ||
</input> | ||
</h:body> | ||
</h:html> |
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ export interface PanelProps { | |
class?: string[] | string; | ||
labelIcon?: string; | ||
labelNumber?: number; | ||
toggleable?: boolean; | ||
} | ||
|
||
const props = withDefaults(defineProps<PanelProps>(), { | ||
|
@@ -21,6 +22,7 @@ const props = withDefaults(defineProps<PanelProps>(), { | |
class: undefined, | ||
labelIcon: undefined, | ||
labelNumber: undefined, | ||
toggleable: false, | ||
}); | ||
|
||
const panelClass = computed(() => [ | ||
|
@@ -31,7 +33,9 @@ const panelClass = computed(() => [ | |
const panelState = ref(false); | ||
|
||
const toggle = () => { | ||
panelState.value = !panelState.value; | ||
if (props.toggleable) { | ||
panelState.value = !panelState.value; | ||
} | ||
}; | ||
|
||
const menu = ref<Menu & MenuState>(); | ||
|
@@ -40,17 +44,25 @@ const toggleMenu = (event: Event) => { | |
menu.value?.toggle(event); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<Panel v-if="!noUi" :class="panelClass" :toggleable="true" :collapsed="panelState"> | ||
<Panel v-if="!noUi" :class="[panelClass, { 'toggleable-enabled': toggleable }]" :toggleable="toggleable" :collapsed="toggleable ? panelState : false"> | ||
<template #header> | ||
<div class="panel-title" role="button" @click="toggle"> | ||
<div v-if="toggleable" class="panel-title" role="button" @click="toggle"> | ||
<h2> | ||
<span class="chevron" :class="panelState ? 'icon-keyboard_arrow_down' : 'icon-keyboard_arrow_up'" /> | ||
<span v-if="labelNumber" class="label-number">{{ labelNumber }}</span> | ||
<span>{{ title }}</span> | ||
<span v-if="labelIcon" class="ml-2" :class="labelIcon" /> | ||
</h2> | ||
</div> | ||
<div v-else> | ||
<h2> | ||
<span v-if="labelNumber" class="label-number">{{ labelNumber }}</span> | ||
<span>{{ title }}</span> | ||
<span v-if="labelIcon" class="ml-2" :class="labelIcon" /> | ||
</h2> | ||
</div> | ||
</template> | ||
<template v-if="menuItems && menuItems.length > 0" #icons> | ||
<Button severity="secondary" rounded class="btn-context" :class="{ 'p-focus': menu?.overlayVisible }" icon="icon-more_vert" aria-label="More" @click="toggleMenu" /> | ||
|
@@ -129,9 +141,8 @@ h2 { | |
} | ||
|
||
:deep(.p-panel-content) { | ||
border-left: 2px solid var(--gray-200); | ||
box-shadow: none; | ||
margin-left: 10px; | ||
border-radius: 0; | ||
padding: 0 0 0 1.5rem; | ||
} | ||
|
||
|
@@ -140,6 +151,11 @@ h2 { | |
} | ||
} | ||
|
||
.toggleable-enabled :deep(.p-panel-content) { | ||
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. |
||
border-left: 2px solid var(--gray-200); | ||
border-radius: 0; | ||
} | ||
|
||
.content-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
|
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 |
---|---|---|
|
@@ -45,7 +45,7 @@ const isControlNode = (node: NonStructuralNode): node is ControlNode => { | |
<template v-for="node in nodes" :key="node.nodeId"> | ||
<template v-if="node.currentState.relevant"> | ||
<!-- Render group nodes --> | ||
<FormGroup v-if="isGroupNode(node)" :node="node" /> | ||
<FormGroup v-if="isGroupNode(node)" :node="node" toggleable /> | ||
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. I set the default for the prop |
||
|
||
<!-- Render repeat nodes --> | ||
<RepeatRange v-else-if="isRepeatRangeNode(node)" :node="node" /> | ||
|
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.
Adding the
toggleable-enabled
class dynamically