Skip to content

Commit 15f1d60

Browse files
author
david califf
committed
delete, copy, paste operations for multiselect
1 parent fe735f6 commit 15f1d60

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

Diff for: packages/selenium-ide/src/neo/components/TestRow/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class TestRow extends React.Component {
233233
cut() {
234234
if (!this.props.readOnly) {
235235
this.props.copyToClipboard(this.props.command)
236-
this.props.remove(this.props.index, this.props.command)
236+
this.props.remove()
237237
}
238238
}
239239
paste() {
@@ -278,7 +278,7 @@ class TestRow extends React.Component {
278278

279279
remove() {
280280
if (!this.props.readOnly) {
281-
this.props.remove(this.props.index, this.props.command)
281+
this.props.remove()
282282
}
283283
}
284284
async clearAll() {

Diff for: packages/selenium-ide/src/neo/containers/Editor/index.jsx

+12-11
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,18 @@ export default class Editor extends React.Component {
5050
return newCommand
5151
}
5252
}
53-
removeCommand(index, command) {
54-
const { test } = this.props
55-
test.removeCommand(command)
56-
if (UiState.selectedCommand === command) {
57-
if (test.commands.length > index) {
58-
UiState.selectCommand(test.commands[index])
59-
} else if (test.commands.length) {
60-
UiState.selectCommand(test.commands[test.commands.length - 1])
61-
} else {
62-
UiState.selectCommand(UiState.pristineCommand)
63-
}
53+
removeCommand() {
54+
const { test } = this.props;
55+
UiState.selectedCommands.forEach((command) =>
56+
test.removeCommand(command)
57+
);
58+
UiState.clearAllSelectedCommands()
59+
if (test.commands.length > index) {
60+
UiState.selectCommand(test.commands[index]);
61+
} else if (test.commands.length) {
62+
UiState.selectCommand(test.commands[test.commands.length - 1]);
63+
} else {
64+
UiState.selectCommand(UiState.pristineCommand);
6465
}
6566
}
6667
handleKeyDown(event) {

Diff for: packages/selenium-ide/src/neo/stores/view/UiState.js

+22-8
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,29 @@ class UiState {
169169
this.lastViewSelection.clear()
170170
}
171171

172-
@action.bound
173-
copyToClipboard(item) {
174-
this.clipboard = item
172+
@action.bound
173+
copyToClipboard() {
174+
// sorting by index
175+
this.clipboard = this.selectedCommands.sort((c1, c2) =>
176+
{
177+
let c1Index = this.displayedTest.commands.indexOf(c1)
178+
let c2Index = this.displayedTest.commands.indexOf(c2)
179+
return c1Index - c2Index
180+
}
181+
)
175182
}
176183

177-
@action.bound
184+
@action.bound
178185
pasteFromClipboard(index) {
179-
if (this.clipboard && this.displayedTest) {
180-
const newCommand = this.clipboard.clone()
181-
this.displayedTest.insertCommandAt(newCommand, index)
186+
if (this.clipboard.length && this.displayedTest) {
187+
this.clipboard.forEach((command, idx) => {
188+
const newCommand = command.clone();
189+
this.displayedTest.insertCommandAt(newCommand, index + idx + 1);
190+
});
182191
}
183192
}
184193

194+
185195
@computed
186196
get displayedTest() {
187197
return this.selectedTest.stack !== undefined &&
@@ -202,13 +212,17 @@ class UiState {
202212
_test &&
203213
(_test !== this.displayedTest || suite !== this.selectedTest.suite)
204214
) {
215+
216+
if(this.selectedTest.test){
217+
this.selectedTest.test.selectedCommands = this.selectedCommands.slice(0)
218+
}
205219
this.selectedCommands.clear()
206220
this.selectedTest = {
207221
test,
208222
suite,
209223
stack: stack >= 0 ? stack : undefined,
210224
}
211-
this.selectedCommands = this.selectedTest.test.selectedCommands;
225+
this.selectedCommands = this.selectedTest.test.selectedCommands.slice(0);
212226
if (PlaybackState.isPlaying && !PlaybackState.paused) {
213227
this.selectCommand(undefined)
214228
} else if (_test && _test.commands.length) {

0 commit comments

Comments
 (0)