Angular: grid cells that use a cellTemplate aren't included in CSV or Print

Bug #1835982 reported by Jane Sandberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned

Bug Description

Translating a TODO item into a launchpad bug, so that it is easier to find and discuss. :-D

TODO item here: https://github.com/evergreen-library-system/Evergreen/blob/b64c3db638247cd6c16fdc521311c3fed0dd9b67/Open-ILS/src/eg2/src/app/share/grid/grid.ts#L746

Basically, if a cell uses a specific template rather than just the regular formatter, it will not display in the Print Full Grid or Download Full CSV views.

One example:

1) Go to Cataloging > Match Import/Export
2) Go to the Record Match Set grid
3) If you don't already have a record match set grid, create a new one.
4) Click the gear icon for the column picker/grid options menu.
5) Click Download Full CSV -- note that all the entries in the name column are empty.
6) Click Print Full Grid -- note that the name column is empty again.

Thanks to James Fournie for bringing this to my attention!

Bill Erickson (berick)
Changed in evergreen:
assignee: nobody → Bill Erickson (berick)
status: New → Confirmed
Revision history for this message
Bill Erickson (berick) wrote :

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1835982-grid-csv-template-fields

I tried some experiments with extracting the rendered contents of cellTemplates for printing, but it started getting messy. It also occurred to me generating print content from DOM-rendered templates would require the entire grid to be rendered in the DOM just to print it.

So, I've punted on that for now and instead added support for grid callers to provide functions which return print-friendly content for a given cell.

For example:

<eg-grid-column i18n-label label="Barcode" name="barcode"
  [cellTemplate]="barcodeTemplate" [cellPrintValue]="cellPrintValues">

this.cellPrintValues = (row: any, cell: GridColumn): string => {
  if (cell.name === 'barcode') {
    return row.barcode;
  }
}

This requires more effort to define the handlers, but I think the flexibility will appreciated. In the example noted above, where the displayed cell renders view/edit links, the print version skips the links which serve no purpose in a print context.

Also adds a fix to avoid printing "undefined" when no a cellTemplate is used but no cellPrintValue is defined.

tags: added: printing pullrequest
Changed in evergreen:
assignee: Bill Erickson (berick) → nobody
milestone: none → 3.4-beta1
Revision history for this message
Bill Erickson (berick) wrote :

Forgot to mention in my previous comment the linked branch includes cellPrintValue handlers for the Angular catalog record detail copies grid as a proof of concept. If we agree this is a reasonable strategy, we will likely want to add handlers for other grids that use cellTemplates.

Revision history for this message
Galen Charlton (gmc) wrote :

I like this approach and the patch works for me. I've pushed a signoff to user/gmcharlt/lp1835982_signoff; that branch also contains a follow-up to add cell value print handlers to the holdings view grid in the Angular staff catalog.

I would be comfortable with this going in as is or with additional follow-up patches to add cellPrintValue handlers for the remaining grids that use cellTemplate. In the former case, though, a new bug should be filed so we don't forget about the remaining grids.

I wonder how hard it would be to add a custom ng-lint rule to complete about eg-grid-columns that use cellTemplate bug lack cellPrintValue.

tags: added: signedoff
Changed in evergreen:
importance: Undecided → Medium
Bill Erickson (berick)
Changed in evergreen:
assignee: nobody → Bill Erickson (berick)
Revision history for this message
Bill Erickson (berick) wrote :

Thanks, Galen.

Here's a follow-up branch:

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1835982-grid-csv-template-fields-2

1. Sign off for Galen's commit

2. Adds remaining print text generators for columns in:
    * Vandelay match set list grid
    * Vandelay queue contents grid
    * Vandelay queued record matches grid
    * Catalog holds grid.

3. Modifies the API such that only a single text generator handler need be defined per grid, instead of one per column. Since in each case so far, a single function was defined to handle all columns in a grid, this seemed like a sane transition. The change includes a new GridCellTextGenerator interface to better define the expected outcomes.

4. Warnings now display at page load time when a cell is rendered via cellTemplate but has no text generator defined.

tags: removed: signedoff
Changed in evergreen:
assignee: Bill Erickson (berick) → nobody
Galen Charlton (gmc)
Changed in evergreen:
milestone: 3.4-beta1 → 3.4-beta2
Galen Charlton (gmc)
Changed in evergreen:
milestone: 3.4-beta2 → 3.4.1
Revision history for this message
Jane Sandberg (sandbergja) wrote :

A note that staff/booking/create-reservation.component.html will now also need a [cellPrintValue]

Changed in evergreen:
milestone: 3.4.1 → 3.4.2
Revision history for this message
Terran McCanna (tmccanna) wrote :

Please rebase against current master. Thanks!

tags: added: needsrepatch
Revision history for this message
Bill Erickson (berick) wrote :
Changed in evergreen:
assignee: nobody → Bill Erickson (berick)
tags: removed: needsrepatch
Changed in evergreen:
assignee: Bill Erickson (berick) → nobody
Revision history for this message
Terran McCanna (tmccanna) wrote :

Blake attempted to apply this to a current master sandbox and got conflict errors.

tags: added: needsrepatch
Revision history for this message
Bill Erickson (berick) wrote :

Thanks, Terran. I pushed a commit to the same branch to fix the issues Blake found a bit earlier today. (We were talking in IRC).

tags: removed: needsrepatch
Galen Charlton (gmc)
Changed in evergreen:
assignee: nobody → Galen Charlton (gmc)
Revision history for this message
Galen Charlton (gmc) wrote :

Sign-off of the current branch pushed to user/gmcharlt/lp1835982_signoff_round_2.

This branch includes a couple follow-ups:

[1] Give the btGrid in the sandbox a GridCellTextGenerator
[2] Add a usage note: a GridCellTextGenerator does not have access to the arbitrary context that can be given to a cellTemplate
[3] Tweak a couple of the new generators

tags: added: signedoff
Changed in evergreen:
assignee: Galen Charlton (gmc) → nobody
Revision history for this message
Bill Erickson (berick) wrote :

Sign-off's for Galen's patches pushed.

Branch includes 2 additions (via 1 commit)

1. Adds a missing text generator for the catalog holds grid patron barcode column.
2. Teaches the text generator internals to translate null/undefined to "" automatically.

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1835982-grid-csv-template-fields-4

Revision history for this message
Jane Sandberg (sandbergja) wrote :

Thanks, Bill and Galen. Pushed to master and rel_3_4, with a follow-up commit to add a GridCellTextGenerator for the booking schedule grid. I really like the new GridCellTextGenerator way of doing things!

Changed in evergreen:
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.