Fixed copy-paste row issues in View/Edit Data. Fixes #3947

1) Copy table rows across two or more active query tool sessions.
  2) Copied rows can be pasted multiple times without selecting a row in the query tool grid.
  3) Adds an empty row at the end in the query tool grid after pasting rows.
This commit is contained in:
Nagesh Dhope
2020-04-16 15:25:39 +05:30
committed by Akshay Joshi
parent dc1e32a632
commit 0ce4f49e08
4 changed files with 56 additions and 27 deletions

View File

@@ -64,6 +64,9 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
if (clipboardData) {
clipboardData.setData('text', text);
// As there no uniform way to read data from clipboard
// storing copied data into main window object, so it is accessible from anywhere in the application
window.parent.window.clipboardData = text;
// We want our data, not data from any selection, to be written to the clipboard
e.preventDefault();
}
@@ -83,6 +86,9 @@ define(['sources/gettext', 'alertify'], function (gettext, alertify) {
document.body.removeChild(textArea);
},
getTextFromClipboard: function() {
return window.parent.window.clipboardData || '';
},
};
return clipboard;
});

View File

@@ -48,6 +48,10 @@ function ($, _, clipboard, RangeSelectionHelper, rangeBoundaryNavigator) {
var setPasteRowButtonEnablement = function (canEditFlag, isEnabled) {
if (canEditFlag) {
$('#btn-paste-row').prop('disabled', !isEnabled);
if(isEnabled && window.parent.$) {
// trigger copied event to all sessions
window.parent.$(window.parent.document).trigger('pgadmin-sqleditor:rows-copied', copyWithHeader());
}
}
};
return copyData;