1
1
<template >
2
2
<div >
3
-
4
- <q-btn-dropdown class =" attributeDropDown" color =" primary" :label =" attributeSelection" >
3
+ <q-btn-dropdown
4
+ class =" attributeDropDown"
5
+ color =" primary"
6
+ :label =" attributeSelection"
7
+ >
5
8
<q-list >
6
- <q-item clickable v-close-popup @keyup.enter =" changeAttribute('id')" @click =" changeAttribute('id')" >
9
+ <q-item
10
+ clickable
11
+ v-close-popup
12
+ @keyup.enter =" changeAttribute('id')"
13
+ @click =" changeAttribute('id')"
14
+ >
7
15
<q-item-section >
8
16
<q-item-label >ID</q-item-label >
9
17
</q-item-section >
10
18
</q-item >
11
19
12
- <q-item clickable v-close-popup @keyup.enter =" changeAttribute('class')" @click =" changeAttribute('class')" >
20
+ <q-item
21
+ clickable
22
+ v-close-popup
23
+ @keyup.enter =" changeAttribute('class')"
24
+ @click =" changeAttribute('class')"
25
+ >
13
26
<q-item-section >
14
27
<q-item-label >Class</q-item-label >
15
28
</q-item-section >
16
29
</q-item >
17
30
</q-list >
18
31
</q-btn-dropdown >
19
- <!-- Attribute (id/class so far) change function for main component parent-->
20
- <q-input @keyup.enter =" createAttribute(attributeText)" color =" white" dark outlined bottom-slots
21
- v-model =" attributeText" label =" Enter Label" dense class =" input-add" v-on:keyup.delete.stop >
32
+ <!-- Attribute (id/class so far) change function for main component parent-->
33
+ <q-input
34
+ @keyup.enter =" createAttribute(attributeText)"
35
+ color =" white"
36
+ dark
37
+ outlined
38
+ bottom-slots
39
+ v-model =" attributeText"
40
+ label =" Enter Label"
41
+ dense
42
+ class =" input-add"
43
+ v-on:keyup.delete.stop
44
+ >
22
45
<template v-slot :append >
23
46
<q-btn flat icon =" add" @click =" createAttribute(attributeText)" />
24
47
</template >
25
48
</q-input >
26
- <!-- delete buttons to remove class/id-->
27
- <button v-if =" this.activeComponentObj.htmlAttributes.class !== ''" class =" deleteButton"
28
- @click =" deleteAttribute('class')" color =" primary" >Remove class</button >
49
+ <!-- delete buttons to remove class/id-->
50
+ <button
51
+ v-if =" this.activeComponentObj.htmlAttributes.class !== ''"
52
+ class =" deleteButton"
53
+ @click =" deleteAttribute('class')"
54
+ color =" primary"
55
+ >
56
+ Remove class
57
+ </button >
29
58
30
- <button v-if =" this.activeComponentObj.htmlAttributes.id !== ''" class =" deleteButton" @click =" deleteAttribute('id')"
31
- color =" primary" >Remove id</button >
59
+ <button
60
+ v-if =" this.activeComponentObj.htmlAttributes.id !== ''"
61
+ class =" deleteButton"
62
+ @click =" deleteAttribute('id')"
63
+ color =" primary"
64
+ >
65
+ Remove id
66
+ </button >
32
67
</div >
33
68
</template >
34
69
35
70
<script >
71
+ export default {
72
+ name: " AttributesSubMenu" ,
73
+ };
74
+ </script >
75
+
76
+ <script setup>
77
+ // new script for Composition API
78
+ import { computed , ref } from " vue" ;
79
+ import { useStore } from " vuex" ;
80
+ import VueMultiselect from " vue-multiselect" ;
81
+
82
+ const store = useStore ();
83
+
84
+ // data
85
+
86
+ let attributeText = ref (" " );
87
+ let attributeSelection = ref (" id" );
88
+ let deleteText = ref (" " );
89
+
90
+ // computed
91
+
92
+ const selectedProps = computed (() => store .state .selectedProps );
93
+ const userProps = computed (() => store .state .userProps );
94
+ const activeComponentObj = computed (() => store .state .activeComponentObj );
95
+ let activeComponent = computed (() => store .state .activeComponent );
96
+ const routes = computed (() => store .state .routes );
97
+ const activeRoute = computed (() => store .state .activeRoute );
98
+ const activeRouteKey = computed (
99
+ () => store .state .routes [store .state .activeRoute ]
100
+ );
101
+
102
+ // actions
103
+
104
+ const editAttribute = (payload ) => store .dispatch (" editAttribute" , payload);
105
+
106
+ const activeComponentData = () => {
107
+ return cloneDeep (activeComponentObj .value );
108
+ };
109
+
110
+ // methods
111
+
112
+ // Prevent Delete on changes to searchable multiselect
113
+ const stopDelete = (e ) => {
114
+ if (e .code === " Backspace" ) e .stopPropogation ();
115
+ };
116
+
117
+ // function to change the state of the attribute selection dropdown menu
118
+ const changeAttribute = (attribute ) => {
119
+ attributeSelection .value = attribute;
120
+ };
121
+
122
+ // attribute change function to create attribute
123
+ const createAttribute = (attribute ) => {
124
+ // console.log("What is my attributeSelection?", typeof attributeSelection, attributeSelection)
125
+ // console.log("What is my attributeText?", typeof attributeText, attributeText)
126
+ // console.log("What is my activeComponent.value?", typeof activeComponent.value, activeComponent.value)
127
+ // console.log("What is my activeRouteKey.value?", typeof activeRouteKey.value, activeRouteKey.value)
128
+ // console.log("What is my activeComponent?", typeof activeComponentData, activeComponentData)
129
+
130
+ editAttribute ({
131
+ attribute: attributeSelection .value ,
132
+ value: attribute,
133
+ activeComponent: activeComponent .value ,
134
+ routeArray: activeRouteKey .value ,
135
+ activeComponentData: activeComponentData,
136
+ });
137
+ attributeText .value = " " ;
138
+ };
139
+
140
+ // delete attribute after the delete bvutton has been clicked
141
+ const deleteAttribute = (attribute ) => {
142
+ editAttribute ({
143
+ attribute: attribute,
144
+ value: " " ,
145
+ activeComponent: activeComponent .value ,
146
+ routeArray: activeRouteKey .value ,
147
+ activeComponentData: activeComponentData,
148
+ });
149
+ };
150
+ </script >
151
+
152
+ <!--
153
+ <script>
154
+ //old Options API code
36
155
import { mapState, mapActions } from "vuex";
37
156
import VueMultiselect from "vue-multiselect";
38
157
@@ -70,6 +189,11 @@ export default {
70
189
},
71
190
//attribute change function to create attribute
72
191
createAttribute(attributeText) {
192
+ // console.log("what is attributeSelection?", typeof this.attributeSelection, this.attributeSelection)
193
+ // console.log("what is attributeText?", typeof attributeText, attributeText)
194
+ // console.log("what is activeComponent?", typeof this.activeComponent, this.activeComponent)
195
+ // console.log("what is this.routes[this.activeRoute]?", typeof this.routes[this.activeRoute], this.routes[this.activeRoute])
196
+ // console.log("what is this.activeComponentData?", typeof this.activeComponentData, this.activeComponentData)
73
197
this.editAttribute({
74
198
attribute: this.attributeSelection,
75
199
value: attributeText,
@@ -96,7 +220,7 @@ export default {
96
220
}
97
221
},
98
222
};
99
- </script >
223
+ </script> -->
100
224
101
225
<style lang="scss" scoped>
102
226
.attributeDropDown {
@@ -121,4 +245,4 @@ export default {
121
245
.deleteButton :hover {
122
246
cursor : pointer ;
123
247
}
124
- </style >
248
+ </style >
0 commit comments