Commit 1750cc62 authored by Adam Procter's avatar Adam Procter

getting positions to place initialisation

have data now need to update with x and y pos for SVG objects. Should be able to just blast it in without comparing as ordering will be same but this may prove to be a poor approach
parent 5682cfa0
Pipeline #219 failed with stages
in 1 minute
......@@ -34,7 +34,8 @@ export default {
},
methods: {
...mapGetters(["allObjects"])
...mapGetters(["allObjects"]),
...mapGetters(["allPositions"])
},
props: {
......@@ -44,13 +45,19 @@ export default {
// SVG UI next
var draw = SVG("user-interface").size(600, 300);
var data = [];
var data2 = [];
let objects = this.allObjects();
//console.log(objects)
objects.forEach(element => {
data.push(element.__ob__.value.doc);
});
//console.log(data)
let positions = this.allPositions();
console.log(positions)
positions.forEach(element => {
data2.push(element.__ob__.value.doc);
});
var links = draw.group();
var markers = draw.group();
......@@ -59,12 +66,22 @@ export default {
var index = 0;
var colours = ["red", "green", "blue", "yellow", "cyan"];
data2.forEach(element => {
console.log(element.xpos)
console.log(element.id)
});
data.forEach(element => {
//index = index + 20
knowledgeObj = nodes
.group()
.draggy({ minX: 0, minY: 0, maxX: 600, maxY: 300 });
// assign node id to the unique id in database
knowledgeObj.node.id = element._id;
if (element.type == "projecttxt") {
// get the correct x and y pos from positions information
......@@ -81,17 +98,18 @@ export default {
fill: colours[Math.floor(Math.random() * colours.length)]
});
}
// var type = knowledgeObj.text(element.type);
// var title = knowledgeObj.text(element.title);
// var uniqueid = knowledgeObj.text(element._id);
// assign node id to the unique id in database
knowledgeObj.node.id = element._id;
//console.log(knowledgeObj.node.id);
// parentNode
// title.move(0, 40);
// uniqueid.move(0, 80);
// Visualising whats in the couch
// var type = knowledgeObj.text(element.type);
// var title = knowledgeObj.text(element.title);
// var uniqueid = knowledgeObj.text(element._id);
// title.move(0, 40);
// uniqueid.move(0, 80);
// rect_1.connectable({
// container: links,
......
......@@ -78,6 +78,18 @@ export default new Vuex.Store({
if (!ids.includes(payload.id)) {
state.allobjects.push(payload);
}
},
GET_KNOWLEDGE_POSITIONS(state, payload) {
var ids = [];
state.allpositions.forEach(payload => {
ids.push(payload.id);
});
if (!ids.includes(payload.id)) {
state.allpositions.push(payload);
}
},
ADD_KNOWLEDGE_OBJECT(data, payload) {
......@@ -153,7 +165,7 @@ export default new Vuex.Store({
})
.then(result => {
Array.from(result.rows.values()).forEach(element => {
commit("SHOW_KNOWLEDGE_OBJECTS", element);
commit("GET_KNOWLEDGE_POSITIONS", element);
});
});
},
......@@ -190,6 +202,9 @@ export default new Vuex.Store({
},
allObjects: state => {
return state.allobjects;
},
allPositions: state => {
return state.allpositions;
}
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment