Bug 27644 - Add button to SQL report editor for inserting runtime parameters
Summary: Add button to SQL report editor for inserting runtime parameters
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on: 27643
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-05 18:35 UTC by Owen Leonard
Modified: 2021-08-18 21:41 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
This patch adds a button menu to the SQL report CodeMirror editor for inserting runtime parameters. Each menu item triggers a modal dialog where the user can specify a parameter label and any other relevant option.
Version(s) released in:
21.05.00


Attachments
Screenshot of the proposed change (87.14 KB, image/png)
2021-02-05 18:35 UTC, Owen Leonard
Details
Bug 27644: Add button to SQL report editor for inserting runtime parameters (12.55 KB, patch)
2021-02-08 13:35 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27644: Add button to SQL report editor for inserting runtime parameters (12.82 KB, patch)
2021-03-29 18:11 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27644: Add button to SQL report editor for inserting runtime parameters (12.97 KB, patch)
2021-03-31 11:13 UTC, PTFS Europe Sandboxes
Details | Diff | Splinter Review
Bug 27644: (follow-up) Wrap strings in translation function (7.48 KB, patch)
2021-04-07 18:38 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 27644: Add button to SQL report editor for inserting runtime parameters (13.03 KB, patch)
2021-04-18 00:08 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 27644: (follow-up) Wrap strings in translation function (7.53 KB, patch)
2021-04-18 00:08 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 27644: (QA follow-up) Remove size=1 from template (1.46 KB, patch)
2021-04-18 00:09 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 Owen Leonard 2021-02-05 18:35:48 UTC
Created attachment 116429 [details]
Screenshot of the proposed change

I can never remember the syntax for adding runtime parameters to SQL reports so I think it would be useful to have a menu of choices for the user to choose from.
Comment 1 Owen Leonard 2021-02-08 13:35:57 UTC
Created attachment 116496 [details] [review]
Bug 27644: Add button to SQL report editor for inserting runtime parameters

This patch adds a button menu to the SQL report CodeMirror editor for
inserting runtime parameters. Each menu item triggers a modal dialog
where the user can specify a parameter label and any other relevant
option.

To test, apply the patch and rebuild the staff client CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

- Go to Reports -> Use saved.
- Create or edit a report.
- You should see a menu button above the SQL editor field, "Insert
  runtime parameter."
- The menu should contain the options "Authorized value," "Date," "Item
  types," "Libraries," "Patron categories," and "Text field."
- Test each option. Each should trigger the display of a modal dialog
  with a heading which corresponds to your choice.
- In all cases except the "Authorized value" choice you should see a
  single form field for "label."
- Enter text in the label field and click the "Insert parameter" button.
- The correct runtime parameter should be inserted into the SQL editor.
  - If you placed a cursor somewhere in the SQL editor first, your
    parameter should be inserted in that location in the editor.
  - If you selected some text in the editor before selecting a
    parameter, the paramter should replace the selected text.
- In the case of the "Authorized value" selection, the modal dialog
  should include both a label field and a field for choosing an
  authorized value category.
- Try submitting the form without selecting an authorized value. It
  should warn you that the field is required.
- After testing the authorized value selection, try inserting another
  parameter to confirm that the authorized value selection (now hidden)
  is no longer required.
Comment 2 Lucas Gass 2021-03-05 20:33:01 UTC
This is a great idea, I too can never remember this syntax. 

This works well when I edit a report. But since the 'Insert runtime parameter' button is only added inside the '[% IF ( editsql ) %]' statement it does not appear when you create a new report. 

Could we have this for new reports too?
Comment 3 Owen Leonard 2021-03-29 18:11:31 UTC
Created attachment 118973 [details] [review]
Bug 27644: Add button to SQL report editor for inserting runtime parameters

This patch adds a button menu to the SQL report CodeMirror editor for
inserting runtime parameters. Each menu item triggers a modal dialog
where the user can specify a parameter label and any other relevant
option.

To test, apply the patch and rebuild the staff client CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

- Go to Reports -> Use saved.
- Create or edit a report.
- You should see a menu button above the SQL editor field, "Insert
  runtime parameter."
- The menu should contain the options "Authorized value," "Date," "Item
  types," "Libraries," "Patron categories," and "Text field."
- Test each option. Each should trigger the display of a modal dialog
  with a heading which corresponds to your choice.
- In all cases except the "Authorized value" choice you should see a
  single form field for "label."
- Enter text in the label field and click the "Insert parameter" button.
- The correct runtime parameter should be inserted into the SQL editor.
  - If you placed a cursor somewhere in the SQL editor first, your
    parameter should be inserted in that location in the editor.
  - If you selected some text in the editor before selecting a
    parameter, the paramter should replace the selected text.
- In the case of the "Authorized value" selection, the modal dialog
  should include both a label field and a field for choosing an
  authorized value category.
- Try submitting the form without selecting an authorized value. It
  should warn you that the field is required.
- After testing the authorized value selection, try inserting another
  parameter to confirm that the authorized value selection (now hidden)
  is no longer required.
Comment 4 PTFS Europe Sandboxes 2021-03-31 11:13:33 UTC
Created attachment 119039 [details] [review]
Bug 27644: Add button to SQL report editor for inserting runtime parameters

This patch adds a button menu to the SQL report CodeMirror editor for
inserting runtime parameters. Each menu item triggers a modal dialog
where the user can specify a parameter label and any other relevant
option.

To test, apply the patch and rebuild the staff client CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

- Go to Reports -> Use saved.
- Create or edit a report.
- You should see a menu button above the SQL editor field, "Insert
  runtime parameter."
