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: export import standard formats #193

Conversation

maharshivpatel
Copy link
Collaborator

@maharshivpatel maharshivpatel commented Mar 15, 2024

  • 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.

depends on : frappe/frappe#25752

- 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.
@maharshivpatel maharshivpatel force-pushed the feat-import-export-standard-format branch from 3f8c019 to 02a4ef7 Compare March 15, 2024 11:04
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.
@maharshivpatel maharshivpatel force-pushed the feat-import-export-standard-format branch from f0b4644 to b2ab4c7 Compare March 17, 2024 21:49
- 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
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.
@maharshivpatel maharshivpatel force-pushed the feat-import-export-standard-format branch from db5899c to bdbbd2c Compare April 1, 2024 13:09
@maharshivpatel
Copy link
Collaborator Author

closing as merging in develop branch #208

@BaaridunNasr
Copy link

@maharshivpatel

Does this happen only during updates, when new versions of apps are installed? Or perhaps even during migration?

@maharshivpatel
Copy link
Collaborator Author

@PhantomKunai only on install

@BaaridunNasr
Copy link

BaaridunNasr commented May 23, 2024

Hmm, I think adding a migrate hook would be worth it, wouldnt it? So that people can add formats to their current app and not worry about having to reinstall it.

Edit : Performing a bench update where apps are re-installed has no effect. Print formats are not imported.

@BaaridunNasr
Copy link

Perhaps this is getting messed up because of install order? For me print_designer installs first.

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

Successfully merging this pull request may close these issues.

2 participants