Bug 34456 - Add the ability to download a template rendered report as a file
Summary: Add the ability to download a template rendered report as a file
Status: Needs documenting
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 34136
Blocks: 35193
  Show dependency treegraph
 
Reported: 2023-08-02 12:27 UTC by Kyle M Hall
Modified: 2023-11-30 16:36 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This allows to create new download formats for reports using notice templates. You can create different file formats, specifying the file name and ending in the accordingly labelled field when setting up the notice.
Version(s) released in:
23.11.00


Attachments
Bug 34456 - Add the ability to download a template rendered report as a file (4.21 KB, patch)
2023-08-02 12:32 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456 - Add the ability to download a template rendered report as a file (4.25 KB, patch)
2023-08-02 14:39 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 34456 - Add the ability to download a template rendered report as a file (4.28 KB, patch)
2023-10-26 13:44 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456 - Add the ability to download a template rendered report as a file (4.31 KB, patch)
2023-10-26 13:45 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456: Add the ability to download a template rendered report as a file (4.31 KB, patch)
2023-10-30 17:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456: (QA follow-up) Change download link language (1.95 KB, patch)
2023-10-30 17:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456: (QA follow-up) perltidy code (1.81 KB, patch)
2023-10-30 17:38 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34456: Add the ability to download a template rendered report as a file (4.36 KB, patch)
2023-10-30 20:28 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 34456: (QA follow-up) Change download link language (2.01 KB, patch)
2023-10-30 20:28 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 34456: (QA follow-up) perltidy code (1.86 KB, patch)
2023-10-30 20:28 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2023-08-02 12:27:22 UTC
Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).
Comment 1 Kyle M Hall 2023-08-02 12:32:32 UTC
Created attachment 154156 [details] [review]
Bug 34456 - Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!
Comment 2 Sam Lau 2023-08-02 14:39:14 UTC
Created attachment 154158 [details] [review]
Bug 34456 - Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 3 Katrin Fischer 2023-10-23 22:03:03 UTC
Kyle, can you please help resolve?

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 34456 - Add the ability to download a template rendered report as a file
error: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc).
error: could not build fake ancestor
Patch failed at 0001 Bug 34456 - Add the ability to download a template rendered report as a file
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem run "git bz apply --continue".
If you would prefer to skip this patch, instead run "git bz apply --skip".
To restore the original branch and stop patching run "git bz apply --abort".
Patch left in /tmp/Bug-34456---Add-the-ability-to-download-a-template-mpcxly5w.patch
Comment 4 Kyle M Hall 2023-10-26 13:44:13 UTC
Created attachment 157924 [details] [review]
Bug 34456 - Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 5 Kyle M Hall 2023-10-26 13:45:37 UTC
Created attachment 157925 [details] [review]
Bug 34456 - Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 6 Katrin Fischer 2023-10-29 09:24:17 UTC
This works, but there are some bigger and smaller issues:

1) It produces an invalid HTML file, missing the html and body tags. If we were to add them to the template, the template could no longer be properly displayed in Koha. That's why I feel it would be better to add those on export. It's created with a .html ending, so I assume that is the use case.

2) The patch commit line needs to be fixed.

3) I think we should change the label in the download menu to fit with the others. It's a list of formats now, never including the word "Download", so my suggestion would be something like: "HTML using [template] '<template>'" 
If possible please avoid the <i> as they break up the string.

4) Perltidy please.
Comment 7 Kyle M Hall 2023-10-30 17:32:06 UTC
(In reply to Katrin Fischer from comment #6)
> This works, but there are some bigger and smaller issues:
> 
> 1) It produces an invalid HTML file, missing the html and body tags. If we
> were to add them to the template, the template could no longer be properly
> displayed in Koha. That's why I feel it would be better to add those on
> export. It's created with a .html ending, so I assume that is the use case.

This feature is meant to generate arbitrary formats. The only production use case we have right now produces an XML file. To make the data viewable before download I use IF blocks to warp the xml in a textarea. This is just one possible way to deal with the issue. The main point is that this feature isn't mean to be HTML only.