- The menu should contain the options "Authorized value," "Date," "Item
  types," "Libraries," "Patron categories," and "Text field."
- Test each option. Each should trigger the display of a modal dialog
  with a heading which corresponds to your choice.
- In all cases except the "Authorized value" choice you should see a
  single form field for "label."
- Enter text in the label field and click the "Insert parameter" button.
- The correct runtime parameter should be inserted into the SQL editor.
  - If you placed a cursor somewhere in the SQL editor first, your
    parameter should be inserted in that location in the editor.
  - If you selected some text in the editor before selecting a
    parameter, the paramter should replace the selected text.
- In the case of the "Authorized value" selection, the modal dialog
  should include both a label field and a field for choosing an
  authorized value category.
- Try submitting the form without selecting an authorized value. It
  should warn you that the field is required.
- After testing the authorized value selection, try inserting another
  parameter to confirm that the authorized value selection (now hidden)
  is no longer required.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 5 Séverine Queune 2021-03-31 11:14:41 UTC
Such a nice one, thanks Owen !
Comment 6 Katrin Fischer 2021-04-03 15:11:52 UTC
This is really nice, but I believe I spotted a translation issue with the default labels:   $("#paramLabel").val("Authorized value") for an example.
Comment 7 Owen Leonard 2021-04-07 18:38:25 UTC
Created attachment 119311 [details] [review]
Bug 27644: (follow-up) Wrap strings in translation function

This patch updates the in-template JavaScript so that some English
strings which were previously untranslatable. This patch wraps them in
the _() function.

To test, apply the patch and test that the correct strings are
translatable. In this example I'm testing fr-FR:

- Update a translation:

  > gulp po:update
  > cd misc/translator
  > perl translate update fr-FR

- Open the corresponding .po file for the strings pulled from
  JavaScript  e.g.  misc/translator/po/fr-FR-staff-prog.po
- Locate strings pulled from reports/guided_reports_start.tt for
  translation, e.g.:

  #: koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt:1324
  #, fuzzy, c-format
  msgid "Authorized value category:"
  msgstr "Catégorie de valeur autorisée&nbsp;: "

- Edit the "msgstr" string if necessary, or remove the "fuzzy," before
  "c-format"
- Install the updated translation:

  > perl translate install fr-FR

In the staff interface, switch to the language you're testing. Confirm
that your translated strings appear. In this case, test in particular:

 - The controls on the modal window when you preview a report's SQL from
   the list of saved reports.
 - The controls and modal dialog for inserting a runtime parameter.
Comment 8 Katrin Fischer 2021-04-18 00:08:53 UTC
Created attachment 119812 [details] [review]
Bug 27644: Add button to SQL report editor for inserting runtime parameters

This patch adds a button menu to the SQL report CodeMirror editor for
inserting runtime parameters. Each menu item triggers a modal dialog
where the user can specify a parameter label and any other relevant
option.

To test, apply the patch and rebuild the staff client CSS
(https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client).

- Go to Reports -> Use saved.
- Create or edit a report.
- You should see a menu button above the SQL editor field, "Insert
  runtime parameter."
- The menu should contain the options "Authorized value," "Date," "Item
  types," "Libraries," "Patron categories," and "Text field."
- Test each option. Each should trigger the display of a modal dialog
  with a heading which corresponds to your choice.
- In all cases except the "Authorized value" choice you should see a
  single form field for "label."
- Enter text in the label field and click the "Insert parameter" button.
- The correct runtime parameter should be inserted into the SQL editor.
  - If you placed a cursor somewhere in the SQL editor first, your
    parameter should be inserted in that location in the editor.
  - If you selected some text in the editor before selecting a
    parameter, the paramter should replace the selected text.
- In the case of the "Authorized value" selection, the modal dialog
  should include both a label field and a field for choosing an
  authorized value category.
- Try submitting the form without selecting an authorized value. It
  should warn you that the field is required.
- After testing the authorized value selection, try inserting another
  parameter to confirm that the authorized value selection (now hidden)
  is no longer required.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Katrin Fischer 2021-04-18 00:08:57 UTC
Created attachment 119813 [details] [review]
Bug 27644: (follow-up) Wrap strings in translation function

This patch updates the in-template JavaScript so that some English
strings which were previously untranslatable. This patch wraps them in
the _() function.

To test, apply the patch and test that the correct strings are
translatable. In this example I'm testing fr-FR:

- Update a translation:

  > gulp po:update
  > cd misc/translator
  > perl translate update fr-FR

- Open the corresponding .po file for the strings pulled from
  JavaScript  e.g.  misc/translator/po/fr-FR-staff-prog.po
- Locate strings pulled from reports/guided_reports_start.tt for
  translation, e.g.:

  #: koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt:1324
  #, fuzzy, c-format
  msgid "Authorized value category:"
  msgstr "Catégorie de valeur autorisée&nbsp;: "

- Edit the "msgstr" string if necessary, or remove the "fuzzy," before
  "c-format"
- Install the updated translation:

  > perl translate install fr-FR

In the staff interface, switch to the language you're testing. Confirm
that your translated strings appear. In this case, test in particular:

 - The controls on the modal window when you preview a report's SQL from
   the list of saved reports.
 - The controls and modal dialog for inserting a runtime parameter.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Katrin Fischer 2021-04-18 00:09:02 UTC
Created attachment 119814 [details] [review]
Bug 27644: (QA follow-up) Remove size=1 from template

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Jonathan Druart 2021-04-21 13:30:08 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 12 Fridolin Somers 2021-04-29 13:26:55 UTC
Enhancement not pushed to 20.11.x