From 29dae02e80ec47855659d6a834319232665d4add Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 20 Mar 2025 19:25:38 +1100 Subject: [PATCH 1/2] feature: allow for copy multiple columns --- .../Data/Browser/DataBrowser.react.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index fbc7c6968a..445fe4754c 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -274,6 +274,42 @@ export default class DataBrowser extends React.Component { if (this.props.disableKeyControls) { return; } + if (e.keyCode === 67 && (e.ctrlKey || e.metaKey)) { + // check if there is multiple selected cells + const { rowStart, rowEnd, colStart, colEnd } = this.state.selectedCells; + if (rowStart !== -1 && rowEnd !== -1 && colStart !== -1 && colEnd !== -1) { + let copyableValue = ''; + + for (let rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) { + const rowData = []; + + for (let colIndex = colStart; colIndex <= colEnd; colIndex++) { + const field = this.state.order[colIndex].name; + let value = field === 'objectId' + ? this.props.data[rowIndex].id + : this.props.data[rowIndex].attributes[field]; + + if (typeof value === 'number' && !isNaN(value)) { + rowData.push(String(value)); + } else { + rowData.push(value || ''); + } + } + + copyableValue += rowData.join('\t'); + if (rowIndex < rowEnd) { + copyableValue += '\r\n'; + } + } + this.setCopyableValue(copyableValue); + copy(copyableValue); + + if (this.props.showNote) { + this.props.showNote('Value copied to clipboard', false); + } + e.preventDefault(); + } + } if ( this.state.editing && this.state.current && From 1cf7a2ed86ae18aae2c90f246ade5c34ba66cf13 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 26 Mar 2025 21:49:44 +1100 Subject: [PATCH 2/2] Update DataBrowser.react.js --- src/dashboard/Data/Browser/DataBrowser.react.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dashboard/Data/Browser/DataBrowser.react.js b/src/dashboard/Data/Browser/DataBrowser.react.js index 5d2feca76c..d807b8fee3 100644 --- a/src/dashboard/Data/Browser/DataBrowser.react.js +++ b/src/dashboard/Data/Browser/DataBrowser.react.js @@ -287,13 +287,13 @@ export default class DataBrowser extends React.Component { const { rowStart, rowEnd, colStart, colEnd } = this.state.selectedCells; if (rowStart !== -1 && rowEnd !== -1 && colStart !== -1 && colEnd !== -1) { let copyableValue = ''; - + for (let rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) { const rowData = []; - + for (let colIndex = colStart; colIndex <= colEnd; colIndex++) { const field = this.state.order[colIndex].name; - let value = field === 'objectId' + const value = field === 'objectId' ? this.props.data[rowIndex].id : this.props.data[rowIndex].attributes[field]; @@ -303,7 +303,7 @@ export default class DataBrowser extends React.Component { rowData.push(value || ''); } } - + copyableValue += rowData.join('\t'); if (rowIndex < rowEnd) { copyableValue += '\r\n';