Skip to content

Commit 66bd7d0

Browse files
committed
Merge branch 'master' into createComponentDropDown
2 parents b1fab08 + 3773c82 commit 66bd7d0

File tree

9 files changed

+201
-38
lines changed

9 files changed

+201
-38
lines changed

src/components/ChildrenMultiselect.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default {
4141
options () {
4242
const routes = Object.keys(this.routes)
4343
const exceptions = new Set(['App', this.activeComponent, ...routes])
44-
console.log('exceptions', exceptions)
44+
// console.log('exceptions', exceptions)
4545
return Object.keys(this.componentMap).filter(component => {
4646
if (!exceptions.has(component)) return component
4747
})
@@ -55,7 +55,7 @@ export default {
5555
//
5656
handleSelect (value) {
5757
// if (this.modalOpen) this.updateActiveComponentChildrenValue(value)
58-
console.log('Multiselect: ', value)
58+
// console.log('Multiselect: ', value)
5959
this.updateActiveComponentChildrenValue(value)
6060
this.updateComponentChildrenMultiselectValue(value)
6161
}

src/components/CodeSnippet.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default {
111111
// updates code snippet, but broken cause children undefined, shows `function () { [native code] }`
112112
updated() {
113113
// console.log(`code: ${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`)
114-
console.log('component map: ', this.componentMap);
114+
// console.log('component map: ', this.componentMap);
115115
if (this.componentMap[this.activeComponent]) {
116116
this.code = `${this.createCodeSnippet(
117117
this.activeComponent,
@@ -128,7 +128,7 @@ export default {
128128
componentMap: {
129129
deep: true,
130130
handler() {
131-
console.log('component Map has changed');
131+
// console.log('component Map has changed');
132132
if (this.componentMap[this.activeComponent]) {
133133
this.code = `${this.createCodeSnippet(
134134
this.activeComponent,
@@ -138,7 +138,7 @@ export default {
138138
},
139139
},
140140
activeComponent: function() {
141-
console.log('watching active component');
141+
// console.log('watching active component');
142142
},
143143
},
144144
};

src/components/ComponentDisplay.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
<q-menu context-menu>
2828
<q-list class="menu">
2929
<q-item clickable v-ripple v-close-popup @click="handleAddChild">
30-
<q-item-section style="color: white">Add Children</q-item-section>
30+
<q-item-section style="color: white">Update Children</q-item-section>
3131
<q-item-section avatar>
3232
<q-icon color="primary" name="add" />
3333
</q-item-section>
3434
</q-item>
35-
<q-item clickable v-ripple v-close-popup auto-close>
35+
<!-- <q-item clickable v-ripple v-close-popup auto-close>
3636
<q-item-section style="color: pink">Delete Children</q-item-section>
3737
<q-item-section avatar>
3838
<q-icon color="primary" name="delete" />
3939
</q-item-section>
40-
</q-item>
40+
</q-item> -->
4141
</q-list>
4242
</q-menu>
4343
</VueDraggableResizable>
@@ -86,7 +86,7 @@ export default {
8686
window.addEventListener("keyup", event => {
8787
if (event.key === "Backspace") {
8888
if (this.activeComponent && this.activeComponentData.isActive) {
89-
// console.log('this:', this)
89+
console.log('this:', this)
9090
this.$store.dispatch("deleteActiveComponent");
9191
}
9292
}
@@ -103,7 +103,7 @@ export default {
103103
]),
104104
// used in VueDraggableResizeable component
105105
activeRouteArray() {
106-
console.log("active route array method", this.routes[this.activeRoute]);
106+
// console.log("active route array method", this.routes[this.activeRoute]);
107107
return this.routes[this.activeRoute];
108108
},
109109
// used to delete components
@@ -119,9 +119,9 @@ export default {
119119
// PROBLEM: the objects on childrenmultiselectvalue are applied
120120
// check to see if there are any existing children
121121
if (this.componentMap[this.activeComponent]) {
122-
console.log('active component', this.activeComponent)
123-
console.log('testmodel', this.testModel)
124-
console.log(this.componentMap[this.activeComponent].children)
122+
// console.log('active component', this.activeComponent)
123+
// console.log('testmodel', this.testModel)
124+
// console.log(this.componentMap[this.activeComponent].children)
125125
this.testModel = this.componentMap[this.activeComponent].children;
126126
}
127127
const routes = Object.keys(this.routes);

src/components/CreateComponent.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
color="secondary"
2828
label="Create Component"
2929
@click="handleClick"
30-
:disabled="!componentNameInputValue"
30+
:disabled="!componentNameInputValue.trim()"
3131
/>
3232
</div>
3333
</template>
@@ -63,6 +63,10 @@ export default {
6363
'addToComponentElementList'
6464
]),
6565
handleClick () {
66+
if (!this.componentNameInputValue.trim()) {
67+
event.preventDefault();
68+
return false;
69+
}
6670
const component = {
6771
componentName: this.componentNameInputValue,
6872
x: 0,
@@ -75,6 +79,7 @@ export default {
7579
}
7680
7781
this.registerComponent(component)
82+
7883
},
7984
resetActiveComponent () {
8085
this.setActiveComponent('')
@@ -91,7 +96,7 @@ export default {
9196
height: 45px;
9297
}
9398
form {
94-
margin-bottom: 2em;
99+
/* margin-bottom: 2em; */
95100
}
96101
#add-component-btn {
97102
height: 15px;

src/components/Footer.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
indicator-color="secondary"
1616
align="left"
1717
>
18+
1819
<q-tab name="code" label="Code Snippet" id="label-text" />
1920
<q-tab name="detail" label="Component Details" id="label-text" />
2021
<q-tab name="tree" label="Project Tree" id="label-text" />
@@ -43,6 +44,7 @@
4344
</template>
4445

4546
<script>
47+
import { mapState } from 'vuex'
4648
import Tree from './Tree'
4749
import HomeQueue from './HomeQueue'
4850
import CodeSnippet from './CodeSnippet'
@@ -53,6 +55,9 @@ export default {
5355
HomeQueue,
5456
CodeSnippet
5557
},
58+
computed: {
59+
...mapState(['activeComponent', 'componentNameInputValue', 'selectedElementList'])
60+
},
5661
data () {
5762
return {
5863
tab: 'code',
@@ -71,6 +76,30 @@ export default {
7176
this.height === 40 ? (this.height = minHeight) : (this.height = 40)
7277
this.open === true ? (this.open = false) : (this.open = true)
7378
}
79+
},
80+
// toggles footer to "html" tab when existing component is not in focus
81+
watch: {
82+
activeComponent: function () {
83+
// console.log('watching activeComponent in Footer');
84+
if (this.activeComponent === '' && this.selectedElementList.length !== 0) {
85+
this.tab = 'html'
86+
}
87+
},
88+
// toggles footer to "html" tab if component name has value & elements are in queue
89+
componentNameInputValue: function() {
90+
// console.log('watching componentNameInputVal')
91+
if (this.componentNameInputValue !== '' && this.selectedElementList.length !== 0 && this.activeComponent === '') {
92+
// console.log(this.selectedElementList)
93+
this.tab = 'html'
94+
}
95+
},
96+
// toggles footer to "html" tab if elements are added to queue on component creation
97+
selectedElementList: function() {
98+
// console.log('watching selectedElementList')
99+
if (this.activeComponent === '' && this.selectedElementList.length !== 0) {
100+
this.tab = 'html'
101+
}
102+
}
74103
}
75104
}
76105
</script>

src/components/HomeQueue.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
22
<section class="home-queue">
3+
<span class='list-title' v-if='component'> Viewing Elements in '{{ this.activeComponent }}' </span>
4+
<span class='list-title' v-else> Elements in Queue </span>
5+
<hr>
36
<draggable
47
v-model="renderList"
58
group="people"
@@ -31,7 +34,11 @@ export default {
3134
type: Array
3235
}
3336
},
34-
37+
data () {
38+
return {
39+
component: false
40+
}
41+
},
3542
computed: {
3643
...mapState(['selectedElementList', 'componentMap', 'activeComponent']),
3744
renderList: {
@@ -52,6 +59,16 @@ export default {
5259
},
5360
components: {
5461
draggable
62+
},
63+
watch: {
64+
activeComponent: function () {
65+
// console.log('watching activeComponent in HomeQueue')
66+
if (this.activeComponent !== '') {
67+
this.component = true
68+
} else {
69+
this.component = false
70+
}
71+
}
5572
}
5673
}
5774
</script>
@@ -63,6 +80,9 @@ export default {
6380
li {
6481
list-style-type: none;
6582
}
83+
.list-title {
84+
// font-weight: bold;
85+
}
6686
.list-group-item {
6787
display: inline-block;
6888
margin: 2px 1.5%;
@@ -81,4 +101,7 @@ li {
81101
position: relative;
82102
left: 20px;
83103
}
104+
hr {
105+
border: 1px solid grey
106+
}
84107
</style>

src/components/Icons.vue

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
v-for="([elementName, iconString], idx) in Object.entries(icons)"
66
:key="idx + Date.now()"
77
>
8+
<span class="badge"> {{ elementStorage[elementName] }}</span>
9+
<br />
810
<i :class="iconString"></i>
911
<br />
10-
<span class="white--text">{{ elementName }}</span>
12+
<span class="white--text"
13+
>{{ elementName }}</span>
1114
</button>
1215
</section>
1316
</template>
@@ -16,14 +19,81 @@
1619
import { mapState } from 'vuex'
1720
1821
export default {
22+
data () {
23+
return {
24+
elementStorage: {}
25+
}
26+
},
1927
name: 'Icons',
2028
computed: {
21-
...mapState(['icons', 'activeComponent'])
29+
...mapState(['icons', 'activeComponent', 'componentMap', 'selectedElementList'])
2230
},
2331
methods: {
2432
changeState (elementName) {
2533
if (this.activeComponent === '') { this.$emit('getClickedIcon', elementName) } else this.$emit('activeElement', elementName)
2634
}
35+
},
36+
watch: {
37+
selectedElementList: function() {
38+
// console.log('watching selectedElementList');
39+
if (this.activeComponent === '') {
40+
this.elementStorage = {};
41+
this.selectedElementList.forEach(el => {
42+
if (!this.elementStorage[el.text]) {
43+
this.elementStorage[el.text] = 1;
44+
} else {
45+
this.elementStorage[el.text] += 1;
46+
}
47+
})
48+
}
49+
// console.log('storage is ', this.elementStorage)
50+
},
51+
// if componentMap is updated (i.e. element is added to component's htmlList), elementStorage will update its cache of elements & frequency
52+
componentMap: {
53+
deep: true,
54+
handler () {
55+
// console.log('watching componentMap');
56+
// console.log('activecomponent is ', this.activeComponent)
57+
// console.log('htmlList', this.componentMap[this.activeComponent].htmlList)
58+
if (this.activeComponent) {
59+
this.elementStorage = {};
60+
this.componentMap[this.activeComponent].htmlList.forEach(el => {
61+
if (!this.elementStorage[el.text]) {
62+
this.elementStorage[el.text] = 1;
63+
} else {
64+
this.elementStorage[el.text] += 1;
65+
}
66+
})
67+
// console.log('elementStorage is ', this.elementStorage);
68+
}
69+
},
70+
},
71+
// if activeComponent is updated, elementStorage will update its cache of elements & frequency to reflect new active component
72+
activeComponent: function() {
73+
// console.log('watching activeComponent', this.activeComponent);
74+
if (this.activeComponent) {
75+
this.elementStorage = {};
76+
this.componentMap[this.activeComponent].htmlList.forEach(el => {
77+
if (!this.elementStorage[el.text]) {
78+
this.elementStorage[el.text] = 1;
79+
} else {
80+
this.elementStorage[el.text] += 1;
81+
}
82+
})
83+
// console.log('elementStorage is ', this.elementStorage);
84+
} else if (this.activeComponent === '') {
85+
// console.log(`watching activeComponent, current active is ''`)
86+
// if component was switched from existing component to '', reset cache and update items
87+
if (this.elementStorage !== {}) this.elementStorage = {};
88+
this.selectedElementList.forEach(el => {
89+
if (!this.elementStorage[el.text]) {
90+
this.elementStorage[el.text] = 1;
91+
} else {
92+
this.elementStorage[el.text] += 1;
93+
}
94+
})
95+
}
96+
}
2797
}
2898
}
2999
</script>
@@ -44,7 +114,6 @@ export default {
44114
width: 100%;
45115
}
46116
}
47-
48117
button {
49118
background: none;
50119
color: white;
@@ -54,7 +123,23 @@ button:hover {
54123
cursor: pointer;
55124
color: #00ffff;
56125
}
57-
button:focus {
126+
button:focus {
58127
outline: none;
128+
color: #00ffff;
129+
}
130+
button:active {
131+
box-shadow: 0 5px inherit;
132+
transform: translateY(4px);
133+
}
134+
.badge {
135+
width: 15px;
136+
line-height: 15px;
137+
text-align: center;
138+
font-size: 10px;
139+
font-weight: bold;
140+
float: right;
141+
border-radius: 50%;
142+
background-color: #228585;
143+
color: white;
59144
}
60145
</style>

src/components/Tree.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default {
4040
children: compData.children
4141
})
4242
})
43+
console.log("Formatcomponent map result", result)
4344
return result
4445
},
4546
transformToTree (data) {

0 commit comments

Comments
 (0)