Skip to content

Commit 1c13a64

Browse files
author
Julia Bakerink
committed
Fixed bug that didn't allow you to delete props due to deleteProp not being defined. Also fixed bug that deleted the parent/child relationship when adding state to a component
1 parent aa602c9 commit 1c13a64

File tree

8 files changed

+37
-86
lines changed

8 files changed

+37
-86
lines changed

juliaTest/Test.vue

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/components/ExportComponentMixin.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default {
118118
}
119119
// if Typescript toggle is on, import defineComponent
120120
if (this.exportAsTypescript === "on") {
121-
imports += 'import { defineComponent } from "vue"\n';
121+
imports += 'import { defineComponent } from "vue";\n';
122122
}
123123
// add imports for children
124124
children.forEach((name) => {
@@ -186,8 +186,6 @@ export default {
186186
} else {
187187
output += "};\n<\/script>";
188188
}
189-
190-
console.log('output', output);
191189
return output;
192190
},
193191
/**

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default {
4545
},
4646
computed: {
4747
// needs access to current component aka activeComponent
48-
...mapState(["componentMap", "activeComponent", "activeComponentObj"]),
48+
...mapState(["componentMap", "activeComponent", "activeComponentObj", "exportAsTypescript"]),
4949
code: function () {
5050
let computedCode = "Your component boilerplate will be displayed here.";
5151
if (this.activeComponent) {
@@ -172,7 +172,12 @@ export default {
172172
imports += "mapState, mapActions";
173173
} else if (this.activeComponentObj.state.length) imports += "mapState";
174174
else imports += "mapActions";
175-
imports += ' } from "vuex"\n';
175+
imports += ' } from "vuex";\n';
176+
}
177+
178+
// if Typescript toggle is on, import defineComponent
179+
if (this.exportAsTypescript === "on") {
180+
imports += 'import { defineComponent } from "vue";\n';
176181
}
177182
178183
// add imports for children
@@ -223,15 +228,28 @@ export default {
223228
}
224229
225230
// concat all code within script tags
226-
let output = "\n\n<script>\n";
227-
output += imports + "\nexport default {\n name: " + componentName;
231+
// if exportAsTypescript is on, out should be <script lang="ts">
232+
let output;
233+
if (this.exportAsTypescript === 'on') {
234+
output = "\n\n<script lang='ts'>\n";
235+
output += imports + "\nexport default defineComponent ({\n name: '" + componentName + "';";
236+
} else {
237+
output = "\n\n<script>\n";
238+
output += imports + "\nexport default {\n name: '" + componentName + "';";
239+
}
228240
output += ",\n components: {\n";
229241
output += childrenComponentNames + " },\n";
230242
output += data;
231243
output += computed;
232244
output += methods;
245+
246+
if (this.exportAsTypescript === 'on') {
247+
output += "});\n<\/script>\n\n<style scoped>\n</style>"
248+
249+
} else {
250+
output += "};\n<\/script>\n\n<style scoped>\n</style>"
251+
}
233252
// eslint-disable-next-line no-useless-escape
234-
output += "};\n<\/script>\n\n<style scoped>\n</style>";
235253
// add props/data
236254
237255
// eslint-disable-next-line no-useless-escape

src/components/home_sidebar_items/ComponentTab/ComponentState.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default {
9898
]),
9999
// Prevent Delete on changes to searchable multiselet
100100
stopDelete(e) {
101-
if (e.code === "Backspce") e.stopPropogation();
101+
if (e.code === "Backspace") e.stopPropogation();
102102
},
103103
// adds a state to the currently selected component
104104
addStateToComp() {

src/components/home_sidebar_items/ComponentTab/EditDeleteComponents.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ export default {
275275
}
276276
},
277277
278+
// Delete prop
279+
deleteProp(prop) {
280+
this.$store.dispatch('deletePropsFromComponent', prop);
281+
},
282+
278283
// changes layer of active component
279284
handleLayer(e) {
280285
e.preventDefault();

src/store/mutations.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const mutations = {
104104
},
105105

106106
[types.ADD_ACTION_TO_COMPONENT]: (state, payload) => {
107-
const active = state.activeComponentObj;
107+
const active = state.componentMap[state.activeComponent];
108108

109109
if (!active.actions) {
110110
active.actions = payload;
@@ -138,7 +138,7 @@ const mutations = {
138138
},
139139

140140
[types.ADD_PROPS_TO_COMPONENT]: (state, payload) => {
141-
const active = state.activeComponentObj;
141+
const active = state.componentMap[state.activeComponent];
142142

143143
if (!active.props) {
144144
active.props = payload;
@@ -169,7 +169,8 @@ const mutations = {
169169
},
170170

171171
[types.ADD_STATE_TO_COMPONENT]: (state, payload) => {
172-
const active = state.activeComponentObj;
172+
// const active = state.activeComponentObj;
173+
const active = state.componentMap[state.activeComponent];
173174

174175
if (!state.activeComponentObj.state) {
175176
state.activeComponentObj.state = payload;
@@ -192,7 +193,7 @@ const mutations = {
192193
},
193194

194195
[types.DELETE_ACTION_FROM_COMPONENT]: (state, payload) => {
195-
const temp = state.activeComponentObj;
196+
const temp = state.componentMap[state.activeComponent];
196197
const newArray = [];
197198
temp.actions.forEach((element) => {
198199
if (element !== payload) newArray.push(element);
@@ -203,7 +204,7 @@ const mutations = {
203204
},
204205

205206
[types.DELETE_PROPS_FROM_COMPONENT]: (state, payload) => {
206-
const temp = state.activeComponentObj;
207+
const temp = state.componentMap[state.activeComponent];
207208
const newArray = [];
208209
temp.props.forEach((element) => {
209210
if (element !== payload) newArray.push(element);
@@ -214,7 +215,7 @@ const mutations = {
214215
},
215216

216217
[types.DELETE_STATE_FROM_COMPONENT]: (state, payload) => {
217-
const temp = state.activeComponentObj;
218+
const temp = state.componentMap[state.activeComponent];
218219
const newArray = [];
219220
temp.state.forEach((element) => {
220221
if (element !== payload) newArray.push(element);

tsTestProps/Test.vue

Lines changed: 0 additions & 34 deletions
This file was deleted.

tstest/Test.vue

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)