Skip to content
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

Coalesce RepeatInstance and Group if group is the only child of RepeatInstance #81

Open
sadiqkhoja opened this issue Apr 16, 2024 · 0 comments
Labels

Comments

@sadiqkhoja
Copy link
Contributor

Current ui-vue handles this logic. This should be move inside the engine.

Ref: #69 (comment)

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;
	}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant