This commit is contained in:
@@ -129,16 +129,16 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
dashMoveStart: function(id) {
|
dashMoveStart: function(id) {
|
||||||
console.log("home-dashboard:dashMoveStart", id);
|
this.move("start", id);
|
||||||
},
|
},
|
||||||
dashMoveBack: function(id) {
|
dashMoveBack: function(id) {
|
||||||
console.log("home-dashboard:dashMoveBack", id);
|
this.move("left", id);
|
||||||
},
|
},
|
||||||
dashMoveForward: function(id) {
|
dashMoveForward: function(id) {
|
||||||
console.log("home-dashboard:dashMoveForward", id);
|
this.move("right", id);
|
||||||
},
|
},
|
||||||
dashMoveEnd: function(id) {
|
dashMoveEnd: function(id) {
|
||||||
console.log("home-dashboard:dashMoveEnd", id);
|
this.move("end", id);
|
||||||
},
|
},
|
||||||
dashRemove: function(id) {
|
dashRemove: function(id) {
|
||||||
let index = this.getEffectiveViewItemIndexById(id);
|
let index = this.getEffectiveViewItemIndexById(id);
|
||||||
@@ -148,13 +148,43 @@ export default {
|
|||||||
this.effectiveView.splice(index, 1);
|
this.effectiveView.splice(index, 1);
|
||||||
this.saveView();
|
this.saveView();
|
||||||
},
|
},
|
||||||
// dashRefresh: function(item) {
|
move: function(direction, id) {
|
||||||
// v-on:dash-refresh="dashRefresh"
|
let index = this.getEffectiveViewItemIndexById(id);
|
||||||
// console.log(
|
if (index == -1) {
|
||||||
// "home-dashboard:refresh (normally handle @ typed dash control)",
|
return;
|
||||||
// item
|
}
|
||||||
// );
|
|
||||||
// },
|
let totalItems = this.effectiveView.length;
|
||||||
|
let newIndex = 0;
|
||||||
|
//calculate new index
|
||||||
|
switch (direction) {
|
||||||
|
case "start":
|
||||||
|
newIndex = 0;
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
newIndex = index - 1;
|
||||||
|
if (newIndex < 0) {
|
||||||
|
newIndex = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "right":
|
||||||
|
newIndex = index + 1;
|
||||||
|
if (newIndex > totalItems - 1) {
|
||||||
|
newIndex = totalItems - 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "end":
|
||||||
|
newIndex = totalItems - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.effectiveView.splice(
|
||||||
|
newIndex,
|
||||||
|
0,
|
||||||
|
this.effectiveView.splice(index, 1)[0]
|
||||||
|
);
|
||||||
|
this.saveView();
|
||||||
|
},
|
||||||
getEffectiveViewItemIndexById: function(id) {
|
getEffectiveViewItemIndexById: function(id) {
|
||||||
return this.effectiveView.findIndex(z => z.id == id);
|
return this.effectiveView.findIndex(z => z.id == id);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user