diff --git a/canvas-10-feb/package.json b/canvas-10-feb/package.json index a6fd2aa1095185779e6f1cda7b6ea73aa41dee0e..dcd0b0bf330698d362f5a3e04ff42f1576a33ac7 100644 --- a/canvas-10-feb/package.json +++ b/canvas-10-feb/package.json @@ -12,6 +12,7 @@ "pouchdb": "^7.2.1", "pouchdb-find": "^7.2.1", "vue": "^2.6.11", + "vue-context": "^5.0.0", "vue-draggable-resizable": "^2.1.0", "vue-router": "^3.1.5", "vuex": "^3.1.2" diff --git a/canvas-10-feb/src/store/index.js b/canvas-10-feb/src/store/index.js index c8948b7951dd28f543501db850afdd116e3453de..65fb09ef4fb2322ae6592bc6442d2964c7f97372 100644 --- a/canvas-10-feb/src/store/index.js +++ b/canvas-10-feb/src/store/index.js @@ -75,12 +75,6 @@ const store = new Vuex.Store({ ] }, mutations: { - // CREATE_INDEX() { - // pouchdb.createIndex({ - // index: { fields: ['name'] } - // }) - // }, - CREATE_MICROCOSM(state, doc) { pouchdb.close().then(function() { // console.log(doc) @@ -99,6 +93,48 @@ const store = new Vuex.Store({ }) }, + GET_ALL_NODES(state) { + pouchdb + .allDocs({ + include_docs: true, + attachments: true + }) + .then(function(doc) { + state.microcosm = microcosm + state.allNodes = doc.rows + store.commit('SET_OTHER_NODES') + }) + .catch(function(err) { + console.log(err) + }) + }, + + SET_OTHER_NODES(state) { + state.otherNodes = [] + var i + var j + for (i = 0; i < Object.keys(state.allNodes).length; i++) { + if ( + state.allNodes[i].id != state.myclient && + state.allNodes[i].id != state.global_pos_name + ) { + for ( + j = 0; + j < Object.keys(state.allNodes[i].doc.nodes).length; + j++ + ) { + const newNode = { + nodeid: state.allNodes[i].doc.nodes[j].nodeid, + nodetext: state.allNodes[i].doc.nodes[j].nodetext + } + + state.otherNodes.push(newNode) + } + } + } + //console.log(state.otherNodes) + }, + SET_CLIENT(state, doc) { state.myclient = doc store.commit('GET_MY_NODES') @@ -124,14 +160,14 @@ const store = new Vuex.Store({ _attachments: {}, nodes: [ { - // FIXME: these values are here as GET_NODES cant hunt a blank - // this shouldnt be here + // FIXME: these values are here as GET_ALL_NODES cant hunt a blank + // this shouldnt need to be here index: uniqueid, nodeid: uniqueid, nodetext: state.myclient, nodeowner: state.myclient, content_type: 'sheet', - // TEMP: this hides it by being auto deleted + // TEMP: this hides this node card as its effectivly auto deleted deleted: true, attachment_name: '' } @@ -141,64 +177,6 @@ const store = new Vuex.Store({ }) }, - GET_ALL_NODES(state) { - pouchdb - .allDocs({ - include_docs: true, - attachments: true - }) - .then(function(doc) { - state.microcosm = microcosm - state.allNodes = doc.rows - console.log(state.allNodes) - }) - .catch(function(err) { - console.log(err) - }) - }, - - // GET_NODES(state) { - // //console.log(state) - // pouchdb - // .allDocs({ - // include_docs: true, - // attachments: true - // }) - // .then(function(doc) { - // state.microcosm = microcosm - // }) - // .catch(function(err) { - // console.log(err) - // }) - // }, - - // GET_ALL_NODES(state) { - // pouchdb - // .allDocs({ - // include_docs: true, - // attachments: true - // }) - // .then(function(doc) { - // //state.otherNodes = doc.rows - // var i - // for (i = 0; i < Object.keys(doc.rows).length; i++) { - // console.log(doc.rows[i].doc.nodes) - // //state.otherNodes = doc.rows[i].doc.nodes - // const newNode = { - // index: doc.rows[i].doc.nodes, - // nodeid: doc.rows[i].doc.nodes, - // nodetext: doc.rows[i].doc.nodes - // } - // state.otherNodes.push(newNode) - // } - // console.log(state.otherNodes) - // // doc.rows[i].doc.nodes - // }) - // .catch(function(err) { - // console.log(err) - // }) - // }, - GET_POSITIONS(state) { pouchdb .get(state.global_pos_name) @@ -230,7 +208,7 @@ const store = new Vuex.Store({ pouchdb.get(state.myclient).then(function(doc) { if (e == undefined) { - doc.notes.push({ + doc.nodes.push({ index: uniqueid, nodeid: uniqueid, nodetext: '', @@ -289,15 +267,7 @@ const store = new Vuex.Store({ var i for (i = 0; i < Object.keys(state.myNodes).length; i++) { if (e.nodeid == state.myNodes[i].nodeid) { - var uniqueid = - Math.random() - .toString(36) - .substring(2, 15) + - Math.random() - .toString(36) - .substring(2, 15) - ;(state.myNodes[i].nodetext = e.nodetext), - (state.myNodes[i].index = uniqueid) + state.myNodes[i].nodetext = e.nodetext } } pouchdb diff --git a/canvas-10-feb/src/views/Home.vue b/canvas-10-feb/src/views/Home.vue index e207385786b634b3632bacae8b9257b04ecf1489..ee177861e615887fe571e5c187d29e7844df71ff 100644 --- a/canvas-10-feb/src/views/Home.vue +++ b/canvas-10-feb/src/views/Home.vue @@ -1,18 +1,19 @@ <template> <div class="home"> <div v-if="clientset"> - <NodesLayer - v-for="value in myNodes" + <OtherNodeslayer + v-for="value in otherNodes" v-bind:key="value.nodeid" v-bind:nodeid="value.nodeid" v-bind:nodetext="value.nodetext" /> - <OtherNodeslayer - v-for="value in otherNodes" + <NodesLayer + v-for="value in myNodes" v-bind:key="value.nodeid" v-bind:nodeid="value.nodeid" v-bind:nodetext="value.nodetext" /> + <CanvasLayer /> <ControlsLayer /> </div> diff --git a/canvas-10-feb/yarn.lock b/canvas-10-feb/yarn.lock index 1a520fd794f066e93fbb959141edb6c02d472f65..ba0df1de4047543ea84eee24f2cfe618c5aa6227 100644 --- a/canvas-10-feb/yarn.lock +++ b/canvas-10-feb/yarn.lock @@ -4416,7 +4416,7 @@ loglevel@^1.6.6: version "1.6.6" resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.6.tgz#0ee6300cc058db6b3551fa1c4bf73b83bb771312" -loose-envify@^1.0.0: +loose-envify@^1.0.0, loose-envify@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" dependencies: @@ -7143,6 +7143,18 @@ vm-browserify@^1.0.1: version "1.1.2" resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" +vue-clickaway@^2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/vue-clickaway/-/vue-clickaway-2.2.2.tgz#cecf6839575e8b2afc5d3edb3efb616d293dbb44" + dependencies: + loose-envify "^1.2.0" + +vue-context@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/vue-context/-/vue-context-5.0.0.tgz#7f9a90bb00a45eba6aad1d49fdf9e0a946bf503f" + dependencies: + vue-clickaway "^2.2.2" + vue-draggable-resizable@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/vue-draggable-resizable/-/vue-draggable-resizable-2.1.0.tgz#b590212aef3c07d040aeceda784438068170fb08"