Coalesce RepeatInstance and Group if group is the only child of RepeatInstance
- Dominant language
- TypeScript
- Stars
- 38
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
Current `ui-vue` handles this logic. This should be move inside the engine.
Ref: https://github.com/getodk/web-forms/pull/69#discussion_r1556503117
```
const label = computed(() => {
// It has just one child and that is a group with label
// then we use label of that group
if( props.instance.currentState.children.length === 1 &&
isGroup(props.instance.currentState.children[0]) &&
props.instance.currentState.children[0].currentState.label
) {
return props.instance.currentState.children[0].currentState.label?.asString
}
// Use RepeatRangeNode label if it's there
// TODO/sk: use state.label.asString
if(props.instance.parent.definition.bodyElement.label?.children[0]?.stringValue){
return `${props.instance.parent.definition.bodyElement.label?.children[0].stringValue} ${props.instanceIndex + 1}`;
}
return `Repeats ${props.instanceIndex+1}`;
});
const children = computed(() => {
// It has just one child and that is a group
// then we use its children - essentially coalesce RepeatInstance and Group into one.
if(props.instance.currentState.children.length === 1 && isGroup(props.instance.currentState.children[0])){
return (props.instance.currentState.children[0] as GroupNode).currentState.children;
}
else{
return props.instance.currentState.children;
}
});
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the existing RepeatInstance label and children handling in ui-vue, then trace the corresponding engine representation. Move the coalescing behavior into the engine so the UI no longer owns it, and verify that RepeatInstance labels and children retain the behavior shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100