Skip to content

Commit 792ba9e

Browse files
feat: Select rows in data browser by clicking and dragging mouse cursor over checkboxes (#2548)
1 parent c0b2ad3 commit 792ba9e

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/components/BrowserRow/BrowserRow.react.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export default class BrowserRow extends Component {
4242
setContextMenu,
4343
onFilterChange,
4444
markRequiredFieldRow,
45+
onMouseDownRowCheckBox,
46+
onMouseUpRowCheckBox,
47+
onMouseOverRowCheckBox,
4548
} = this.props;
4649
const attributes = obj.attributes;
4750
let requiredCols = [];
@@ -62,11 +65,16 @@ export default class BrowserRow extends Component {
6265
}
6366
return (
6467
<div className={styles.tableRow} style={{ minWidth: rowWidth }}>
65-
<span className={styles.checkCell}>
68+
<span
69+
className={styles.checkCell}
70+
onMouseUp={onMouseUpRowCheckBox}
71+
onMouseOver={() => onMouseOverRowCheckBox(obj.id)}
72+
>
6673
<input
6774
type="checkbox"
6875
checked={selection['*'] || selection[obj.id]}
6976
onChange={e => selectRow(obj.id, e.target.checked)}
77+
onMouseDown={(e) => onMouseDownRowCheckBox(e.target.checked)}
7078
/>
7179
</span>
7280
{order.map(({ name, width, visible }, j) => {

src/dashboard/Data/Browser/Browser.react.js

+31
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class Browser extends DashboardView {
9898
currentUser: Parse.User.current(),
9999

100100
processedScripts: 0,
101+
102+
rowCheckboxDragging: false,
103+
draggedRowSelection: false,
101104
};
102105

103106
this.addLocation = this.addLocation.bind(this);
@@ -163,6 +166,9 @@ class Browser extends DashboardView {
163166
this.abortEditCloneRow = this.abortEditCloneRow.bind(this);
164167
this.cancelPendingEditRows = this.cancelPendingEditRows.bind(this);
165168
this.redirectToFirstClass = this.redirectToFirstClass.bind(this);
169+
this.onMouseDownRowCheckBox = this.onMouseDownRowCheckBox.bind(this);
170+
this.onMouseUpRowCheckBox = this.onMouseUpRowCheckBox.bind(this);
171+
this.onMouseOverRowCheckBox = this.onMouseOverRowCheckBox.bind(this);
166172

167173
this.dataBrowserRef = React.createRef();
168174

@@ -189,10 +195,12 @@ class Browser extends DashboardView {
189195

190196
componentDidMount() {
191197
this.addLocation(this.props.params.appId);
198+
window.addEventListener('mouseup', this.onMouseUpRowCheckBox);
192199
}
193200

194201
componentWillUnmount() {
195202
this.removeLocation();
203+
window.removeEventListener('mouseup', this.onMouseUpRowCheckBox);
196204
}
197205

198206
componentWillReceiveProps(nextProps, nextContext) {
@@ -1790,6 +1798,26 @@ class Browser extends DashboardView {
17901798
this.setState({ showPointerKeyDialog: false });
17911799
}
17921800

1801+
onMouseDownRowCheckBox(checked) {
1802+
this.setState({
1803+
rowCheckboxDragging: true,
1804+
draggedRowSelection: !checked,
1805+
});
1806+
}
1807+
1808+
onMouseUpRowCheckBox() {
1809+
this.setState({
1810+
rowCheckboxDragging: false,
1811+
draggedRowSelection: false,
1812+
});
1813+
}
1814+
1815+
onMouseOverRowCheckBox(id) {
1816+
if (this.state.rowCheckboxDragging) {
1817+
this.selectRow(id, this.state.draggedRowSelection);
1818+
}
1819+
}
1820+
17931821
renderContent() {
17941822
let browser = null;
17951823
let className = this.props.params.className;
@@ -1909,6 +1937,9 @@ class Browser extends DashboardView {
19091937
onAddRowWithModal={this.addRowWithModal}
19101938
onAddClass={this.showCreateClass}
19111939
showNote={this.showNote}
1940+
onMouseDownRowCheckBox={this.onMouseDownRowCheckBox}
1941+
onMouseUpRowCheckBox={this.onMouseUpRowCheckBox}
1942+
onMouseOverRowCheckBox={this.onMouseOverRowCheckBox}
19121943
/>
19131944
);
19141945
}

src/dashboard/Data/Browser/BrowserTable.react.js

+9
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ export default class BrowserTable extends React.Component {
170170
scripts={this.context.scripts}
171171
selectedCells={this.props.selectedCells}
172172
handleCellClick={this.props.handleCellClick}
173+
onMouseDownRowCheckBox={this.props.onMouseDownRowCheckBox}
174+
onMouseUpRowCheckBox={this.props.onMouseUpRowCheckBox}
175+
onMouseOverRowCheckBox={this.props.onMouseOverRowCheckBox}
173176
/>
174177
<Button
175178
value="Clone"
@@ -240,6 +243,9 @@ export default class BrowserTable extends React.Component {
240243
scripts={this.context.scripts}
241244
selectedCells={this.props.selectedCells}
242245
handleCellClick={this.props.handleCellClick}
246+
onMouseDownRowCheckBox={this.props.onMouseDownRowCheckBox}
247+
onMouseUpRowCheckBox={this.props.onMouseUpRowCheckBox}
248+
onMouseOverRowCheckBox={this.props.onMouseOverRowCheckBox}
243249
/>
244250
<Button
245251
value="Add"
@@ -318,6 +324,9 @@ export default class BrowserTable extends React.Component {
318324
scripts={this.context.scripts}
319325
selectedCells={this.props.selectedCells}
320326
handleCellClick={this.props.handleCellClick}
327+
onMouseDownRowCheckBox={this.props.onMouseDownRowCheckBox}
328+
onMouseUpRowCheckBox={this.props.onMouseUpRowCheckBox}
329+
onMouseOverRowCheckBox={this.props.onMouseOverRowCheckBox}
321330
/>
322331
);
323332
}

0 commit comments

Comments
 (0)