Fix sorting code for steps > 1

pull/35/head
Ondřej Hruška 6 years ago
parent 786c18cec9
commit e7a1e38e18
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 20
      resources/assets/js/components/ColumnEditor.vue

@ -193,17 +193,21 @@ export default {
}
},
/** Swap column in either direction (+1 or -1) */
/** Move a column (dir is positive or negative) */
move (pos1, dir) {
let pos2 = pos1 + dir
if (pos2 < 0 || pos2 >= this.columns.length) {
console.warn(`Attempted to move out of bounds (${pos1} -> ${pos2})`)
return;
// clamp
if (pos2 < 0) {
pos2 = 0
} else if (pos2 >= this.columns.length) {
pos2 = this.columns.length - 1
}
let col1 = this.columns[pos1]
let col2 = this.columns[pos2]
this.$set(this.columns, pos1, col2)
this.$set(this.columns, pos2, col1)
let columns = this.columns
let col1 = columns.splice(pos1, 1)[0] // unwrap returned 1-element array
columns.splice(pos2, 0, col1)
this.columns = columns
},
/** Indicate a column is dirty and needs saving */

Loading…
Cancel
Save