refactor: apply recursion to FilterBlock
#279
Merged
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.
Refactored
FilterBlock
in order to completely generalize its usage and allow for the long awaited separation of "Opção UMinho" subjects from the regular ones and the organization of the subjects of each profile in the master's degree in its own category.This refactor was made possible by using a recursive component,
RenderLayer
, that calls itself for each sublayer. This component receives information in the following specification, that itself is also recursive:The stopping condition of the recursive component is reaching a layer that has
checkboxes
specified. This allows us to have whatever amount of nested layers we want and even mix sublayers with checkboxes. For example, this is what the structure looks like for 1st year, 1st semester:Notice how we have an extra sublayer on the first semester and not on the second one. This data structure gives us full liberty of what to place in the filters, what titles to give each specific layer, etc., which didn't happen before.
There were also improvements to the checkbox toggle functions so that they were generalized for events and shifts, etc.
The file went from 400 lines to just under 200 :D 🚀
Thanks to the generalization, Select All is now available for everything so we can now select all shifts of a specific subject, for example.