Skip to content

Commit 7a5dbbc

Browse files
authored
Merge pull request #7 from dnohashi/selectParent
Can select parent when creating a component
2 parents aab5a97 + 6a20411 commit 7a5dbbc

File tree

12 files changed

+1068
-18
lines changed

12 files changed

+1068
-18
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@
1616
"localforage": "^1.7.3",
1717
"mousetrap": "^1.6.3",
1818
"quasar": "^1.0.0",
19+
"vue-drag-resize": "^1.3.2",
1920
"vue-draggable-resizable": "^2.0.0-rc2",
2021
"vue-loader": "^15.7.0",
2122
"vue-multiselect": "^2.1.6",
22-
"vued3tree": "^3.7.1"
23+
"vued3tree": "^3.7.1",
24+
"vuex": "^3.1.1"
2325
},
2426
"devDependencies": {
2527
"@quasar/app": "^1.0.0",
2628
"@vue/eslint-config-standard": "^4.0.0",
2729
"babel-eslint": "^10.0.1",
2830
"devtron": "^1.4.0",
2931
"electron": "^5.0.6",
32+
"electron-builder": "^20.44.4",
3033
"electron-debug": "^3.0.1",
3134
"electron-devtools-installer": "^2.2.4",
3235
"eslint": "^5.10.0",

quasar.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ module.exports = function (ctx) {
147147
},
148148

149149
electron: {
150-
// bundler: 'builder', // or 'packager'
150+
bundler: 'builder', // or 'packager'
151151

152152
extendWebpack (cfg) {
153153
// do something with Electron main process Webpack cfg

src/components/ComponentDisplay.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:w="componentData.w"
1010
:h="componentData.h"
1111
:parent="true"
12+
class-name-resizable="my-resizable-class"
1213
@activated="onActivated(componentData)"
1314
@deactivated="onDeactivated(componentData)"
1415
@dragging="onDrag"

src/components/CreateComponent.vue

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,23 @@
1616
<div class="icon-container">
1717
<Icons @getClickedIcon="addToSelectedElementList" />
1818
</div>
19-
<!-- <ChildrenMultiselect /> -->
19+
<ParentMultiselect />
2020
<br />
21-
<!-- <button
22-
class="button is-primary"
23-
id="add-component-btn"
24-
@click="handleClick"
25-
:disabled="!componentNameInputValue"
26-
>Add Component</button> -->
2721
<q-btn id="add-component-btn" class="primary" color="secondary" label="Create Component" icon-right="add" @click="handleClick" :disabled="!componentNameInputValue" />
2822
</div>
2923
</template>
3024

3125
<script>
3226
import Icons from './Icons'
33-
// import ChildrenMultiselect from '@/components/ChildrenMultiselect';
27+
import ParentMultiselect from '../components/ParentMultiselect'
3428
import { mapState, mapActions } from 'vuex'
3529
// import * as types from '../store/types.js'
3630
3731
export default {
3832
name: 'HomeSidebar',
3933
components: {
40-
// ChildrenMultiselect,
41-
Icons
34+
Icons,
35+
ParentMultiselect
4236
},
4337
computed: {
4438
...mapState(['componentMap', 'selectedElementList']),

src/components/FooterTabView.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
<script>
3737
export default {
38+
name: 'FooterTabView.vue',
3839
data () {
3940
return {
4041
tab: 'tree'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div id="parent-select">
3+
<br />
4+
<multiselect
5+
placeholder="Choose Parent (if applicable)"
6+
:multiple="false"
7+
:close-on-select="true"
8+
:options="options"
9+
@input="handleSelect"
10+
:max-height="150"
11+
:option-height="20"
12+
:searchable="false"
13+
></multiselect>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import { mapState, mapActions } from 'vuex'
19+
import Multiselect from 'vue-multiselect'
20+
21+
export default {
22+
name: 'ParentMultiselect',
23+
components: {
24+
Multiselect
25+
},
26+
computed: {
27+
...mapState([
28+
'routes',
29+
'componentMap',
30+
'activeComponent'
31+
]),
32+
options () {
33+
const routes = Object.keys(this.routes)
34+
const exceptions = new Set(['App', ...routes])
35+
return Object.keys(this.componentMap).filter(component => {
36+
if (!exceptions.has(component)) return component
37+
})
38+
}
39+
},
40+
methods: {
41+
...mapActions([
42+
'setActiveComponent',
43+
'parentSelected'
44+
]),
45+
handleSelect (value) {
46+
// Set Active Component to selected Parent
47+
this.setActiveComponent(value)
48+
// Set parentSelected to true IF VALUE IS A VALID PARENT (not null)
49+
this.parentSelected(true)
50+
}
51+
}
52+
}
53+
</script>
54+
55+
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
56+
<style scoped>
57+
58+
</style>

src/components/TopMenuBar.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@
8787
</q-bar>
8888
</div>
8989
</template>
90+
91+
<script>
92+
export default {
93+
name: 'TopMenuBar',
94+
components: {
95+
QMenu,
96+
QItem,
97+
QSeparator,
98+
QItemSection,
99+
QList,
100+
QBtn
101+
}
102+
}
103+
</script>

src/store/actions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ const actions = {
1616
let value = state.componentChildrenMultiselectValue.map(component => {
1717
return state.componentMap[component]
1818
})
19+
20+
if (state.parentSelected) {
21+
commit(types.UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE, [...state.componentMap[state.activeComponent].children, payload.componentName])
22+
}
23+
1924
commit(types.UPDATE_COMPONENT_CHILDREN_VALUE, { component, value })
2025
commit(types.UPDATE_COMPONENT_CHILDREN_MULTISELECT_VALUE, [])
2126
commit(types.UPDATE_COMPONENT_NAME_INPUT_VALUE, '')
2227
commit(types.SET_SELECTED_ELEMENT_LIST, [])
28+
commit(types.SET_ACTIVE_COMPONENT, '')
29+
commit(types.PARENT_SELECTED, false)
2330
}
2431
},
2532
// sets component inside componentDisplay
@@ -102,6 +109,9 @@ const actions = {
102109
},
103110
[types.updateOpenModal]: ({ commit }, payload) => {
104111
commit(types.UPDATE_OPEN_MODAL, payload)
112+
},
113+
[types.parentSelected]: ({ commit }, payload) => {
114+
commit(types.PARENT_SELECTED, payload)
105115
}
106116
}
107117

src/store/mutations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ const mutations = {
157157
// additionally addes children to the component
158158
[types.UPDATE_COMPONENT_CHILDREN_VALUE]: (state, payload) => {
159159
const { component, value } = payload
160-
console.log('IN MUTATIONS: ', value)
161-
console.log('Type: ', typeof value)
162-
163160
state.componentMap[component].children = value
164161
},
165162
[types.UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE]: (state, payload) => {
@@ -179,6 +176,9 @@ const mutations = {
179176
// invoked when element is double clicked, changing the boolean value
180177
[types.UPDATE_OPEN_MODAL]: (state, payload) => {
181178
state.modalOpen = payload
179+
},
180+
[types.PARENT_SELECTED]: (state, payload) => {
181+
state.parentSelected = payload
182182
}
183183
}
184184

0 commit comments

Comments
 (0)