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

feat: recursive dynamic containers #224

Merged

Conversation

maharshivpatel
Copy link
Collaborator

@maharshivpatel maharshivpatel commented Apr 9, 2024

  • Current Logic for dynamic containers is not recursive. It loops through the elements and compute possible rows then it loops again and compute possible columns.

  • This was less efficient, less flexible, and not recursive. Impact will be more apparent when we have multi pages and 100s to Elements.

  • Now, I have added recursive logic to handle nested dynamic containers. current implementation have 2 functions computeRowLayout and computeColumnLayout. this functions that call each other to create a recursive layout until it's not possible. first, we compute main layout where we split it into 3 sections ( header, body, footer). we run these functions on each of these sections and save the layout.

    In theory, we can set dynamicHeight for any element as long as it's not overlapping.

Instead of computing layout and then checking for overlaps, we can check for overlaps while computing layout.
also, fixed bug in auto header / footer height calculation causing overlapping error.
added 1px on both sides ( top/bottom ) of the table element.
moved computeRowElementDimensions & computeColumnLayout function calls inside computeRowLayout.

this is cleaner code and will be better design to allow recursive layout parsing.
- Current Logic for dynamic containers is not recursive.
    It loops through the elements and compute possible rows then it loops again and compute possible columns.

- This was less efficient, less flexible, and not recursive.
    Impact will be more apparent when we have multi pages and 100s to Elements.

- Now, I have added recursive logic to handle nested dynamic containers.
    current implementation have 2 functions computeRowLayout and computeColumnLayout.
    this functions that call each other to create a recursive layout until it's not possible.
    first, we compute main layout where we split it into 3 sections ( header, body, footer).
    then we run these functions on each of these sections and save the layout.

    In theory, we can set dynamicHeight for any element as long as it's not overlapping.
if rectangle is only ( basically no element is overlapping with it) or last element inside row or column, row and column layout is computed for children.
- if rectangle is overlapping with other element and we make it relative placement of other element will be broken so for now it is set to compute layout as per above condition

created patch that will convert isDynamicHeight Boolean to heightType with value "fixed" or "auto".

updated default objects and  control in Properties Panel.

changed schema version number to 1.2.0 as schema is changed and is incompatible with old formats (1.1.0)  we need to handle old formats.

updated jinja render template
- modified relative_containers to be recursive
- updated all templates to use heightType properties
- updated logic to include min-height
- added logic for backwards compatibility.
- also introduced dynamic height for static text if it has parseJinja enabled.
- updated rectangle template to be dynamic height

misc:
    is_older_schema now handles really old formats which don't have schema_version
    reverted styles for relative column
added logic to run patches on output print_formats that are used by jinja when required
@maharshivpatel maharshivpatel marked this pull request as ready for review May 1, 2024 02:09
@maharshivpatel maharshivpatel merged commit 574b7f8 into frappe:develop May 1, 2024
1 check passed
@maharshivpatel
Copy link
Collaborator Author

🎉 This PR is included in version 1.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant