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