Skip to content
Snippets Groups Projects
Commit 8db73a45 authored by Adam Procter's avatar Adam Procter
Browse files

Merge branch 'fixhandles'

parents 155dd674 a623ff83
No related branches found
No related tags found
No related merge requests found
# 0.1.2
_1st March 2020_
### Added
- Imported missing css for handles for vue draggable, nodes are now resizable
- Size of node is also sync'd in realtime cross devices
# 0.1.1 # 0.1.1
_29th Feb 2020_ _29th Feb 2020_
......
{ {
"name": "nodenogg.in", "name": "nodenogg.in",
"version": "0.1.1", "version": "0.1.2",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
......
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
<div class="debug"> <div class="debug">
<hr /> <hr />
<!-- <h2>Debug Options</h2> --> <!-- <h2>Debug Options</h2> -->
<h4>LAST UPDATE 29th Feb 2020.</h4> <h4>LAST UPDATE 1st March 2020.</h4>
<p>You need to know what this button does before you press it.</p> <p>You need to know what this button does before you press it.</p>
<button class="danger" @click="removeLocal()">Join another microcosm</button> <button class="danger" @click="removeLocal()">
Join another microcosm
</button>
<!-- <button @click="exportStorage()">Export my contributions</button> <!-- <button @click="exportStorage()">Export my contributions</button>
<button class="danger" v-on:click="deleteClient"> <button class="danger" v-on:click="deleteClient">
Delete my contributions (inc. attachments) permanently Delete my contributions (inc. attachments) permanently
......
...@@ -2,14 +2,17 @@ ...@@ -2,14 +2,17 @@
<div ref="nodes" class="node"> <div ref="nodes" class="node">
<div v-for="(value, index) in configPositions" v-bind:key="index"> <div v-for="(value, index) in configPositions" v-bind:key="index">
<vue-draggable-resizable <vue-draggable-resizable
class="innernode"
v-if="nodeid == value.nodeid" v-if="nodeid == value.nodeid"
:w="200" :w="value.width"
:h="250" :h="value.height"
:x="value.xpos" :x="value.xpos"
:y="value.ypos" :y="value.ypos"
@activated="onActivated"
@dragging="onDrag" @dragging="onDrag"
@resizing="onResize" @resizing="onResize"
@dragstop="onDragstop" @dragstop="onDragstop"
@resizestop="onResizestop"
style="background-color: rgb(205, 234, 255);" style="background-color: rgb(205, 234, 255);"
> >
<form> <form>
...@@ -28,9 +31,7 @@ ...@@ -28,9 +31,7 @@
</div>--> </div>-->
<p>markdown supported</p> <p>markdown supported</p>
<button class="danger" @click="deleteFlag()"> <button class="danger" @click="deleteFlag()">Delete</button>
Delete
</button>
</form> </form>
</vue-draggable-resizable> </vue-draggable-resizable>
</div> </div>
...@@ -43,13 +44,18 @@ import { mapState } from 'vuex' ...@@ -43,13 +44,18 @@ import { mapState } from 'vuex'
export default { export default {
name: 'NodesLayer', name: 'NodesLayer',
props: { nodeid: String, nodetext: String }, props: {
nodeid: String,
nodetext: String,
nodewidth: Number,
nodeheight: Number
},
data() { data() {
return { return {
thistext: this.nodetext, thistext: this.nodetext,
width: 0, width: this.nodewidth,
height: 0, height: this.nodeheight,
localx: 0, localx: 0,
localy: 0 localy: 0
} }
...@@ -63,19 +69,43 @@ export default { ...@@ -63,19 +69,43 @@ export default {
configPositions: state => state.configPositions configPositions: state => state.configPositions
}), }),
methods: { methods: {
onActivated() {
var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) {
this.width = this.configPositions[i].width
this.height = this.configPositions[i].height
}
}
},
onResize(x, y, width, height) { onResize(x, y, width, height) {
this.localx = x this.localx = x
this.localy = y this.localy = y
this.width = width this.width = width
this.height = height this.height = height
}, },
onResizestop(x, y, width, height) {
var localnodeid = this.nodeid
var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) {
this.width = this.configPositions[i].width
this.height = this.configPositions[i].height
}
}
this.width = width
this.height = height
this.$store.dispatch('movePos', { localnodeid, x, y, width, height })
},
onDrag(x, y) { onDrag(x, y) {
this.localx = x this.localx = x
this.localy = y this.localy = y
}, },
onDragstop(x, y) { onDragstop(x, y, width, height) {
var localnodeid = this.nodeid var localnodeid = this.nodeid
width = this.width
height = this.height
var i var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) { for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) { if (this.configPositions[i].nodeid == this.nodeid) {
...@@ -83,7 +113,7 @@ export default { ...@@ -83,7 +113,7 @@ export default {
this.localy = this.configPositions[i].ypos this.localy = this.configPositions[i].ypos
} }
} }
this.$store.dispatch('movePos', { localnodeid, x, y }) this.$store.dispatch('movePos', { localnodeid, x, y, width, height })
}, },
setFocus() { setFocus() {
...@@ -105,12 +135,11 @@ export default { ...@@ -105,12 +135,11 @@ export default {
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style scoped>
.node { .node {
background-color: rgb(207, 177, 235);
position: relative; position: relative;
} }
textarea { textarea {
width: 195px; width: 100%;
height: 120px; height: 120px;
resize: none; resize: none;
} }
......
...@@ -3,13 +3,15 @@ ...@@ -3,13 +3,15 @@
<div v-for="(value, index) in configPositions" v-bind:key="index"> <div v-for="(value, index) in configPositions" v-bind:key="index">
<vue-draggable-resizable <vue-draggable-resizable
v-if="nodeid == value.nodeid" v-if="nodeid == value.nodeid"
:w="200" :w="value.width"
:h="250" :h="value.height"
:x="value.xpos" :x="value.xpos"
:y="value.ypos" :y="value.ypos"
@activated="onActivated"
@dragging="onDrag" @dragging="onDrag"
@resizing="onResize" @resizing="onResize"
@dragstop="onDragstop" @dragstop="onDragstop"
@resizestop="onResizestop"
style="border: 1px solid black; background-color: rgb(205, 234, 255);" style="border: 1px solid black; background-color: rgb(205, 234, 255);"
> >
<p :id="nodeid" :inner-html.prop="nodetext | marked">{{ nodeid }}</p> <p :id="nodeid" :inner-html.prop="nodetext | marked">{{ nodeid }}</p>
...@@ -25,13 +27,18 @@ import marked from 'marked' ...@@ -25,13 +27,18 @@ import marked from 'marked'
export default { export default {
name: 'otherNodeslayer', name: 'otherNodeslayer',
props: { nodeid: String, nodetext: String }, props: {
nodeid: String,
nodetext: String,
nodewidth: Number,
nodeheight: Number
},
data() { data() {
return { return {
thistext: this.nodetext, thistext: this.nodetext,
width: 0, width: this.nodewidth,
height: 0, height: this.nodeheight,
localx: 0, localx: 0,
localy: 0 localy: 0
} }
...@@ -47,19 +54,42 @@ export default { ...@@ -47,19 +54,42 @@ export default {
configPositions: state => state.configPositions configPositions: state => state.configPositions
}), }),
methods: { methods: {
onActivated() {
var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) {
this.width = this.configPositions[i].width
this.height = this.configPositions[i].height
}
}
},
onResize(x, y, width, height) { onResize(x, y, width, height) {
this.localx = x this.localx = x
this.localy = y this.localy = y
this.width = width this.width = width
this.height = height this.height = height
}, },
onResizestop(x, y, width, height) {
var localnodeid = this.nodeid
var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) {
this.width = this.configPositions[i].width
this.height = this.configPositions[i].height
}
}
this.width = width
this.height = height
this.$store.dispatch('movePos', { localnodeid, x, y, width, height })
},
onDrag(x, y) { onDrag(x, y) {
this.localx = x this.localx = x
this.localy = y this.localy = y
}, },
onDragstop(x, y) { onDragstop(x, y, width, height) {
var localnodeid = this.nodeid var localnodeid = this.nodeid
width = this.width
height = this.height
var i var i
for (i = 0; i < Object.keys(this.configPositions).length; i++) { for (i = 0; i < Object.keys(this.configPositions).length; i++) {
if (this.configPositions[i].nodeid == this.nodeid) { if (this.configPositions[i].nodeid == this.nodeid) {
...@@ -67,7 +97,7 @@ export default { ...@@ -67,7 +97,7 @@ export default {
this.localy = this.configPositions[i].ypos this.localy = this.configPositions[i].ypos
} }
} }
this.$store.dispatch('movePos', { localnodeid, x, y }) this.$store.dispatch('movePos', { localnodeid, x, y, width, height })
} }
} }
} }
......
...@@ -3,6 +3,7 @@ import Vuex from 'vuex' ...@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import PouchDB from 'pouchdb' import PouchDB from 'pouchdb'
PouchDB.plugin(require('pouchdb-find')) PouchDB.plugin(require('pouchdb-find'))
import VueDraggableResizable from 'vue-draggable-resizable' import VueDraggableResizable from 'vue-draggable-resizable'
import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
Vue.use(Vuex) Vue.use(Vuex)
Vue.component('vue-draggable-resizable', VueDraggableResizable) Vue.component('vue-draggable-resizable', VueDraggableResizable)
...@@ -193,12 +194,13 @@ const store = new Vuex.Store({ ...@@ -193,12 +194,13 @@ const store = new Vuex.Store({
}, },
MOVE_POS(state, e) { MOVE_POS(state, e) {
//console.log(e.localnodeid)
var i var i
for (i = 0; i < Object.keys(state.configPositions).length; i++) { for (i = 0; i < Object.keys(state.configPositions).length; i++) {
if (e.localnodeid == state.configPositions[i].nodeid) { if (e.localnodeid == state.configPositions[i].nodeid) {
state.configPositions[i].xpos = e.x state.configPositions[i].xpos = e.x
state.configPositions[i].ypos = e.y state.configPositions[i].ypos = e.y
state.configPositions[i].width = e.width
state.configPositions[i].height = e.height
} }
} }
...@@ -278,7 +280,9 @@ const store = new Vuex.Store({ ...@@ -278,7 +280,9 @@ const store = new Vuex.Store({
doc.positions.push({ doc.positions.push({
nodeid: uniqueid, nodeid: uniqueid,
xpos: 50, xpos: 50,
ypos: 50 ypos: 50,
width: 200,
height: 250
}) })
return pouchdb return pouchdb
.put({ .put({
...@@ -399,8 +403,8 @@ const store = new Vuex.Store({ ...@@ -399,8 +403,8 @@ const store = new Vuex.Store({
commit('SET_CLIENT', e) commit('SET_CLIENT', e)
}, },
movePos: ({ commit }, nodeid, xpos, ypos) => { movePos: ({ commit }, nodeid, xpos, ypos, width, height) => {
commit('MOVE_POS', nodeid, xpos, ypos) commit('MOVE_POS', nodeid, xpos, ypos, width, height)
}, },
addNode: ({ commit }, e) => { addNode: ({ commit }, e) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment