Closed vivienmast closed 7 years ago
A similar issue occurs for entity-list.component.ts.e.vm, and entity.ts.e.vm
thanks, good catch. Why setting to $temp ?
fixed, thanks!
Setting temp is just a hack to prevent Velocity from printing the return value of the add() method to the file. Not sure if there is a better way to do this, but it works... It might be better to give a variable name that makes this explicit such as $swallowReturnValue to make the code more readable.
In entity-detail.component.ts.e.vm, lines 8-12:
#foreach ($relation in $entity.xToOne.list)
#if(!$relation.to.type.equals($entity.model.type))
import {${relation.to.type}} from '../$relation.toEntity.model.var/${relation.toEntity.model.var}';
#end
#end
when creating an Entity with several X-to-One relations with the same target type (e.g., a PROJECT entity with a project manager and a deputy project manager which are both of Type USER), the component gets imported repeatedly, leading to a compile error.
I assume the same happens for Many-To-Many Relations (lines 13-16) though I didn't test that.
EDIT: Changing lines 8-12 to the following solved this for me (solution for lines 13-16 is probably analogous):
#set($imports = [])
#foreach ($relation in $entity.xToOne.list)
#if(!$relation.to.type.equals($entity.model.type) && !$imports.contains($relation.to.type))
import {${relation.to.type}} from '../$relation.toEntity.model.var/${relation.toEntity.model.var}';
#set($temp = $imports.add($relation.to.type))
#end
#end