> 2) The patch commit line needs to be fixed.

Fixed!

> 3) I think we should change the label in the download menu to fit with the
> others. It's a list of formats now, never including the word "Download", so
> my suggestion would be something like: "HTML using [template] '<template>'" 
> If possible please avoid the <i> as they break up the string.

As explained above, this isn't meant to be strictly for HTML. Instead, I'll change the option to "Rendered template ( <filename> )". That will more closely match what we are doing now.

> 
> 4) Perltidy please.

Can do!
Comment 8 Katrin Fischer 2023-10-30 17:36:41 UTC
I was wondering if it should work for different formats. I am ok with the name change, but should we also do something about the file ending then?
Comment 9 Kyle M Hall 2023-10-30 17:38:28 UTC
Created attachment 158092 [details] [review]
Bug 34456: Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!

Signed-off-by: Sam Lau <samalau@gmail.com>
Comment 10 Kyle M Hall 2023-10-30 17:38:34 UTC
Created attachment 158093 [details] [review]
Bug 34456: (QA follow-up) Change download link language
Comment 11 Kyle M Hall 2023-10-30 17:38:36 UTC
Created attachment 158094 [details] [review]
Bug 34456: (QA follow-up) perltidy code
Comment 12 Kyle M Hall 2023-10-30 17:42:47 UTC
(In reply to Katrin Fischer from comment #8)
> I was wondering if it should work for different formats. I am ok with the
> name change, but should we also do something about the file ending then?

The file name is controlled by the report title template. Does that work for you?
Comment 13 Katrin Fischer 2023-10-30 17:53:16 UTC
(In reply to Kyle M Hall from comment #12)
> (In reply to Katrin Fischer from comment #8)
> > I was wondering if it should work for different formats. I am ok with the
> > name change, but should we also do something about the file ending then?
> 
> The file name is controlled by the report title template. Does that work for
> you?

Can you rephrase that? Or I'll try to explain better: the file I downloaded had a .html ending.
Comment 14 Kyle M Hall 2023-10-30 17:57:59 UTC
(In reply to Katrin Fischer from comment #13)
> (In reply to Kyle M Hall from comment #12)
> > (In reply to Katrin Fischer from comment #8)
> > > I was wondering if it should work for different formats. I am ok with the
> > > name change, but should we also do something about the file ending then?
> > 
> > The file name is controlled by the report title template. Does that work for
> > you?
> 
> Can you rephrase that? Or I'll try to explain better: the file I downloaded
> had a .html ending.

The "Message subject" becomes the filename. I think your browser is adding the .html to your file. I have mine set to "Example.xml" and when I choose to download it my browser tells me it is an html file, but honors the "Example.xml" message subject. I bet if I changed it to just "Example" my browser would tack on the .html on its' own.
Comment 15 Katrin Fischer 2023-10-30 20:28:37 UTC
Created attachment 158105 [details] [review]
Bug 34456: Add the ability to download a template rendered report as a file

Bug 34136 adds the ability to render a report using a notice template rather than displaying data in a table. It would be even more useful to be able to download the contents as a file where the notice subject can be used as the filename so the filename can be generated dynamically ( such as adding the current date as part of the filename ).

Test Plan:
1) Follow the test plan for Bug 34136
2) Run your report
3) Note under the Download menu the new item "Download as" with the
   subject line for your template
4) Click that link, note the file contains the contents of your report!

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Katrin Fischer 2023-10-30 20:28:39 UTC
Created attachment 158106 [details] [review]
Bug 34456: (QA follow-up) Change download link language

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 17 Katrin Fischer 2023-10-30 20:28:42 UTC
Created attachment 158107 [details] [review]
Bug 34456: (QA follow-up) perltidy code

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 18 Tomás Cohen Arazi 2023-11-01 20:26:46 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 19 Fridolin Somers 2023-11-08 08:45:13 UTC
Depends on Bug 34136 not in 23.05.x