Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Commit 6eb78ce9 authored by Adam Procter's avatar Adam Procter
Browse files

updates to myNodes

parent e4de5675
# 0.2.2
_1st September 2021_
## Added
- you can now discard nodes
- you can now toggle read and edit view of each node
# 0.2.1
_31st August 2021_
......
......@@ -14,6 +14,7 @@
"pouchdb": "^7.2.2",
"vue": "^3.2.6",
"vue-router": "^4.0.0",
"vue3-swatches": "^1.0.2",
"vuex": "^4.0.0"
},
"devDependencies": {
......
......@@ -11,8 +11,27 @@
rows="5"
></textarea>
<p class="info">*markdown supported &amp; autosaves</p>
<button>Colour</button>
<button>Shape</button>
<VSwatches
v-model="nodes.node_color"
@input="chooseColor(nodes.node_id, nodes.node_color)"
:swatches="swatches"
:shapes="shapes"
show-border
show-fallback
fallback-input-type="color"
>
<template v-slot:trigger>
<button @click.prevent>{{ nodes.node_color }}</button>
</template>
</VSwatches>
<select v-model="nodes.node_shape">
<option value="">Square</option>
<option value="">Circle</option>
<option value="">Triangle</option>
<option value="">Hexegon</option>
</select>
<button @click.prevent="toggleMode(nodes.node_id)">Read</button>
<button @click.prevent="discardNode(nodes.node_id)">Discard</button>
</template>
......@@ -27,12 +46,14 @@
<script>
// @ is an alias to /src
import { mapState } from 'vuex'
import VSwatches from 'vue3-swatches'
// import marked from 'marked'
export default {
name: 'MyNodes',
components: { VSwatches },
props: {
added: Boolean,
},
......@@ -40,6 +61,14 @@ export default {
data() {
return {
myArray: [],
shapes: 'circles',
// swatches: [{ color: '#F493A7', showBorder: true }],
swatches: [
['#EB5757', '#F2994A', '#F2C94C'],
['#219653', '#27AE60', '#6FCF97'],
['#2F80ED', '#2D9CDB', '#56CCF2'],
['#9B51E0', '#BB6BD9', '#E9B7FC'],
],
}
},
......@@ -95,6 +124,17 @@ export default {
this.$store.dispatch('toggleMode', { e })
setTimeout(this.loadData, 500)
},
chooseColor(nodeid, color) {
if (confirm('Confirm change?')) {
this.$store.dispatch('colorNode', { nodeid, color })
setTimeout(this.loadData, 500)
} else {
// nothing happens
}
// this.$store.dispatch('colorNode', { nodeid, color })
// setTimeout(this.loadData, 500)
},
},
}
</script>
......
......@@ -233,6 +233,32 @@ export const mutations = {
})
.catch(function () {})
},
COLOR_NODE(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_color = e.color
}
}
pouchdb
.get(deviceName)
.then(function (doc) {
return pouchdb.bulkDocs([
{
_id: state.myclient,
_rev: doc._rev,
nodes: state.myNodes,
},
])
})
.then(function () {
return pouchdb.get(deviceName).then(function (doc) {
state.myNodes = doc.nodes
})
})
.catch(function () {})
},
}
export const actions = {
......@@ -260,6 +286,10 @@ export const actions = {
commit('TOGGLE_MODE', e)
},
colorNode: ({ commit }, { nodeid, color }) => {
commit('COLOR_NODE', { nodeid, color })
},
getMicrocosm(vuexContext) {
deviceName = vuexContext.rootState.setup.deviceName
// microcosmName = vuexContext.rootState.setup.microcosmName
......
......@@ -7668,6 +7668,11 @@ vue-template-es2015-compiler@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
vue3-swatches@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/vue3-swatches/-/vue3-swatches-1.0.2.tgz#118b06c6c47d51ce1d2b18c588f13b90fea897fd"
integrity sha512-XxopqMhNSfxorsIqTwW+2A544DvBOC3w6f6vDdPQNbuaJ3Sm9iqchzGAI9o37M6eRxByOplBWQ/i6ZPBGTIabw==
vue@^3.2.6:
version "3.2.6"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.6.tgz#c71445078751f458648fd8fb3a2da975507d03d2"
......
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