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

add csv and xlsx formats #61

Merged
merged 43 commits into from
Apr 30, 2024
Merged

add csv and xlsx formats #61

merged 43 commits into from
Apr 30, 2024

Conversation

ETLaurent
Copy link
Contributor

@ETLaurent ETLaurent commented Apr 2, 2024

Summary

Untie gzip method to build something more agnostic in order to be able to add other formats (such as formats which do not have multiple compressed files, but just a simple export file, like a CSV file for instance).

Add CSV format.
XLSX is added via a separate module: https://github.com/apostrophecms/import-export-xlsx (see PR).

Non-exhaustive list of the work done to separate concerns:

  • no apos instance in format files
  • no format specific stuff inside import.js and export.js files
  • usage of callbacks to deal with apos-specific attachment business in the gzip format and format-specific files handling on apostrophe side (ie: concerns are separated)
  • gzip import function handles the extraction AND the deletion of the archive on its own

Other improvements:

  • better handling of the streams and their error events
  • better handling and clarification of the double format.input() call, whether it is called with overrideLocale: true or not
  • refactor remove functions into one (except in gzip format where the remove function is standalone)
  • add logs:
    • on import and export side (prefixed by [import] and [export])
    • on formats side ([csv], [gzip], [xlsx])
  • add documentation to explain how add and register new formats

What are the specific steps to test this change?

For example:

  1. Run the website and log in as an admin
  2. Open a piece manager modal and select several pieces
  3. Click the "Archive" button on the top left of the manager and confirm that it should proceed
  4. Check that all pieces have been archived properly

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

canImport(req, docType) {
return self.canImportOrExport(req, docType, 'import');
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to import.js

canImport(req, docType) {
return self.canImportOrExport(req, docType, 'import');
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from export.js

@ETLaurent ETLaurent changed the title add csv format add csv and xlsx formats Apr 15, 2024
@ETLaurent ETLaurent marked this pull request as ready for review April 29, 2024 17:38
@ETLaurent ETLaurent merged commit 35ec804 into main Apr 30, 2024
9 checks passed
@ETLaurent ETLaurent deleted the pro-5809-add-csv-format branch April 30, 2024 12:45
@ETLaurent
Copy link
Contributor Author

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