Bugzilla – Attachment 120849 Details for
Bug 27747
Add CodeMirror custom syntax highlighting for column placeholders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders
Bug-27747-Add-CodeMirror-custom-syntax-highlightin.patch (text/plain), 4.34 KB, created by
Lucas Gass (lukeg)
on 2021-05-11 16:24:08 UTC
(
hide
)
Description:
Bug 27747: Add CodeMirror custom syntax highlighting for column placeholders
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2021-05-11 16:24:08 UTC
Size:
4.34 KB
patch
obsolete
>From c3359d064aea1ee076e16f40c3ebe16cf45c5a45 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 22 Feb 2021 12:36:08 +0000 >Subject: [PATCH] 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> >--- > .../en/modules/reports/guided_reports_start.tt | 41 ++++++++++++++-------- > 1 file changed, 27 insertions(+), 14 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index ab9478ac45..11cfc366ee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -47,6 +47,9 @@ > .cm-sqlParams { > color: #11917B; > } >+ .cm-columnPlaceholder { >+ color: #BF2D5D; >+ } > #mana_search_errortext { font-family: monospace; font-weight: bold; } > </style> > [% Asset.css("css/reports.css") | $raw %] >@@ -1420,22 +1423,32 @@ > } > > /* overlay a syntax-highlighting definition on top of the existing sql one */ >- CodeMirror.defineMode("sqlParams", function(config, parserConfig) { >- var sqlParamsOverlay = { >+ CodeMirror.defineMode("sqlPlaceholders", function(config, parserConfig) { >+ var sqlPlaceholdersOverlay = { > token: function(stream, state) { >- var ch; >- if (stream.match("<<")) { >- while ((ch = stream.next()) != null) >- if (ch == ">" && stream.next() == ">") { >- stream.eat(">"); >- return "sqlParams"; >+ var ch; >+ >+ if (stream.match("<<")) { >+ while ((ch = stream.next()) != null) >+ if (ch == ">" && stream.next() == ">") { >+ stream.eat(">"); >+ return "sqlParams"; >+ } >+ } >+ >+ if (stream.match("[[")) { >+ while ((ch = stream.next()) != null) >+ if (ch == "]" && stream.next() == "]") break; >+ stream.eat("]"); >+ return "columnPlaceholder"; >+ } >+ >+ else if (stream.next() != null) { >+ return null; > } >- } >- while (stream.next() != null && !stream.match("<<", false)) {} >- return null; > } > }; >- return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/x-sql"), sqlParamsOverlay); >+ return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/x-sql"), sqlPlaceholdersOverlay); > }); > > var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone."); >@@ -1454,7 +1467,7 @@ > > var editor = CodeMirror.fromTextArea(sql, { > lineNumbers: true, >- mode: "sqlParams", /* text/x-sql plus custom sqlParams configuration */ >+ mode: "sqlPlaceholders", /* text/x-sql plus custom sqlPlaceholders configuration */ > lineWrapping: true, > smartIndent: false > }); >@@ -1476,7 +1489,7 @@ > [% IF ( showsql ) %] > var editor = CodeMirror.fromTextArea(sql, { > lineNumbers: false, >- mode: "sqlParams", /* text/x-sql plus custom sqlParams configuration */ >+ mode: "sqlPlaceholders", /* text/x-sql plus custom sqlPlaceholders configuration */ > lineWrapping: true, > readOnly: true > }); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27747
:
117146
|
120849
|
123108
|
123109