diff --git a/resources/assets/js/components/ColumnEditor.vue b/resources/assets/js/components/ColumnEditor.vue index 14335f2..4b049fe 100644 --- a/resources/assets/js/components/ColumnEditor.vue +++ b/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 */