Commit 947a7ffb authored by Adam Procter's avatar Adam Procter
Browse files

fixed some typos and added shape selection

parent 5fd7cb1c
<template> <template>
<div v-for="(nodes, index) in myArray" :key="index"> <div v-for="(nodes, index) in myArray" :key="index">
<form class="nodes"> <form class="nodes">
<template v-if="nodes.read_mode == false"> <template v-if="nodes.node_readmode == false">
<textarea <textarea
v-model="nodes.node_text" v-model="nodes.node_text"
@input="editNode" @input="editNode"
...@@ -25,11 +25,15 @@ ...@@ -25,11 +25,15 @@
<button @click.prevent>{{ nodes.node_color }}</button> <button @click.prevent>{{ nodes.node_color }}</button>
</template> </template>
</VSwatches> </VSwatches>
<select v-model="nodes.node_shape"> <select
<option value="">Square</option> v-model="nodes.node_shape"
<option value="">Circle</option> @input="setShape"
<option value="">Triangle</option> :id="nodes.node_id"
<option value="">Hexegon</option> >
<option value="square">Square</option>
<option value="circle">Circle</option>
<option value="triangle">Triangle</option>
<option value="hexegon">Hexegon</option>
</select> </select>
<button @click.prevent="toggleMode(nodes.node_id)">Read</button> <button @click.prevent="toggleMode(nodes.node_id)">Read</button>
...@@ -126,15 +130,19 @@ export default { ...@@ -126,15 +130,19 @@ export default {
}, },
chooseColor(nodeid, color) { chooseColor(nodeid, color) {
// TESTING method is even being called // var nodeid = e.target.id
if (confirm('Confirm change?')) { // var color = e.target.value
this.$store.dispatch('colorNode', { nodeid, color })
setTimeout(this.loadData, 500) this.$store.dispatch('colorNode', { nodeid, color })
} else { setTimeout(this.loadData, 500)
// nothing happens },
}
// this.$store.dispatch('colorNode', { nodeid, color }) setShape(e) {
// setTimeout(this.loadData, 500) var nodeid = e.target.id
var shape = e.target.value
this.$store.dispatch('setShape', { nodeid, shape })
setTimeout(this.loadData, 500)
}, },
}, },
} }
......
...@@ -186,7 +186,6 @@ export const mutations = { ...@@ -186,7 +186,6 @@ export const mutations = {
{ {
_id: deviceName, _id: deviceName,
_rev: doc._rev, _rev: doc._rev,
_attachments: doc._attachments,
nodes: state.myNodes, nodes: state.myNodes,
}, },
]) ])
...@@ -204,14 +203,14 @@ export const mutations = { ...@@ -204,14 +203,14 @@ export const mutations = {
for (i = 0; i < Object.keys(state.myNodes).length; i++) { for (i = 0; i < Object.keys(state.myNodes).length; i++) {
if ( if (
e.e == state.myNodes[i].node_id && e.e == state.myNodes[i].node_id &&
state.myNodes[i].read_mode == false state.myNodes[i].node_readmode == false
) { ) {
state.myNodes[i].read_mode = true state.myNodes[i].node_readmode = true
} else if ( } else if (
e.e == state.myNodes[i].node_id && e.e == state.myNodes[i].node_id &&
state.myNodes[i].read_mode == true state.myNodes[i].node_readmode == true
) { ) {
state.myNodes[i].read_mode = false state.myNodes[i].node_readmode = false
} }
} }
pouchdb pouchdb
...@@ -259,6 +258,36 @@ export const mutations = { ...@@ -259,6 +258,36 @@ export const mutations = {
}) })
.catch(function () {}) .catch(function () {})
}, },
SET_SHAPE(state, e) {
var i
for (i = 0; i < Object.keys(state.myNodes).length; i++) {
if (e.nodeid == state.myNodes[i].node_id) {
state.myNodes[i].node_shape = e.shape
}
}
pouchdb
.get(deviceName)
.then(function (doc) {
return pouchdb.bulkDocs([
{
_id: deviceName,
_rev: doc._rev,
nodes: state.myNodes,
},
])
})
.then(function () {
return pouchdb.get(deviceName).then(function (doc) {
state.myNodes = doc.nodes
})
})
.catch(function (err) {
if (err.status == 404) {
// pouchdb.put({ })
}
})
},
} }
export const actions = { export const actions = {
...@@ -290,6 +319,10 @@ export const actions = { ...@@ -290,6 +319,10 @@ export const actions = {
commit('COLOR_NODE', { nodeid, color }) commit('COLOR_NODE', { nodeid, color })
}, },
setShape: ({ commit }, { nodeid, shape }) => {
commit('SET_SHAPE', { nodeid, shape })
},
getMicrocosm(vuexContext) { getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName deviceName = vuexContext.rootState.setup.deviceName
// microcosmName = vuexContext.rootState.setup.microcosmName // microcosmName = vuexContext.rootState.setup.microcosmName
......
Supports Markdown
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