Skip to content

Commit bd94bf4

Browse files
committed
styled component box and added num of children blah blah blah, looks like trash
2 parents 01bfae7 + 630470d commit bd94bf4

File tree

11 files changed

+403
-23
lines changed

11 files changed

+403
-23
lines changed

package-lock.json

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
"mousetrap": "^1.6.3",
1818
"prismjs": "^1.16.0",
1919
"quasar": "^1.0.0",
20+
"vue-custom-context-menu": "^3.0.1",
2021
"vue-drag-resize": "^1.3.2",
22+
"vue-draggable-nested-tree": "^2.2.17",
2123
"vue-draggable-resizable": "^2.0.0-rc2",
2224
"vue-loader": "^15.7.0",
2325
"vue-multiselect": "^2.1.6",
2426
"vue-prism-editor": "^0.2.1",
2527
"vued3tree": "^3.7.1",
28+
"vuedraggable": "^2.23.0",
2629
"vuex": "^3.1.1"
2730
},
2831
"devDependencies": {

quasar.conf.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,21 @@ module.exports = function (ctx) {
5353
'QTab',
5454
'QRouteTab',
5555
'QTabPanels',
56+
'QDialog',
57+
'QSelect',
5658
'QTabPanel',
5759
'QFab',
58-
'QFabAction'
60+
'QFabAction',
61+
'QMenu',
62+
'QUploader',
63+
'QEditor',
64+
'QCard',
65+
'QChip'
5966
],
6067

6168
directives: [
62-
'Ripple'
69+
'Ripple',
70+
'ClosePopup'
6371
],
6472

6573
// Quasar plugins
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<div id="child-select">
3+
<br />
4+
<multiselect
5+
id="dropdown"
6+
placeholder="Select child components"
7+
:multiple="true"
8+
:close-on-select="false"
9+
:options="options"
10+
:value="componentChildrenMultiselectValue"
11+
@input="handleSelect"
12+
:max-height="150"
13+
:option-height="20"
14+
:searchable="false"
15+
></multiselect>
16+
<!-- <q-select
17+
:options="options"
18+
label="Select children"
19+
multiple
20+
/> -->
21+
</div>
22+
</template>
23+
24+
<script>
25+
import { mapState, mapActions } from 'vuex'
26+
import Multiselect from 'vue-multiselect'
27+
28+
export default {
29+
components: {
30+
Multiselect
31+
},
32+
computed: {
33+
...mapState([
34+
'routes',
35+
// comes from store/state/index.js
36+
'componentMap',
37+
'activeComponent',
38+
'componentChildrenMultiselectValue',
39+
'modalOpen'
40+
]),
41+
options () {
42+
const routes = Object.keys(this.routes)
43+
const exceptions = new Set(['App', this.activeComponent, ...routes])
44+
console.log('exceptions', exceptions)
45+
return Object.keys(this.componentMap).filter(component => {
46+
if (!exceptions.has(component)) return component
47+
})
48+
}
49+
},
50+
methods: {
51+
...mapActions([
52+
'updateComponentChildrenMultiselectValue',
53+
'updateActiveComponentChildrenValue'
54+
]),
55+
//
56+
handleSelect (value) {
57+
// if (this.modalOpen) this.updateActiveComponentChildrenValue(value)
58+
console.log('Multiselect: ', value)
59+
this.updateActiveComponentChildrenValue(value)
60+
this.updateComponentChildrenMultiselectValue(value)
61+
}
62+
}
63+
}
64+
</script>
65+
66+
<!-- New step!
67+
Add Multiselect CSS. Can be added as a static asset or inside a component. -->
68+
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
69+
<style scoped>
70+
#child-select {
71+
min-width: 300px;
72+
min-height: 200px;
73+
}
74+
</style>

