|
|
|
@ -170,10 +170,12 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
/** Send a query to the server */ |
|
|
|
|
query (data, sucfn, erfn) { |
|
|
|
|
query(this.route, data, sucfn, erfn) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** Add a column at the end */ |
|
|
|
|
addCol () { |
|
|
|
|
if (this.newTable) { |
|
|
|
|
this.columns.push({ |
|
|
|
@ -191,17 +193,25 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
move (i, dir) { |
|
|
|
|
let cur = this.columns[i] |
|
|
|
|
let next = this.columns[i + dir] |
|
|
|
|
this.$set(this.columns, i, next) |
|
|
|
|
this.$set(this.columns, i + dir, cur) |
|
|
|
|
/** Swap column in either direction (+1 or -1) */ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
let col1 = this.columns[pos1] |
|
|
|
|
let col2 = this.columns[pos2] |
|
|
|
|
this.$set(this.columns, pos1, col2) |
|
|
|
|
this.$set(this.columns, pos2, col1) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** Indicate a column is dirty and needs saving */ |
|
|
|
|
markColNeedSave(i) { |
|
|
|
|
this.$set(this.columns[i], '_dirty', true) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** User started dragging a column */ |
|
|
|
|
beginDrag (i, evt) { |
|
|
|
|
const column = this.columns[i] |
|
|
|
|
column._dragging = true |
|
|
|
@ -241,6 +251,7 @@ export default { |
|
|
|
|
$(window).on('mouseup', dragEndListener) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** Compute classes for the column's delete button */ |
|
|
|
|
delBtnClass(col) { |
|
|
|
|
return [ |
|
|
|
|
'btn', |
|
|
|
@ -251,6 +262,7 @@ export default { |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** Save a column */ |
|
|
|
|
saveCol(n) { |
|
|
|
|
let col = this.columns[n] |
|
|
|
|
if (_.isUndefined(col)) return |
|
|
|
@ -267,6 +279,7 @@ export default { |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** Delete / undelete a column; New columns vanish. */ |
|
|
|
|
toggleColDelete(n) { |
|
|
|
|
let col = this.columns[n] |
|
|
|
|
if (_.isUndefined(col)) return |
|
|
|
|