mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Added multi droppable handling
Now just need to style it
This commit is contained in:
@@ -16,28 +16,38 @@ export default class TableSettings extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleOnDragEnd = (result) => {
|
handleOnDragEnd = (result) => {
|
||||||
|
console.log(result);
|
||||||
if (!result.destination) return;
|
if (!result.destination) return;
|
||||||
|
|
||||||
let data = this.state.visible;
|
let visible = this.state.visible;
|
||||||
let array = data.obj.value;
|
let hidden = this.state.hidden;
|
||||||
|
|
||||||
let reorderedItem = array.splice(result.source.index, 1);
|
let from = result.source.droppableId == 'visibleColumns' ? visible.obj.value : hidden.obj.value;
|
||||||
array.splice(result.destination.index, 0, reorderedItem[0]);
|
let to = result.destination.droppableId == 'visibleColumns' ? visible.obj.value : hidden.obj.value;
|
||||||
data.obj.value = array;
|
|
||||||
|
|
||||||
console.log(array);
|
let [reorderedItem] = from.splice(result.source.index, 1);
|
||||||
|
to.splice(result.destination.index, 0, reorderedItem);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
visible: data
|
visible: visible,
|
||||||
|
hidden: hidden
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
save = () => {
|
save = () => {
|
||||||
var url = 'api/settings?token=' + window.token;
|
var url = 'api/settings/bulk?token=' + window.token;
|
||||||
|
|
||||||
Axios.post(url, {
|
Axios.post(url, {
|
||||||
name: 'visible_columns',
|
data: [
|
||||||
value: this.state.data.obj.value
|
{
|
||||||
|
name: 'visible_columns',
|
||||||
|
value: this.state.visible.obj.value
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'hidden_columns',
|
||||||
|
value: this.state.hidden.obj.value
|
||||||
|
}
|
||||||
|
],
|
||||||
})
|
})
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
console.log(resp);
|
console.log(resp);
|
||||||
|
|||||||
Reference in New Issue
Block a user