Bug 27747

Summary: Add CodeMirror custom syntax highlighting for column placeholders
Product: Koha Reporter: Owen Leonard <oleonard>
Component: ReportsAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Nick Clemens (kidclamp) <nick>
Severity: enhancement    
Priority: P5 - low CC: caroline.cyr-la-rose, fridolin.somers, jonathan.druart, kyle, lucas, nick, testopia
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This patch modifies the configuration of the reports module's SQL editor so that column placeholders have their own syntax highlighting, setting them apart by color from other parts of the SQL code.
Version(s) released in:
21.11.00
Circulation function:
Bug Depends on: 27643    
Bug Blocks:    
Attachments: Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders
Bug 27747: (QA follow-up) Make code consistent and add explicit brackets

Description Owen Leonard 2021-02-22 12:33:57 UTC
I propose we add a basic syntax highlighting configuration for column placeholders (Bug 23390), defined as any string surrounded by square brackets: [[itemnumber|Item number]].
Comment 1 Owen Leonard 2021-02-22 12:43:03 UTC
Created attachment 117146 [details] [review]
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders

This patch adds some additional configuration to CodeMirror so that
column placeholders have a distinct color in the CodeMirror SQL editor.

To test, apply the patch and create or edit an SQL report which contains
one or more column placeholders, e.g. [[itemnumber|Item number]],
[[borrowernumber|Borrower number]], etc.

Confirm that when editing the SQL, these placeholders should appear as
red text. Save your report and view it. The syntax highlighting should
be updated in this view too.
Comment 2 Lucas Gass (lukeg) 2021-05-11 16:24:08 UTC
Created attachment 120849 [details] [review]
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders

This patch adds some additional configuration to CodeMirror so that
column placeholders have a distinct color in the CodeMirror SQL editor.

To test, apply the patch and create or edit an SQL report which contains
one or more column placeholders, e.g. [[itemnumber|Item number]],
[[borrowernumber|Borrower number]], etc.

Confirm that when editing the SQL, these placeholders should appear as
red text. Save your report and view it. The syntax highlighting should
be updated in this view too.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 3 Nick Clemens (kidclamp) 2021-07-23 13:07:56 UTC
Created attachment 123108 [details] [review]
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders

This patch adds some additional configuration to CodeMirror so that
column placeholders have a distinct color in the CodeMirror SQL editor.

To test, apply the patch and create or edit an SQL report which contains
one or more column placeholders, e.g. [[itemnumber|Item number]],
[[borrowernumber|Borrower number]], etc.

Confirm that when editing the SQL, these placeholders should appear as
red text. Save your report and view it. The syntax highlighting should
be updated in this view too.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 4 Nick Clemens (kidclamp) 2021-07-23 13:07:59 UTC
Created attachment 123109 [details] [review]
Bug 27747: (QA follow-up) Make code consistent and add explicit brackets

The while statements were including the next statement, I add brackets to make it
more obvious

Also the highlighting was applying to [[borrowernumber|Borrow number]
I removed the break to match code above and only highlight when syntax complete and correct

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 5 Jonathan Druart 2021-07-26 10:47:27 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall (khall) 2021-07-30 15:14:22 UTC
Enhancement not backported for 21.05