public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dave Page <[email protected]>
To: pgadmin-hackers <[email protected]>
Cc: Nikhil Mohite <[email protected]>
Subject: RM 6427 - Newlines in text columns of resultset show an allegedly "empty" field
Date: Wed, 30 Jun 2021 11:05:19 +0100
Message-ID: <CA+OCxozRoYYgSp+BRrovk31uzn4sB0JCL6ztcgaOjpx6qnfbqA@mail.gmail.com> (raw)

Here's a simple patch for $SUBJECT. It will remove any leading spaces from
the grid cell display and replace them with '[...] '. In edit mode, the
data is unchanged.

The only downside I can see to this is that the tooltip will show the
modified data when it probably should actually show the un-modified data.
Unfortunately that's handled by a SlickGrid plugin, which would have to be
vendorised and modified (perhaps non-trivially). I don't think that's a big
issue though.

-- 
Dave Page
Blog: https://pgsnake.blogspot.com
Twitter: @pgsnake

EDB: https://www.enterprisedb.com


Attachments:

  [application/octet-stream] RM_6427.diff (948B, 3-RM_6427.diff)
  download | inline diff:
diff --git a/web/pgadmin/static/js/slickgrid/formatters.js b/web/pgadmin/static/js/slickgrid/formatters.js
index 7c9b2a21b..2159c9dda 100644
--- a/web/pgadmin/static/js/slickgrid/formatters.js
+++ b/web/pgadmin/static/js/slickgrid/formatters.js
@@ -103,12 +103,21 @@
 
   function TextFormatter(row, cell, value, columnDef) {
     // If column has default value, set placeholder
-    var data = NullAndDefaultFormatter(row, cell, value, columnDef);
-    if (data) {
-      return data;
+    var raw = NullAndDefaultFormatter(row, cell, value, columnDef);
+
+    var data;
+    if (raw) {
+      data = raw;
     } else {
-      return _.escape(value);
+      data = _.escape(value);
     }
+
+    // Replace leading whitespace with a marker so we don't just show blank lines
+    if (data.trimStart() != data) {
+      data = '[...] ' + data.trimStart();
+    }
+
+    return data;
   }
 
   function BinaryFormatter(row, cell, value, columnDef) {


view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: RM 6427 - Newlines in text columns of resultset show an allegedly "empty" field
  In-Reply-To: <CA+OCxozRoYYgSp+BRrovk31uzn4sB0JCL6ztcgaOjpx6qnfbqA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox