Skip to content

Commit 7684e6f

Browse files
authored
Merge pull request #15 from oslabs-beta/bryan/treeDisplayBugs
various bugfixes: pasting no longer generates duplicate names; remove…
2 parents df60e51 + 6dee1e6 commit 7684e6f

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/components/home_sidebar_items/ComponentTab/EditDeleteComponents.vue

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ export default {
195195
196196
// returns options for component multiselect
197197
options() {
198+
if (this.activeComponent !== '')
199+
this.newName = this.activeComponentObj.componentName;
200+
if (this.activeComponent !== ''){
201+
this.childrenSelected = [];
202+
this.childrenSelected = this.componentMap[this.activeComponent].children;
203+
} else {
204+
this.childrenSelected = [];
205+
}
198206
const compMap = this.componentMap;
199207
const activeComp = this.activeComponent;
200208
const val = this.activeRouteDisplay.map(
@@ -304,18 +312,6 @@ export default {
304312
},
305313
},
306314
mixins: [handleExportComponentMixin],
307-
watch: {
308-
// watches for changes in selected component, changes edit name text to newly selected component
309-
activeComponentObj: function () {
310-
if (this.activeComponentObj)
311-
this.newName = this.activeComponentObj.componentName;
312-
if (this.activeComponent !== ''){
313-
this.childrenSelected = this.componentMap[this.activeComponent].children;
314-
} else {
315-
this.childrenSelected = [];
316-
}
317-
},
318-
},
319315
};
320316
</script>
321317

src/components/home_sidebar_items/ComponentTab/ParentMultiselect.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ export default {
9191
:global(.multiselect__option) {
9292
color: white;
9393
}
94+
:global(.multiselect__option--selected) {
95+
background-color: $accent;
96+
color: #155158;
97+
98+
}
9499
:global(.multiselect__single) {
95100
background-color: $subprimary;
96101
color: white;
97102
}
98103
:global(.multiselect__single:focus) {
99-
background-color: $subprimary;
104+
background-color: $negative;
100105
color: white;
101106
}
102107
:global(.multiselect__input::placeholder) {

src/store/mutations.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,11 @@ const mutations = {
286286
const pastedComponent = { ...copiedComponent };
287287
pastedComponent.x = 20;
288288
pastedComponent.y = 20;
289-
state.componentMap[
290-
(pastedComponent.componentName += ` (${state.copyNumber})`)
291-
] = pastedComponent;
289+
pastedComponent.componentName += ` (${state.copyNumber})`
290+
while(state.componentMap.hasOwnProperty(pastedComponent.componentName)){
291+
pastedComponent.componentName += ` copy`
292+
}
293+
state.componentMap[pastedComponent.componentName] = pastedComponent;
292294

293295
// increment copyNumber
294296
state.copyNumber += 1;
@@ -650,19 +652,19 @@ const mutations = {
650652
if (state.activeComponent === payload){return}
651653
const temp = state.componentMap[state.activeComponent].children;
652654
// delete block
653-
if ((temp.filter((el) => payload.includes(el))).length > 0) {
655+
if ((temp.filter((el) => payload === el)).length > 0) {
654656
//commented stuff below does not seem necessary for the functionality of this if block.
655-
656657
//children will be current children EXCLUDING payload
657658
// const child = temp.filter((el) => payload.includes(el));
659+
console.log('delete block')
658660
let childCount = 0;
659661
const components = Object.values(state.componentMap);
660662
for (const comp of components) {
661663
if (comp.children.includes(payload)) childCount++; //if the component has 2 parents, do not assign the component to the route
662664
}
663-
state.componentMap[state.activeComponent].children = (temp.filter((el) => !payload.includes(el)));
665+
state.componentMap[state.activeComponent].children = (temp.filter((el) => payload !== el));
664666
if (childCount <= 1) {
665-
state.componentMap[state.activeRoute].children.push(...temp.filter((el) => payload.includes(el)));
667+
state.componentMap[state.activeRoute].children.push(...temp.filter((el) => payload === el));
666668
}
667669
// const newHTMLList = state.componentMap[
668670
// state.activeComponent

0 commit comments

Comments
 (0)