Fixed an issue where drag and drop object is not correct in codemirror for properties dialog. Fixes #4436

This commit is contained in:
Pradip Parkale
2021-04-29 13:19:36 +05:30
committed by Akshay Joshi
parent 488dc1849d
commit 333a22496c
2 changed files with 36 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ Housekeeping
Bug fixes
*********
| `Issue #4436 <https://redmine.postgresql.org/issues/4436>`_ - Fixed an issue where drag and drop object is not correct in codemirror for properties dialog.
| `Issue #5555 <https://redmine.postgresql.org/issues/5555>`_ - Fixed an issue where data is displayed in the wrong order when executing the query repeatedly.
| `Issue #6329 <https://redmine.postgresql.org/issues/6329>`_ - Fixed an issue where the wrong SQL is showing for the child partition tables.
| `Issue #6341 <https://redmine.postgresql.org/issues/6341>`_ - Fixed an issue where CSV download quotes the numeric columns.

View File

@@ -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'))