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

refactor: apply recursion to FilterBlock #279

Merged
merged 5 commits into from
Jan 31, 2025
Merged

refactor: apply recursion to FilterBlock #279

merged 5 commits into from
Jan 31, 2025

Conversation

diogogmatos
Copy link
Member

@diogogmatos diogogmatos commented Jan 29, 2025

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.

image image

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:

export interface Layer {
  title: string;
  sublayers?: Layer[];
  checkboxes?: CheckBox[];
}

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:

{
   title: "1ˢᵗ year",
   sublayers: [
     {
       title: "1ˢᵗ semester",
       checkboxes: getCheckBoxes()[0].slice(0, 5),
       sublayers: [
         {
           title: "Opção UMinho",
           checkboxes: getCheckBoxes()[0].slice(5),
         },
       ],
     },
     {
       title: "2ⁿᵈ semester",
       checkboxes: getCheckBoxes()[1],
     },
  ],
}

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.

@diogogmatos diogogmatos added the enhancement New feature or request label Jan 29, 2025
@diogogmatos diogogmatos self-assigned this Jan 29, 2025
Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for cesium-calendarium ready!

Name Link
🔨 Latest commit 4f4a2ba
🔍 Latest deploy log https://app.netlify.com/sites/cesium-calendarium/deploys/679c26eabed1e50008cc2345
😎 Deploy Preview https://deploy-preview-279--cesium-calendarium.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@nunom27 nunom27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!!

@diogogmatos diogogmatos merged commit 98f9896 into master Jan 31, 2025
5 checks passed
@diogogmatos diogogmatos deleted the dm/filters branch January 31, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:high
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants