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

Implement a "Download to CSV" feature #1420

Closed
4 of 6 tasks
entrotech opened this issue Aug 9, 2023 · 5 comments · Fixed by #1508, #1549 or #1550
Closed
4 of 6 tasks

Implement a "Download to CSV" feature #1420

entrotech opened this issue Aug 9, 2023 · 5 comments · Fixed by #1508, #1549 or #1550
Labels
enhancement Release Note: Shows as visual or user experience Enhancement level: medium p-feature: Final Summary Page pg 5 /calculation/5 priority: MUST HAVE role: front-end Front End Developer size: 3pt Can be done in 13-18 hours
Milestone

Comments

@entrotech
Copy link
Member

entrotech commented Aug 9, 2023

Overview

We want users to have the ability to download a CSV file for one or more calculations - one row per calculation. To start, this will be accessible by pressing a button on the last page of the wizard, which will produce a CSV with column headings and one row of data. IMPORTANT: The code to implement this feature must not reside in the Wizard Components, but should be implemented as a function that can be called from anywhere in the application with a single method that is passed an array of one or more calculationId values, and downloads a single CSV file with one row per calculation in the array.

Action Items

  • Add a "Download" button to the TDM Calculation Summary page of the wizard. The design should look like the existing "Print Summary" button, with a download icon.
  • When pressed, the button should create a CSV file. The CSV format can have a heading of "TDM Calculation Project Summary" on the first row, a second row with the caption "Date Printed" and the current date/time. The third row will be blank, The fourth row will have "column headings", and the subsequent row will have the data for the current calculation. For downloading multiple projects, the subsequent rows will have one row per additional project (though that will only come into play when the feature is added to the My Project page).
  • For scalar data (strings, numbers, etc.), there will be one column with a column heading that corresponds to the label from the PDF print format. So the first few will be "Project Name", "Address", "Parcel #", "Building Permit #", and so on. The easiest way to get a complete list of the columns for the Project Name and Project Details sections is probably to create a sample project where every possible input field is filled in with data. For strategies, some of the strategies are multiple choice. In these cases, a separate column will exist for each possible choice. For example, there will be two columns for the Encouragement Program strategy, one with the column heading "Encouragement Program - Education, Marketing and Outreach" and a second with the heading "Encouragement Program - Voluntary Behavior Change Program". The selected option will have a "Y" in the project's row.
  • I created a project using the ladot@dispostable login called "Kitchen Sink Project" that has almost all possible fields selected (except "Mandatory Trip Reducction" and "Cash-out" strategies, since they are mutually exclusive with other strategies). If you look and PDF print-out from this project, it shows most of the possible inputs and results on the Summary.
  • You can use the service on the client project.service.js called getById to get all the project data you need. For multiple projects, you would have to loop over all the ids in the array, but we could eventually create another endpoint to get all the projects at once.
  • The CSV file format needs to be documented and the document delivered to the CLATS team (Mony Patel, Michelle Leung and Jason Kwok).

Resources/Instructions

@entrotech entrotech added enhancement Release Note: Shows as visual or user experience Enhancement role: front-end Front End Developer level: medium priority: MUST HAVE p-feature: Final Summary Page pg 5 /calculation/5 size: 3pt Can be done in 13-18 hours labels Aug 9, 2023
@jeffmchang
Copy link
Member

UPDATE

Did some research on available libraries that we could use to implement the CSV download functionality. Looking to use either react-csv or papaparse I'm leaning towards react-csv but we'll have to see which library is more compatible.

NEXT STEPS

Need to break down further how the 'Download Summary' is passing in rules to be sent to the PDFprint functionality. Will most likely have a similar system to the react-csv in terms of passing the information as an object and simply connecting the data to the react-csv component.

@jeffmchang
Copy link
Member

UPDATE

Decided to use react-csv, so far my current download button downloads the ENTIRE project with all its details from all 5 pages. Looking to somehow isolate the rules that specifically reside in the component (or summary page). react-csv has some specific asks that require me to filter data and the types that we pass in. I might need to create a set of rules that specifically identify the needed details from the summary page and attach it to the data attribute of the CSVLink component.

BLOCKER

Testing out different ways to reuse the rules from the ReactToPrint component, rather than creating a whole new set just for the CSVLink. Other than that, no other blockers.

@ZekeAranyLucas
Copy link
Member

AFAICT, we don't currently support multi-select in the projects page, so I would separate those tasks into a new issue.

@entrotech
Copy link
Member Author

Select the Export as CSV menu option to get data and display crude results

image

Temporary Dialog showing rough results:
image

@entrotech
Copy link
Member Author

@bonniewolfe @ZekeAranyLucas @Biuwa @Parisajf Work on extracting the columns we need from the project and rules, and ordering them in a reasonable fashion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Release Note: Shows as visual or user experience Enhancement level: medium p-feature: Final Summary Page pg 5 /calculation/5 priority: MUST HAVE role: front-end Front End Developer size: 3pt Can be done in 13-18 hours
Projects
Status: Released
4 participants