1 minute read

Summary

This week I started to work in the support for composition of arbitrary depth. That is, the user should be able to include subtrees inside other subtrees without any limitations.

Frontend support

This time, I began with support for subtrees in the TreeEditor, as all the endpoints for managing them were already set up.

After discussing it with collaborators, I concluded that using modals to handle composition only introduced unnecessary complexity, making it difficult to implement multiple composition levels.

Instead, I decided to change the contents directly in the main tree editor. Now, when a user clicks on a subtree, the frontend requests the new graph and updates the main editor, displaying the name of the current subtree being viewed.

However, this approach required tracking the tree hierarchy to ensure smooth navigation. If a user clicks into a nested subtree, they should be able to return along the same path.

For that reason, my main contribution this week was to implement the necessary functions in the frontend to manage this state. I implemented this with an array containing the different subtree names in hierarchical order. Different functions in the editor were in charge of properly adding or removing subtrees. As for the moment the user cannot move more than one level at a time, the implementation was moderately straightforward.

Backend support

The subtree management endpoints work without any modifications. The subtrees are stored under the trees/subtrees folder in the project folder.

However, I realized that the tree generation functionality has two big issues for the multilevel composition:

  • No easy way to call the code N-times to account for all the multilevel subtrees. With the current implementation, even if it is easy to detect the depth of the tree, the tree generator wouldn’t work.
  • The translation of subtree’s JSON files to XML is executed before the tree generation. As new trees may be discovered at N-depth in the tree, this would require translating and generating at the same time, obfuscating the business logic.

Contributed PRs