Skip to content

Commit 8e42eb2

Browse files
committed
fixed merge conflicts
co-authored by: Faraz Moallemi [email protected]
2 parents e9e6e1a + 3b1a198 commit 8e42eb2

File tree

4 files changed

+95
-21
lines changed

4 files changed

+95
-21
lines changed

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
},
4343
computed: {
4444
// needs access to current component aka activeComponent
45-
...mapState(['componentMap', 'activeComponent', 'activeComponentObj'])
45+
...mapState(['componentMap', 'activeComponent', 'activeComponentObj']),
4646
},
4747
methods: {
4848
getWindowHeight (e) {
@@ -59,7 +59,7 @@ export default {
5959
return result
6060
},
6161
// Creates beginner boilerplate
62-
createTemplate (componentName, children) {
62+
createTemplate (componentName) {
6363
// not sure why output was set up like this, was imputted into return statement
6464
// using string literal
6565
// let output = ``
@@ -217,6 +217,14 @@ export default {
217217
return output
218218
}
219219
},
220+
watch: {
221+
// watches activeComponentObj for changes to make it reactive upon mutation
222+
activeComponentObj: {
223+
handler(){
224+
this.code = this.createCodeSnippet(this.activeComponentObj.componentName, this.activeComponentObj.children)
225+
}
226+
}
227+
},
220228
mounted () {
221229
// https://vuejs.org/v2/api/#Vue-nextTick
222230
// kinda like a promise, used for the window resize

src/components/file_system_interface/ExportProject.vue

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,87 @@ export default {
223223
* @description imports child components into <script>
224224
*/
225225
writeScript (componentName, children) {
226-
let str = ''
226+
// let str = ''
227+
// children.forEach(name => {
228+
// str += `import ${name} from '@/components/${name}.vue';\n`
229+
// })
230+
// let childrenComponentNames = ''
231+
// children.forEach(name => {
232+
// childrenComponentNames += `\t\t${name},\n`
233+
// })
234+
// return `\n\n<script>\n${str}\nexport default {\n\tname: '${componentName}'
235+
// ,\n\tcomponents: {\n${childrenComponentNames}\t}\n};\n<\/script>`
236+
// },
237+
// add import mapstate and mapactions if they exist
238+
let imports = ''
239+
if (this.activeComponentObj.actions.length || this.activeComponentObj.state.length){
240+
imports += 'import { '
241+
if (this.activeComponentObj.actions.length && this.activeComponentObj.state.length) {
242+
imports += 'mapState, mapActions'
243+
}
244+
else if (this.activeComponentObj.state.length) imports += 'mapState'
245+
else imports += 'mapActions'
246+
imports += ' } from "vuex"\n'
247+
}
248+
249+
// add imports for children
227250
children.forEach(name => {
228-
str += `import ${name} from '@/components/${name}.vue';\n`
251+
imports += `import ${name} from '@/components/${name}.vue';\n`
229252
})
253+
254+
// add components section
230255
let childrenComponentNames = ''
231256
children.forEach(name => {
232-
childrenComponentNames += `\t\t${name},\n`
257+
childrenComponentNames += ` ${name},\n`
233258
})
234-
return `\n\n<script>\n${str}\nexport default {\n\tname: '${componentName}',\n\tcomponents: {\n${childrenComponentNames}\t}\n};\n<\/script>`
235-
},
236259
260+
// if true add data section and populate with props
261+
let data = ''
262+
if (this.activeComponentObj.props.length){
263+
data += ' data () {\n return {'
264+
this.activeComponentObj.props.forEach(prop => {
265+
data += `\n ${prop}: "PLACEHOLDER FOR VALUE",`
266+
})
267+
data += '\n'
268+
data += ' }\n'
269+
data += ' },\n'
270+
}
271+
272+
// if true add computed section and populate with state
273+
let computed = ''
274+
if (this.activeComponentObj.state.length){
275+
computed += ' computed: {'
276+
computed += '\n ...mapState(['
277+
this.activeComponentObj.state.forEach((state) =>{
278+
computed += `\n "${state}",`
279+
})
280+
computed += '\n ]),\n'
281+
computed += ' },\n'
282+
}
283+
284+
// if true add methods section and populate with actions
285+
let methods = ''
286+
if (this.activeComponentObj.actions.length){
287+
methods += ' methods: {'
288+
methods += '\n ...mapActions(['
289+
this.activeComponentObj.actions.forEach((action) => {
290+
methods += `\n "${action}",`
291+
})
292+
methods += '\n ]),\n'
293+
methods += ' },\n'
294+
}
295+
296+
// concat all code within script tags
297+
let output = '\n\n<script>\n'
298+
output += imports + '\nexport default {\n name: ' + componentName
299+
output += ',\n components: {\n'
300+
output += childrenComponentNames + ' },\n'
301+
output += data
302+
output += computed
303+
output += methods
304+
output += '};\n<\/script>'
305+
return output
306+
},
237307
/**
238308
* @description writes the <style> in vue component
239309
* if component is 'App', writes css, else returns <style scoped>
@@ -402,7 +472,7 @@ export default {
402472
}
403473
},
404474
computed: {
405-
...mapState(['componentMap', 'imagePath'])
475+
...mapState(['componentMap', 'imagePath', 'activeComponentObj'])
406476
}
407477
}
408478

src/components/home_sidebar_items/EditDeleteComponents.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ Description:
1515
label="Edit name"
1616
dense
1717
class="input-add"
18-
/>
19-
<!-- <template v-slot:append>
18+
>
19+
<template v-slot:append>
2020
<q-btn
2121
round
2222
dense
2323
flat
2424
icon="fas fa-edit"
2525
@click="editCompName(newName)"
2626
/>
27-
</template> -->
27+
</template>
28+
</q-input>
2829
<multiselect
2930
class="multiselect"
3031
v-model="value"
@@ -56,14 +57,6 @@ Description:
5657
@click="e => handleLayer(e)"
5758
/>
5859
{{ this.activeComponentObj.z }}
59-
<!-- <q-btn
60-
class="btn"
61-
color="transparent"
62-
text-color="white"
63-
label="-"
64-
@click="e => handleLayer(e)"
65-
/> -->
66-
<!-- <p id="counter" style="color: white">{{ this.activeComponentObj.z }}</p> -->
6760
<q-btn
6861
class="btn"
6962
color="transparent"
@@ -281,9 +274,9 @@ export default {
281274
margin: 1rem;
282275
}
283276
/* modifies top label */
284-
.component {
277+
/* .component {
285278
text-transform: uppercase;
286-
}
279+
} */
287280
/* modifies each list element */
288281
.q-list {
289282
margin-bottom: 0.5rem;

src/store/mutations.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const mutations = {
8484
[types.CREATE_ACTION]: (state, payload) => {
8585
// if (!(state.userActions.includes(payload)))
8686
state.userActions.push(payload)
87+
state.userActions.sort()
8788
},
8889

8990
[types.ADD_ACTION_SELECTED]: (state, payload) => {
@@ -116,6 +117,7 @@ const mutations = {
116117
[types.CREATE_PROP]: (state, payload) => {
117118
// if (!(state.userActions.includes(payload)))
118119
state.userProps.push(payload)
120+
state.userProps.sort()
119121
},
120122

121123
[types.ADD_PROPS_SELECTED]: (state, payload) => {
@@ -146,6 +148,7 @@ const mutations = {
146148
[types.CREATE_STATE]: (state, payload) => {
147149
// if (!(state.userActions.includes(payload)))
148150
state.userState.push(payload)
151+
state.userState.sort()
149152
},
150153

151154
[types.ADD_STATE_SELECTED]: (state, payload) => {

0 commit comments

Comments
 (0)