Skip to content

Commit d62e1b8

Browse files
committed
aesthetic changes to toggle buttons
1 parent ad21b68 commit d62e1b8

File tree

4 files changed

+112
-16
lines changed

4 files changed

+112
-16
lines changed

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export default {
120120
let outputStr = ``
121121
for (let el of htmlArr) {
122122
if (!el.text) {
123+
console.log(htmlArr)
123124
outputStr += ` <${el}/>\n`
124125
} else {
125126
outputStr += ` `
@@ -220,10 +221,18 @@ export default {
220221
watch: {
221222
// watches activeComponentObj for changes to make it reactive upon mutation
222223
activeComponentObj: {
224+
handler(){
225+
//console.log(this.activeComponentObj.children)
226+
this.code = this.createCodeSnippet(this.activeComponentObj.componentName, this.activeComponentObj.children)
227+
}
228+
},
229+
// watches componentMap for changes to make it reactive upon mutation
230+
componentMap: {
223231
handler(){
224232
this.code = this.createCodeSnippet(this.activeComponentObj.componentName, this.activeComponentObj.children)
225233
}
226234
}
235+
227236
},
228237
mounted () {
229238
// https://vuejs.org/v2/api/#Vue-nextTick

src/components/dashboard_items/Dashboard.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export default {
9999
// user is in the process of creating a component
100100
componentNameInputValue: function () {
101101
if (this.componentNameInputValue !== '' && this.activeComponent === '') {
102-
console.log(this.selectedElementList.length)
103102
this.tab = 'tree'
104103
}
105104
},

src/components/home_sidebar_items/EditDeleteComponents.vue

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ Description:
4949
<q-btn id="deleteButton" @click="deleteSelectedComp(activeComponentData)" label = 'Delete currently selected'/>
5050
<div v-if="this.activeComponentData">
5151
<br/>
52+
<!-- @input="selectParent"
53+
@open="resetActiveComponent" -->
54+
<multiselect
55+
v-model="testModel"
56+
placeholder="Add/Remove Children"
57+
:multiple="true"
58+
:close-on-select="false"
59+
:options="childOptions"
60+
@input="handleAddChild"
61+
:max-height="90"
62+
:option-height="20"
63+
:searchable="false"
64+
/>
65+
<br/>
66+
5267
<section id="counter" style="color: white"> Layer:
5368
<q-btn
5469
class="btn"
@@ -66,14 +81,18 @@ Description:
6681
@click="e => handleLayer(e)"
6782
/>
6883
</section>
69-
<br/>
84+
<br/>
7085
<p> Toggle to edit: </p>
71-
<section class="toggleText"> HTML elements
72-
<toggle-button v-model="showHTML"/> </section>
86+
<div class="toggleRow">
87+
<section class="toggleText"> HTML elements</section>
88+
<toggle-button v-model="showHTML" class="toggle"/>
89+
</div>
7390
<HTMLQueue v-if="showHTML"/>
7491
<br/>
75-
<section class="toggleText"> State
76-
<toggle-button v-model="showState"/> </section>
92+
<div class="toggleRow">
93+
<section class="toggleText"> State</section>
94+
<toggle-button v-model="showState" class="toggle"/>
95+
</div>
7796
<hr v-if="showState">
7897
<a
7998
v-for="s in this.activeComponentData.state"
@@ -93,8 +112,10 @@ Description:
93112
</q-list>
94113
</a>
95114
<br/>
96-
<section class="toggleText"> Actions
97-
<toggle-button v-model="showActions" /> </section>
115+
<div class="toggleRow">
116+
<section class="toggleText"> Actions</section>
117+
<toggle-button v-model="showActions" class="toggle"/>
118+
</div>
98119
<hr v-if="showActions">
99120
<a
100121
v-for="action in this.activeComponentData.actions"
@@ -114,9 +135,10 @@ Description:
114135
</q-list>
115136
</a>
116137
<br/>
117-
<section class="toggleText">
118-
Props
119-
<toggle-button v-model="showProps"/> </section>
138+
<div class="toggleRow">
139+
<section class="toggleText">Props </section>
140+
<toggle-button v-model="showProps" class="toggle" justify='end'/>
141+
</div>
120142
<hr v-if="showProps">
121143
<a
122144
v-for="prop in this.activeComponentData.props"
@@ -152,6 +174,7 @@ export default {
152174
data () {
153175
return {
154176
value: '',
177+
testModel: [],
155178
newName: '',
156179
showState: false,
157180
showActions: false,
@@ -185,8 +208,40 @@ export default {
185208
(component) => component.componentName
186209
)
187210
return val
211+
},
212+
213+
childOptions () {
214+
// checks if component has any parents and pushes them into lineage
215+
const checkParents = (component, lineage = [component.componentName]) => {
216+
if (!Object.keys(component.parent).length) return lineage
217+
for (var parents in component.parent) {
218+
lineage.push(parents)
219+
checkParents(component.parent[parents], lineage)
220+
}
221+
return lineage
222+
}
223+
let lineage = [this.activeComponent]
224+
// checks to see if there are any existing children
225+
if (this.componentMap[this.activeComponent]) {
226+
// console.log('testmodel', this.testModel)
227+
// console.log(this.componentMap[this.activeComponent].children)
228+
this.testModel = this.componentMap[this.activeComponent].children
229+
lineage = checkParents(this.componentMap[this.activeComponent])
230+
// console.log('Lineage', lineage);
231+
}
232+
const routes = Object.keys(this.routes)
233+
const exceptions = new Set([
234+
'App',
235+
...lineage,
236+
...routes,
237+
...this.testModel
238+
])
239+
return Object.keys(this.componentMap).filter(component => {
240+
if (!exceptions.has(component)) return component
241+
})
188242
}
189243
},
244+
190245
methods: {
191246
...mapActions([
192247
'setActiveComponent',
@@ -196,9 +251,15 @@ export default {
196251
'deleteActionFromComponent',
197252
'deletePropsFromComponent',
198253
'deleteStateFromComponent',
199-
'updateComponentLayer'
254+
'updateComponentLayer',
255+
'updateActiveComponentChildrenValue'
200256
]),
201257
258+
handleAddChild (value) {
259+
// console.log('selected child component: ', value)
260+
this.updateActiveComponentChildrenValue(value)
261+
},
262+
202263
// delete selected state from active component
203264
deleteState (state) {
204265
this.deleteStateFromComponent(state)
@@ -279,6 +340,12 @@ export default {
279340
</script>
280341

281342
<style>
343+
344+
.toggleRow{
345+
display: flex;
346+
/* align-items: center; */
347+
justify-content: space-between;
348+
}
282349
/* modifies entire container */
283350
.edit-sidebar {
284351
padding: 0.5rem;
@@ -314,6 +381,10 @@ p {
314381
color: white;
315382
}
316383
384+
.toggle{
385+
align-self: flex-end;
386+
}
387+
317388
.editName {
318389
color: white;
319390
}

src/store/mutations.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,32 @@ const mutations = {
539539

540540
[types.UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE]: (state, payload) => {
541541
let temp = state.componentMap[state.activeComponent].children
542+
// delete block
542543
if (payload.length < temp.length) {
543544
let child = temp.filter(el => !payload.includes(el))
544545
// console.log('delete child: ', child)
546+
let childCount = 0
547+
let components = Object.values(state.componentMap)
548+
console.log(components)
549+
for (let comp of components){
550+
if (comp.children.includes(child[0])) childCount++
551+
}
545552
state.componentMap[state.activeComponent].children = payload
546-
state.componentMap[state.activeRoute].children.push(
547-
...temp.filter(el => !payload.includes(el))
548-
)
553+
if (childCount <= 1){
554+
state.componentMap[state.activeRoute].children.push(
555+
...temp.filter(el => !payload.includes(el))
556+
)
557+
}
558+
const newHTMLList = state.componentMap[state.activeComponent].htmlList.filter(el => {
559+
return el !== child[0]
560+
})
561+
state.componentMap[state.activeComponent].htmlList = newHTMLList
562+
const newMap = {...state.componentMap}
563+
state.componentMap = Object.assign({}, newMap)
549564
delete state.componentMap[child[0]].parent[state.activeComponent]
550-
} else {
565+
}
566+
// add block
567+
else {
551568
let child = payload.filter(el => !temp.includes(el))
552569
// console.log('child added', child)
553570
state.componentMap[state.activeComponent].children = payload

0 commit comments

Comments
 (0)