src/components/ComponentDisplay.vue

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,59 @@
55
v-for="componentData in activeRouteArray"
66
:key="componentData.componentName"
77
:x="componentData.x"
8-
:y="componentData.y"
8+
:y="componentData.y + 20"
99
:w="componentData.w"
1010
:h="componentData.h"
1111
:parent="true"
12-
class-name-resizable="my-resizable-class"
1312
@activated="onActivated(componentData)"
1413
@deactivated="onDeactivated(componentData)"
1514
@dragging="onDrag"
1615
@resizing="onResize"
16+
@dblclick.native="onDoubleClick(componentData)"
1717
>
18-
19-
<div class="component-title">
18+
<div class="component-title">
2019
<p>{{ componentData.componentName }}</p>
2120
</div>
2221
<div class="component-children">
23-
<p>children: </p>
22+
<p># of children: {{ componentMap[componentData.componentName].children.length }} </p>
23+
<p>children: {{ componentMap[componentData.componentName].children }}</p>
2424
<!-- <p v-for="child in childList" :key="childList.indexOf(child)"> {{ child.text }}</p> -->
2525
</div>
26+
<q-menu context-menu>
27+
<q-list>
28+
<q-item clickable v-ripple v-close-popup @click="handleAddChild">
29+
<q-item-section>Add Children</q-item-section>
30+
<q-item-section avatar><q-icon color="primary" name="add"/></q-item-section>
31+
</q-item>
32+
<q-item clickable v-ripple v-close-popup auto-close>
33+
<q-item-section>Delete Children</q-item-section>
34+
<q-item-section avatar><q-icon color="primary" name="delete"/></q-item-section>
35+
</q-item>
36+
</q-list>
37+
</q-menu>
2638
</VueDraggableResizable>
39+
<div>
40+
<q-dialog v-model="modalOpen">
41+
<q-select
42+
@input="handleSelect"
43+
id="dropdown"
44+
filled
45+
v-model="testModel"
46+
multiple
47+
:options="options"
48+
use-chips
49+
stack-label
50+
label="Select children"
51+
style="width: 250px; background-color: #fd5f00"
52+
/>
53+
</q-dialog>
54+
</div>
2755
</div>
2856
</template>
2957
<script>
3058
import { mapState, mapActions } from 'vuex'
3159
import VueDraggableResizable from 'vue-draggable-resizable'
60+
// import ChildrenMultiselect from '../components/ChildrenMultiselect'
3261
import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
3362
3463
export default {
@@ -38,7 +67,10 @@ export default {
3867
},
3968
data () {
4069
return {
41-
abilityToDelete: false
70+
modalOpen: false,
71+
abilityToDelete: false,
72+
testOptions: ['parent', 'child', 'grandchild'],
73+
testModel: []
4274
}
4375
},
4476
mounted () {
@@ -52,7 +84,8 @@ export default {
5284
})
5385
},
5486
computed: {
55-
...mapState(['routes', 'activeRoute', 'activeComponent', 'componentMap']),
87+
...mapState(['routes', 'activeRoute', 'activeComponent', 'componentMap', 'componentChildrenMultiselectValue']),
88+
// used in VueDraggableResizeable component
5689
activeRouteArray () {
5790
console.log('active route array method', this.routes[this.activeRoute])
5891
return this.routes[this.activeRoute]
@@ -65,10 +98,21 @@ export default {
6598
},
6699
childList () {
67100
return this.componentMap[componentData.componentName].children
101+
},
102+
options () {
103+
// PROBLEM: the objects on childrenmultiselectvalue are applied
104+
const routes = Object.keys(this.routes)
105+
const exceptions = new Set(['App', this.activeComponent, ...routes])
106+
return Object.keys(this.componentMap).filter(component => {
107+
if (!exceptions.has(component)) return component
108+
})
68109
}
69110
},
70111
methods: {
71-
...mapActions(['setActiveComponent']),
112+
...mapActions([
113+
'setActiveComponent',
114+
'updateComponentChildrenMultiselectValue',
115+
'updateActiveComponentChildrenValue']),
72116
onResize: function (x, y, width, height) {
73117
this.activeComponentData.x = x
74118
this.activeComponentData.y = y
@@ -93,6 +137,20 @@ export default {
93137
},
94138
onDeactivated () {
95139
this.activeComponentData.isActive = false
140+
},
141+
onDoubleClick (compData) {
142+
this.setActiveComponent(compData.componentName)
143+
this.activeComponentData.isActive = true
144+
},
145+
handleAddChild () {
146+
// render modal with childrenmultiselect in it
147+
this.modalOpen = true
148+
},
149+
handleSelect (value) {
150+
// if (this.modalOpen) this.updateActiveComponentChildrenValue(value)
151+
console.log('Multiselect: ', value)
152+
this.updateActiveComponentChildrenValue(value)
153+
// this.updateComponentChildrenMultiselectValue(value)
96154
}
97155
// @dblclick.native="onDoubleClick(componentData)"
98156
// onDoubleClick (compData) {
@@ -164,7 +222,6 @@ export default {
164222
-ms-transition: background-color 200ms linear;
165223
transition: background-color 200ms linear;
166224
}
167-
168225
.active {
169226
background-color: rgba(57, 63, 84, 0.5);
170227
border: 1px dashed rgb(227, 203, 71);

0 commit comments

Comments
 (0)