Fix sorting code for steps > 1
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user