[pgAdmin][RM4487] Boolean data type is not editable in view data

Aditya Toshniwal <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAM9w-_nFD8Kv3aaehfNyUzH4wt-Wiu+fwqC--vAvzF9OMcKqtA@mail.gmail.com>
Hi Hackers,

Attached is the patch to fix two issues:
1) 4487 - Boolean data type is not editable in view data
2) 3778 - No keyboard key to edit boolean column in "View/Edit Data"

Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
RM4487_3778.patch (application/octet-stream, 2 KB)
diff --git a/web/pgadmin/static/js/slickgrid/editors.js b/web/pgadmin/static/js/slickgrid/editors.js
index 2325149b..22bd86ba 100644
--- a/web/pgadmin/static/js/slickgrid/editors.js
+++ b/web/pgadmin/static/js/slickgrid/editors.js
@@ -886,27 +886,35 @@ import gettext from 'sources/gettext';
   // Custom checkbox editor, We need it for runtime as it does not render
   // indeterminate checkbox state
   function pgCheckboxEditor(args) {
-    var $select, el;
+    var $select;
     var defaultValue, previousState;
 
     this.init = function() {
-      $select = $('<div class=\'multi-checkbox\'><span class=\'check\' hideFocus></span></div>');
+      $select = $('<div class=\'multi-checkbox\' tabindex="0"><span class=\'check\' hideFocus></span></div>');
       $select.appendTo(args.container);
       $select.trigger('focus');
 
-      // The following code is taken from https://css-tricks.com/indeterminate-checkboxes/
-      $select.on('click', function() {
-        el = $(this);
-        var states = ['unchecked', 'partial', 'checked'];
-        var curState = el.find('.check').data('state');
-        curState++;
-        el.find('.check')
-          .removeClass('unchecked partial checked')
-          .addClass(states[curState % states.length])
-          .data('state', curState % states.length);
+      $select.on('click', this.changeValue);
+
+      $select.on('keydown', (e) => {
+        if (e.which == $.ui.keyCode.SPACE) {
+          e.preventDefault();
+          this.changeValue(e);
+        }
       });
     };
 
+    this.changeValue = function() {
+      // The following code is taken from https://css-tricks.com/indeterminate-checkboxes/
+      var states = ['unchecked', 'partial', 'checked'];
+      var curState = $select.find('.check').data('state') || 0;
+      curState++;
+      $select.find('.check')
+        .removeClass('unchecked partial checked')
+        .addClass(states[curState % states.length])
+        .data('state', curState % states.length);
+    };
+
     this.destroy = function() {
       $select.remove();
     };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.