Skip to content

Commit e9c7c3e

Browse files
committed
first commit for vuex
1 parent 5eb68c9 commit e9c7c3e

File tree

6 files changed

+335
-170
lines changed

6 files changed

+335
-170
lines changed

src/components/Footer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ Description:
4949
<HomeQueue />
5050
</q-tab-panel>
5151
<q-tab-panel name="detail">
52-
<div class="text-h7">Vuex</div>Component Info Here
52+
<div class="text-h6">Vuex</div>Component Info Here
5353
</q-tab-panel>
5454
<q-tab-panel name="detail">
55-
<div class="text-h8">Vuex</div>Component Info Here
55+
<div class="text-h6">Vuex</div>Component Info Here
5656
</q-tab-panel>
5757
</q-tab-panels>
5858
</q-card>

src/components/HomeSideDropDownItems/VuexForm.vue

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description:
66

77
<template>
88
<div class="input-container">
9-
<q-input
9+
<!-- <q-input
1010
standout="bg-secondary text-white"
1111
bottom-slots
1212
v-model="text"
@@ -17,7 +17,7 @@ Description:
1717
<template v-slot:append>
1818
<q-btn round dense flat icon="add" />
1919
</template>
20-
</q-input>
20+
</q-input> -->
2121
<q-input
2222
standout="bg-secondary text-white"
2323
bottom-slots
@@ -27,26 +27,120 @@ Description:
2727
class="input-add"
2828
>
2929
<template v-slot:append>
30-
<q-btn round dense flat icon="add" />
30+
<q-btn
31+
round dense flat icon="add"
32+
@click="createNewAction(text)"
33+
/>
3134
</template>
3235
</q-input>
33-
<q-input
36+
<!-- <q-input
3437
standout="bg-secondary text-white"
3538
bottom-slots
3639
v-model="text"
37-
label="Add Mutation"
40+
label="Select Action"
3841
dense
3942
class="input-add"
4043
>
4144
<template v-slot:append>
4245
<q-btn round dense flat icon="add" />
4346
</template>
44-
</q-input>
47+
</q-input> -->
48+
<template>
49+
<div id="action-select">
50+
<br />
51+
<multiselect
52+
v-model="value"
53+
placeholder="Select Action"
54+
:multiple="true"
55+
:close-on-select="false"
56+
:options="options"
57+
@input="selectAction"
58+
:max-height="90"
59+
:option-height="20"
60+
:searchable="true"
61+
>
62+
<span slot="noResult">No components found.</span>
63+
</multiselect>
64+
</div>
65+
</template>
4566
</div>
4667
</template>
4768

48-
<style lang="stylus" scoped>
49-
.input-add {
50-
margin: 0em 1em 0em 1em;
69+
<script>
70+
import { mapState, mapActions } from 'vuex'
71+
import Multiselect from 'vue-multiselect'
72+
73+
export default {
74+
name: 'VuexForm',
75+
components: {
76+
Multiselect
77+
},
78+
data () {
79+
return {
80+
text: "",
81+
value: ""
82+
}
83+
},
84+
computed: {
85+
...mapState([
86+
'routes',
87+
'componentMap',
88+
'activeComponent',
89+
'activeRoute',
90+
'routes',
91+
'userActions'
92+
]),
93+
options (){
94+
return ["a", "b", "c"];
95+
}
96+
},
97+
methods: {
98+
...mapActions(['setActiveComponent', 'createAction', 'addActionSelected']),
99+
selectAction (value) {
100+
this.addActionSelected(value)
101+
},
102+
createNewAction (text) {
103+
console.log('text:', text);
104+
if (!this.$store.state.userActions.includes(text)) {
105+
this.createAction(text);
106+
console.log('userActions', this.$store.state.userActions);
107+
console.log('userActionArray', this.userActions);
108+
this.text = ""
109+
}
110+
},
111+
// when multiselect is opened activeComponent is deselected to allow for parentSelected action
112+
resetActiveComponent () {
113+
if (this.activeComponent !== '') {
114+
this.setActiveComponent('')
115+
}
116+
}
117+
},
118+
// clears out value in mutiselect on creation of component
119+
watch: {
120+
componentMap: {
121+
handler () {
122+
// console.log('componentMap has changed')
123+
this.value = ''
124+
}
125+
}
126+
}
51127
}
128+
</script>
129+
130+
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
131+
<style scoped>
132+
#parent-select {
133+
height: 30px;
134+
margin: 0.75rem;
135+
width: 90%;
136+
}
137+
</style>
138+
139+
140+
</script>
141+
142+
143+
<style lang="stylus" scoped>
144+
.input-add
145+
margin 0 1em
52146
</style>

src/store/actions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ const actions = {
112112

113113
// End of Routing section //////////////////////////////////////////
114114

115+
// Vuex Actions ///////////////////////////////////////////////
116+
117+
[types.createAction]: ({ commit }, payload) => {
118+
commit(types.CREATE_ACTION, payload)
119+
},
120+
121+
[types.addActionSelected]: ({ commit }, payload) => {
122+
commit(types.ADD_ACTION_SELECTED, payload)
123+
},
124+
125+
// End of Vuex Actions section //////////////////////////////////////////
126+
127+
115128
// Actions dispatched from left hand panel////////////////////////////////////////
116129

117130
[types.addToComponentElementList]: ({ commit }, payload) => {

0 commit comments

Comments
 (0)