Commit 5682cfa0 authored by Adam Procter's avatar Adam Procter

edits

parent ab1ad312
Pipeline #218 failed with stages
in 58 seconds
......@@ -26,23 +26,17 @@ export default {
data: function() {
return {
// data: [],
// id:1
// mode:"shared"
id:null,
xpos:null,
ypos:null,
id: null,
xpos: null,
ypos: null,
isShowing: false
};
},
methods: {
...mapGetters(["allObjects"])
},
props: {
//object: Object
},
......@@ -73,6 +67,7 @@ export default {
.draggy({ minX: 0, minY: 0, maxX: 600, maxY: 300 });
if (element.type == "projecttxt") {
// get the correct x and y pos from positions information
knowledgeObj.rect(60, 40).attr({
fill: colours[Math.floor(Math.random() * colours.length)]
//.svg('<g id="doc" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect id="Rectangle-2" fill="#000000" x="3" y="0" width="115" height="171"></rect><rect id="Rectangle" stroke="#FFFFFF" stroke-width="7" x="3.5" y="3.5" width="113" height="164"></rect><path d="M23.5,40.5 L95,40.5" id="Line-3" stroke="#979797" stroke-width="4" stroke-linecap="square"></path><path d="M24.5,54.25 L96,54.25" id="Line-3-Copy" stroke="#979797" stroke-width="4" stroke-linecap="square"></path><path d="M24.5,69.25 L96,69.25" id="Line-3-Copy-2" stroke="#979797" stroke-width="4" stroke-linecap="square"></path><path d="M24.5,86.25 L70,86.25" id="Line-3-Copy-3" stroke="#979797" stroke-width="4" stroke-linecap="square"></path></g>')
......@@ -81,20 +76,19 @@ export default {
knowledgeObj.circle(30, 30).attr({
fill: colours[Math.floor(Math.random() * colours.length)]
});
} else {
knowledgeObj.ellipse(20, 50).attr({
knowledgeObj.ellipse(20, 50).attr({
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);
// 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
// parentNode
// title.move(0, 40);
// uniqueid.move(0, 80);
......@@ -110,23 +104,6 @@ export default {
nodes.mousedown(node => {
console.log("start connect");
});
// mouseup is where we capture position of objects after they have been moved
// FIXME: determine unique ID of the node that has been moved
// FIXME: associate each node with a knowledge object in the db
// so we have a mapping to record these movements
//nodes.mouseup(node => {
// this logs out the final id in the array it doesnt know which one I moved...
// node.clientX and Y is fine different thing
// console.log(currentTarget)
// just gets the last id in the list not the one dragged
// console.log(knowledgeObj.native().id)
//this.fill({ color: '#f06' })
//knowledgeObj.fill({ color: '#f06' })
// console.log("x: "+node.clientX)
// console.log("y: "+node.clientY)
//node.first().remove()
// })
nodes.mouseup(event => {
// FIX ME : we know the id and the locations to
......@@ -143,7 +120,6 @@ export default {
// the svgjs object
//console.log(SVG.adopt(event.target))
});
nodes.dblclick(node => {
......
......@@ -23,6 +23,7 @@ export default new Vuex.Store({
state: {
// should this be here now
allobjects: [],
allpositions:[],
database: null,
isLoggedIn: !!localStorage.getItem("token")
},
......@@ -69,7 +70,7 @@ export default new Vuex.Store({
SHOW_KNOWLEDGE_OBJECTS(state, payload) {
var ids = [];
var knowledge = [];
//var knowledge = [];
state.allobjects.forEach(payload => {
ids.push(payload.id);
......@@ -109,22 +110,21 @@ export default new Vuex.Store({
pouchdb.sync("positions", "https://nn.adamprocter.co.uk/positions");
},
// FIXME called on mouse up but not always heard..
UPDATE_KNOWLEDGE_POSITION(data, payload) {
console.log(payload.id)
var id = payload.id
id.toString()
positions_db.get(id).then(function (updater) {
updater.xpos = payload.xpos,
updater.ypos = payload.ypos,
positions_db.put(updater).then(function(){
// FIXME this does sync but does it pass the changes we want to capture via VUEX STORE
pouchdb.sync("positions", "https://nn.adamprocter.co.uk/positions");
console.log(payload.id);
var id = payload.id;
id.toString();
positions_db.get(id).then(function(updater) {
(updater.xpos = payload.xpos),
(updater.ypos = payload.ypos),
positions_db.put(updater).then(function() {
// FIXME this does sync but does it pass the changes we want to capture via VUEX STORE
pouchdb.sync("positions", "https://nn.adamprocter.co.uk/positions");
});
});
})
}
},
}
},
actions: {
db_init({ commit }) {
......@@ -146,6 +146,16 @@ export default new Vuex.Store({
commit("SHOW_KNOWLEDGE_OBJECTS", element);
});
});
positions_db
.allDocs({
include_docs: true,
attachments: true
})
.then(result => {
Array.from(result.rows.values()).forEach(element => {
commit("SHOW_KNOWLEDGE_OBJECTS", element);
});
});
},
addKnowledgeObject({ commit }, payload) {
......
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