Skip to content

Commit fb8284a

Browse files
Merge pull request #11 from oslabs-beta/fileStructure
File structure
2 parents eddd34a + 262af9c commit fb8284a

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

src/components/ComponentDisplay.vue

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ export default {
145145
146146
// used to delete active component
147147
activeComponentData () {
148-
return this.activeRouteArray.filter(componentData => {
149-
return componentData.componentName === this.activeComponent
150-
})[0]
148+
return this.activeComponentObj
151149
},
152150
153151
childList () {
@@ -383,11 +381,8 @@ export default {
383381
}
384382
},
385383
watch: {
386-
activeComponentObj: {
387-
handler () {
388-
// console.log('componentMap has changed')
389-
this.value = ''
390-
}
384+
activeComponent: function () {
385+
this.onActivated(this.activeComponentObj)
391386
}
392387
}
393388
}

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Description:
77

88
<template>
99
<div class="codesnippet-container">
10-
<div class="top-p" v-if="activeComponent === ''">Select a component</div>
11-
<div v-else>{{ `${activeComponent}.vue` }}</div>
10+
<div class="top-p" v-if="this.activeComponent === ''">Select a component</div>
11+
<div v-else>{{ `${this.activeComponent}.vue` }}</div>
1212
<prism-editor
1313
v-model="code"
1414
language="js"
@@ -173,19 +173,32 @@ export default {
173173
window.removeEventListener('resize', this.getWindowHeight)
174174
},
175175
watch: {
176-
// If HTML elements or components are added, rerenders Code Snippet
177-
componentMap: {
178-
deep: true,
176+
177+
activeComponent: {
179178
handler () {
180-
// console.log('component Map has changed');
179+
console.log('component Map has changed')
181180
if (this.componentMap[this.activeComponent]) {
181+
console.log('we made it here')
182182
this.code = `${this.createCodeSnippet(
183183
this.activeComponent,
184184
this.componentMap[this.activeComponent].children
185185
)}`
186186
}
187187
}
188188
}
189+
},
190+
// If HTML elements or components are added, rerenders Code Snippet
191+
componentMap: {
192+
deep: true,
193+
handler () {
194+
// console.log('component Map has changed');
195+
if (this.componentMap[this.activeComponent]) {
196+
this.code = `${this.createCodeSnippet(
197+
this.activeComponent,
198+
this.componentMap[this.activeComponent].children
199+
)}`
200+
}
201+
}
189202
}
190203
}
191204
</script>

src/components/home_sidebar_items/ComponentList.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ export default {
113113
},
114114
editCompName (name) {
115115
if (name) this.editComponentName(name)
116-
console.log(this.routes[this.activeRoute])
117-
console.log(this.activeComponentObj)
118-
console.log(this.activeComponent)
116+
this.setActiveComponent(this.activeComponent)
119117
}
120118
},
121119
watch: {

src/components/home_sidebar_items/VuexForm.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Description:
1616
label="Create Action in Store"
1717
dense
1818
class="input-add"
19+
v-on:keyup.delete.stop
1920
>
2021
<template v-slot:append>
2122
<q-btn
@@ -40,6 +41,7 @@ Description:
4041
open-direction="top"
4142
:options="actionOptions"
4243
:searchable="true"
44+
@search-change="stopDelete($event)"
4345
>
4446
<span slot="noResult">No actions found.</span>
4547
</multiselect>
@@ -66,6 +68,7 @@ Description:
6668
label="Create State in Store"
6769
dense
6870
class="input-add"
71+
v-on:keyup.delete.stop
6972
>
7073
<template v-slot:append>
7174
<q-btn round dense flat icon="add" @click="createNewState(textState)" />
@@ -84,6 +87,7 @@ Description:
8487
open-direction="top"
8588
:options="stateOptions"
8689
:searchable="true"
90+
@search-change="stopDelete($event)"
8791
>
8892
<span slot="noResult">No state found.</span>
8993
</multiselect>
@@ -110,6 +114,7 @@ Description:
110114
label="Create Prop"
111115
dense
112116
class="input-add"
117+
v-on:keyup.delete.stop
113118
>
114119
<template v-slot:append>
115120
<q-btn round dense flat icon="add" @click="createNewProp(textProps)" />
@@ -128,6 +133,7 @@ Description:
128133
open-direction="top"
129134
:options="propsOptions"
130135
:searchable="true"
136+
@search-change="stopDelete($event)"
131137
>
132138
<span slot="noResult">No props found.</span>
133139
</multiselect>
@@ -225,6 +231,12 @@ export default {
225231
'addPropsToComponent'
226232
]),
227233
234+
// Prevent Delete on changes to seafrchable multiselect
235+
stopDelete (e) {
236+
if (e.code === 'Backspace') e.stopPropogation()
237+
console.log(e)
238+
},
239+
228240
// Create's a new action that will be stored in the userActions array within store, and it will be added to the action drop-down menu
229241
createNewAction (text) {
230242
if (!this.userActions.includes(text) && text) {

src/store/mutations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ const mutations = {
178178
active.componentName = payload
179179
state.activeComponentObj = Object.assign({},
180180
state.activeComponentObj, { componentName: payload })
181+
state.activeComponent = payload
182+
state.componentMap[state.activeComponent] = state.activeComponentObj
181183
},
182184

183185
// *** HTML ELEMENTS *** //////////////////////////////////////////////

0 commit comments

Comments
 (0)