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

chore: Merge develop to master #214

Merged
merged 52 commits into from
Apr 5, 2024
Merged

chore: Merge develop to master #214

merged 52 commits into from
Apr 5, 2024

Conversation

maharshivpatel
Copy link
Collaborator

No description provided.

maharshivpatel and others added 30 commits January 18, 2024 15:05
This property is how user can configure if some element should have fixed height or should be dynamically adjusted.
This will not ensure that it will have dynamically calculated height as it will depend on several factors
This is just to give them control to choose between static and dynamic height.
childernSave, childernLoad & handleDynamicContent can be used at other places so converted them to actions.
now, when we save Print Format, data that jinja template uses will be saved in print_designer_print_format field.

misc - updated default for isDynamicHeight to False.
display: inline-flex is not supported by wkhtmltopdf.
It was added in hope that we will make it work somehow in the future.
This commit removes the globalStyles rectangle style as it was conflicting with relative containers.
Added function in JS and Python to check if schema version in format is older than current schema version.
This is useful for checking if a schema update is needed or handle different logic based on version.

misc: bumped version to 1.1.0
-   added isElementOverlapping function takes elements
    and checks if any other element is overlapping with it or not.

-   created checkUpdateElementOverlapping util function when called
    it will loop over all the parent level elements and
    check and update any element's isElementOverlapping property if it is changed.

-   updated isDynamicHeight in propertiesPanel to show only when
    element is table or dynamicText and isElementOverlapping is false.

-   Subscribed to ElementStore in onMounted of canvas to call checkUpdateElementOverlapping
    when any new elements are added.

-   when any element is deleted, dragged or resized using mouse or keyboard shortcuts
    run checkUpdateElementOverlapping
-   added .error class which basically makes text red
    if dynamic text includes "page_info" and is in body container.
-   computeLayout function loops over this.Elements
    divides them into possible rows ( dynamic containers ) based on their start and end locations.
    returns three arrays, header, body ( can have multiple containers ) and footer.

-   separated logic into smaller functions and changed structure for save a bit for dynamic containers.
    -   checkIfAnyTableIsEmpty
    -   handleHeaderFooterOverlapping
        -   autoCalculateHeaderFooter
    -   cleanUpElementsForSave
        -   checkIfPrintFormatIsEmpty
        -   childrensSave
-   calculate dimensions of the container based on the childerns dimensions
-   create wrapper element for the container that will have position relative
    height will be decided based on it's childerns condition
-   save this data in print_designer_print_format that will be used by new jinja template.
-   removed auto generated table element
-   moved settings load logic to a separate function
    to avoid race condition and simplify the code
-   refactored jinja template and separated it to smaller files for maintainability
-   added concept of relative containers that are rendered on main/parent array loop.
-   added logic to decide if a container has dynamicHeight or not
-   If main/parent container's isDynamicHeight = true
    if children's type is dynamic-text or table, it will not set height property and set margin-top instead of top property
    ( top property's space is not calculated as part of parent's DOM height, so it will not work as expected )
-   If main/parent container's isDynamicHeight = false
    logic will be same as before. it will be inside a dynamic container.

-   new template is not compatible with old schema ( formats created/updated for this PR ).
-   if print_formats schema version is less then 1.1.0, it will use old template.

-   misc: removed duplicate code and called get_print_format_template.
-   update page header/footer height with margin before computing layout
-   update startY of header elements with margin
-   update footer conditional to account for margin
for a long time, print designer formats only looked correct in pdf, not in print-view.
this commit fixes print-view to look similar to print designer designs
of-course repeating header/footer won't work in print-view, but that's a different issue

fixes #191
use css comments syntax :D
reason to do this is scroll affects getBoundingClientRect values.
we also have the values already saved so no need to calculate again.

side effect:
Its faster than the old implementation, in real world no noticeable difference.
If someday someone creates 1000 page elements, this will be faster 10 ms XD.
old: 83.455810546875 ms
new: 73.48681640625 ms
As in framework we recently started using cssparser to parse css files,
previous css style fix was broken and PDF options parsing wasn't working.
changed the approach so it will work in both pdf and print-view.
This is continuation of the #205 PR.
There are some issue with PDF generated by table component and I am working on it.
I will update the PR once I fix the issue.
on save of older schema show dialog and make copy of print format
it will keep making copy with incremented version number
( Copy 1 ), ( Copy 2 ), ( Copy 3 ) etc.

misc: added try catch block in removing deleteRule
- Added Custom Field for Print Designer Template Location
- Added Hook to define folder location for Print Designer Templates
( location fallbacks to default_templates if not defined in hooks for export )

- when print designer is installed, loop over all apps and import standard templates.
- when any new app is installed, check if it has print designer templates and install them.
    - it also checks print_designer app for new templates and installs them.

- Modified export functionality for print formats that are made using print_designer.
    - it will export print format in custom directory if defined in hooks else in default_templates folder.
    - user / developer can define app where print format should be exported in print_designer_template_app field.
added new custom field "print_designer_preview_img" to store the format preview image.
added html2canvas
on save
- make copy of main-container dom and convert to canvas using html2canvas.
- create file instance and pass blob to it from canvas.toBlob()
- send file to /api/method/upload_file , client side function is just modified version of FileUploader.
- remove old format preview image after new one is uploaded successfully.

This will be used to display the format preview in the format Grid View.
dynamic text value is fetched from db so there is no need to save it as part of format.
we have to consider and load metaFields from db so remove it from Print Format JSON.
- if standard is set to true, remove static file urls as it can't be used across site.
- only try to load file if url value exists for the file.
    - This doesn't check if image file exists or not.
As standard field returns Yes or No, update the logic to compare string instead of boolean.

update preview image url in print_designer_preview_img field
maharshivpatel and others added 22 commits April 2, 2024 02:10
First check if table exists before trying to load childfield meta
Copy the image to the export directory so that it can be used for preview while installing the format.
when print_designer format is saved in developer mode and format is standard.
preview images and " File " document is exported as per the location defined in the selected app's hook.
after install once the formats are imported, copy the file to private/files folder and update the file path in the format.
After merging relative containers when this in this PR conflicts were manually resolved.
There were some incorrect conflict resolutions, which are fixed in this commit.

Also, removed multiple updates for print format document caused by updating file_url.
instead get latest file_url from the file document else set to null.
while refactoring the code, by mistake it was changed to an array. This commit fixes it.
unintended cssRules were removed by mistake so until that can be fixed removing deleteRule code.
image upload sometime happen before the format is saved and sometimes after.
handled both cases based on isFormatSaving flag.
when we create copy when user updates the formats with old schema.
it was implicitly setting the name with copy + number suffix.
now we set that name as default and prompt user if they want to change the name.
In dynamic content new line / `<br>` was rendering even if value was empty.
which leaves empty line in the content. this commit fixes that for old_print_format jinja template.

also, added missing jinja code for suffix in new template.
wkhtmltopdf have issue with table header overlapping if it is inside a div with display: inline.

wkhtmltopdf doesn't support flex but it has some old experimental support for https://developer.mozilla.org/en-US/docs/Web/CSS/box-align

As it doesn't support proper implementation of flex it is not used anywhere in print designer.

This PR uses display: -webkit-box; to fix the particular issue.

hopefully can be used to add more features in the future.
This was used to debug the layout while developing the feature.

There will be feature where user can modify/configure the layout soon :D
It will be added in a separate PR so not needed as of now.
@maharshivpatel maharshivpatel merged commit 3d84e3b into main Apr 5, 2024
2 checks passed
@maharshivpatel
Copy link
Collaborator Author

🎉 This PR is included in version 1.1.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.

1 participant