public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM4436]Drag and drop is incorrect in codemirror boxes in node properties dialog
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM4436]Drag and drop is incorrect in codemirror boxes in node properties dialog
@ 2021-04-29 05:47  Pradip Parkale <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Pradip Parkale @ 2021-04-29 05:47 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Please find the attached patch for #4436 - Drag and drop is incorrect in
codemirror boxes in node properties dialog.


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] RM4436.patch (1.8K, 3-RM4436.patch)
  download | inline diff:
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 8f70fd3c0..e6b0f2480 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -2609,10 +2609,10 @@ define([
       // refresh the code mirror object on 'pg-property-tab-changed' event to
       // make it work properly.
       self.model.on('pg-property-tab-changed', this.refreshTextArea, this);
-
+      this.sqlCtrl.setOption('dragDrop', true);
       this.sqlCtrl.on('focus', this.onFocus);
       this.sqlCtrl.on('blur', this.onBlur);
-
+      this.sqlCtrl.on('drop', this.onDrop);
       // Refresh SQL Field to refresh the control lazily after it renders
       setTimeout(function() {
         self.refreshTextArea.apply(self);
@@ -2621,6 +2621,39 @@ define([
       return self;
     },
 
+    onDrop: function(editor, e){
+      var dropDetails = null;
+      try {
+        dropDetails = JSON.parse(e.dataTransfer.getData('text'));
+
+        /* Stop firefox from redirecting */
+
+        if(e.preventDefault) {
+          e.preventDefault();
+        }
+        if (e.stopPropagation) {
+          e.stopPropagation();
+        }
+      } catch(error) {
+        /* if parsing fails, it must be the drag internal of codemirror text */
+        return;
+      }
+
+      var cursor = editor.coordsChar({
+        left: e.x,
+        top: e.y,
+      });
+      editor.replaceRange(dropDetails.text, cursor);
+      editor.focus();
+      editor.setSelection({
+        ...cursor,
+        ch: cursor.ch + dropDetails.cur.from,
+      },{
+        ...cursor,
+        ch: cursor.ch +dropDetails.cur.to,
+      });
+    },
+
     onFocus: function() {
       var $ctrl = this.$el.find('.pgadmin-controls').first();
       if (!$ctrl.hasClass('focused'))


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin][RM4436]Drag and drop is incorrect in codemirror boxes in node properties dialog
@ 2021-04-29 07:50  Akshay Joshi <[email protected]>
  parent: Pradip Parkale <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-04-29 07:50 UTC (permalink / raw)
  To: Pradip Parkale <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Thu, Apr 29, 2021 at 11:17 AM Pradip Parkale <
[email protected]> wrote:

> Hi Hackers,
>
> Please find the attached patch for #4436 - Drag and drop is incorrect in
> codemirror boxes in node properties dialog.
>
>
> --
> Thanks & Regards,
> Pradip Parkale
> Software Engineer | EnterpriseDB Corporation
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-04-29 07:50 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 05:47 [pgAdmin][RM4436]Drag and drop is incorrect in codemirror boxes in node properties dialog Pradip Parkale <[email protected]>
2021-04-29 07:50 ` Akshay Joshi <[email protected]>

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