Skip to content

Commit 3ff405c

Browse files
committed
resolved keriann conflict
2 parents f5d6abc + c3465a8 commit 3ff405c

File tree

7 files changed

+134
-110
lines changed

7 files changed

+134
-110
lines changed

src/App.vue

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,114 +12,114 @@ import {defaultState} from './store/state/index.js'
1212
1313
let redoMixin = {
1414
data() {
15-
return {
16-
// banana:[],
17-
doneAction:[],
18-
undoneAction:[],
19-
isTimetraveling: false,
20-
initialState:{}
21-
}
22-
},
23-
24-
created(){
25-
26-
this.$store.subscribeAction((action,state)=>{
27-
// console.log("We are saving this action!", action)
28-
if (typeof action.payload === "object"){
29-
// console.log("We saved the world with a deepclone!", action.payload === cloneDeep)
30-
action.payload = cloneDeep(action.payload)
31-
}
32-
this.doneAction.push(action)
33-
// console.log('this is the action we are logging',action)
34-
// console.log('this is in our redo queue', this.undoneAction[this.undoneAction.length-1])
35-
// console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
36-
if(!this.isTimetraveling){
37-
if (this.undoneAction[this.undoneAction.length-1]){
38-
if(action.type == this.undoneAction[this.undoneAction.length-1].type &&
39-
deepEqual(action.payload,this.undoneAction[this.undoneAction.length-1].payload)){
40-
this.undoneAction.pop()
41-
}
42-
else{
43-
this.undoneAction = []
44-
}
45-
}
46-
}
47-
})
48-
// this.blankState = cloneDeep(this.$store)
49-
},
15+
return {
16+
// banana:[],
17+
doneAction:[],
18+
undoneAction:[],
19+
isTimetraveling: false,
20+
initialState:{}
21+
}
22+
},
23+
24+
created() {
5025
51-
mounted(){
52-
window.addEventListener("keydown", event => {
53-
if (event.ctrlKey && event.key === "z") {
54-
event.preventDefault()
55-
this.undo()
26+
this.$store.subscribeAction((action, state) => {
27+
// console.log("We are saving this action!", action)
28+
if (typeof action.payload === "object") {
29+
// console.log("We saved the world with a deepclone!", action.payload === cloneDeep)
30+
action.payload = cloneDeep(action.payload)
31+
}
32+
this.doneAction.push(action)
33+
// console.log('this is the action we are logging',action)
34+
// console.log('this is in our redo queue', this.undoneAction[this.undoneAction.length-1])
35+
// console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
36+
if(!this.isTimetraveling) {
37+
if (this.undoneAction[this.undoneAction.length-1]) {
38+
if(action.type == this.undoneAction[this.undoneAction.length-1].type &&
39+
deepEqual(action.payload,this.undoneAction[this.undoneAction.length-1].payload)) {
40+
this.undoneAction.pop()
5641
}
57-
});
58-
window.addEventListener("keydown", event => {
59-
if (event.ctrlKey && event.key === "y") {
60-
event.preventDefault()
61-
this.redo()
42+
else {
43+
this.undoneAction = []
6244
}
63-
});
64-
//console.log("do we want this? or this.$store.state?", this.$store.state)
65-
this.initialState = defaultState(this.$store.state)
45+
}
46+
}
47+
})
48+
// this.blankState = cloneDeep(this.$store)
49+
},
6650
67-
},
51+
mounted(){
52+
window.addEventListener("keydown", event => {
53+
if (event.ctrlKey && event.key === "z") {
54+
event.preventDefault()
55+
this.undo()
56+
}
57+
});
58+
window.addEventListener("keydown", event => {
59+
if (event.ctrlKey && event.key === "y") {
60+
event.preventDefault()
61+
this.redo()
62+
}
63+
});
64+
//console.log("do we want this? or this.$store.state?", this.$store.state)
65+
this.initialState = defaultState(this.$store.state)
6866
69-
methods: {
70-
undo: function() {
71-
// do {
72-
// console.log("How far back?")
67+
},
7368
74-
this.isTimetraveling = true;
69+
methods: {
70+
undo: function() {
71+
// do {
72+
// console.log("How far back?")
7573
76-
let undone = this.doneAction.pop()
77-
78-
if(undone !== undefined){
79-
this.undoneAction.push(undone)
80-
if(undone.type==="setActiveComponent"){
81-
console.log("We did something useless!")
82-
do{
83-
this.undoneAction.push(this.doneAction.pop())
84-
}
85-
while (this.doneAction[this.doneAction.length-1] &&
86-
(this.doneAction[this.doneAction.length - 1].type === "setActiveComponent"))
87-
}
88-
}
74+
this.isTimetraveling = true;
8975
90-
// while (this.doneAction[this.doneAction.length-1] &&
91-
// (this.doneAction[this.doneAction.length - 1].type === "setActiveComponent" ||
92-
// this.doneAction[this.doneAction.length - 1].type === "updateComponentPosition" ))
93-
let payload = {
94-
initialState: this.initialState,
95-
store: this.$store
96-
}
97-
this.$store.commit("EMPTY_STATE",payload)
98-
console.log(this.$store)
99-
this.doneAction.forEach(action => {
100-
console.log("In the loop",this.$store)
101-
//this.$store.commit(`${mutation.type}`, mutation.payload);
102-
this.$store.dispatch(action.type, cloneDeep(action.payload));
103-
this.doneAction.pop();
104-
});
105-
this.isTimetraveling = false;
76+
let undone = this.doneAction.pop()
10677
107-
},
108-
redo: function() {
109-
110-
let action = this.undoneAction.pop()
111-
this.isTimetraveling = true;
112-
if(action){
113-
this.$store.dispatch(action.type, cloneDeep(action.payload))
114-
}
115-
this.isTimetraveling = false;
116-
if(action && (action.type === "setActiveComponent")){
117-
console.log("WE GOTTA DO MORE")
118-
this.redo();
119-
}
78+
if(undone !== undefined) {
79+
this.undoneAction.push(undone)
80+
if(undone.type==="setActiveComponent") {
81+
console.log("We did something useless!")
82+
do{
83+
this.undoneAction.push(this.doneAction.pop())
12084
}
85+
while (this.doneAction[this.doneAction.length-1] &&
86+
(this.doneAction[this.doneAction.length - 1].type === "setActiveComponent"))
87+
}
88+
}
12189
90+
// while (this.doneAction[this.doneAction.length-1] &&
91+
// (this.doneAction[this.doneAction.length - 1].type === "setActiveComponent" ||
92+
// this.doneAction[this.doneAction.length - 1].type === "updateComponentPosition" ))
93+
let payload = {
94+
initialState: this.initialState,
95+
store: this.$store
12296
}
97+
this.$store.commit("EMPTY_STATE",payload)
98+
console.log(this.$store)
99+
this.doneAction.forEach(action => {
100+
console.log("In the loop",this.$store)
101+
// this.$store.commit(`${mutation.type}`, mutation.payload);
102+
this.$store.dispatch(action.type, cloneDeep(action.payload));
103+
this.doneAction.pop();
104+
});
105+
this.isTimetraveling = false;
106+
107+
},
108+
redo: function() {
109+
110+
let action = this.undoneAction.pop()
111+
this.isTimetraveling = true;
112+
if(action) {
113+
this.$store.dispatch(action.type, cloneDeep(action.payload))
114+
}
115+
this.isTimetraveling = false;
116+
if(action && (action.type === "setActiveComponent")) {
117+
console.log("WE GOTTA DO MORE")
118+
this.redo();
119+
}
120+
}
121+
122+
}
123123
}
124124
125125

src/components/ComponentDisplay.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,19 @@ export default {
138138
// console.log('component parent',component.parent)
139139
// console.log('component parent parent', component.parent.parent)
140140
if (!Object.keys(component.parent).length) return lineage;
141+
<<<<<<< HEAD
141142
for(var parents in component.parent) {
142143
//for each parent in our component
143144
// console.log('parents', parents)
144145
lineage.push(parents); //push the parent into lineage
145146
// console.log('lineage pre push', component, lineage)
147+
=======
148+
for (var parents in component.parent) {
149+
// for each parent in our component
150+
console.log('parents', parents)
151+
lineage.push(parents); // push the parent into lineage
152+
console.log('lineage pre push', component, lineage)
153+
>>>>>>> c3465a8ee7303f95f469f78b7ab5d89214b77193
146154
checkParents(component.parent[parents], lineage);
147155
// console.log('lineage post recursive call', lineage)
148156
}
@@ -187,7 +195,7 @@ export default {
187195
//console.log("updated")
188196
if(this.activeComponent === '')
189197
{
190-
if(this.$refs.boxes){
198+
if(this.$refs.boxes) {
191199
this.$refs.boxes.forEach((element)=> {
192200
element.enabled = false;
193201
element.$emit('deactivated')
@@ -272,7 +280,7 @@ export default {
272280
activeComponentData: this.activeComponentData
273281
}
274282
275-
//this.updateStartingSize(payload);
283+
// this.updateStartingSize(payload);
276284
277285
},
278286

src/components/ExportProject.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ export default {
353353
this.createRouter(data);
354354
for (let [routeImage, imageLocation] of Object.entries(this.imagePath)) {
355355
// console.log('routeImage is ', routeImage);
356-
this.createAssetFile(path.join(data, "src", "assets", routeImage), imageLocation)
356+
if (imageLocation !== '') {
357+
this.createAssetFile(path.join(data, "src", "assets", routeImage), imageLocation)
358+
}
357359
};
358360
for (let componentName in this.componentMap) {
359361
// if componentName is a route:

src/components/HomeQueue.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
@start="drag = true"
1212
@end="drag = false"
1313
>
14-
<div class="list-group-item" v-for="(element, index) in renderList" :key="index + Date.now()">
15-
{{ element.text }}
16-
<i class="fas fa fa-trash fa-md" @click="deleteElement(index)"></i>
14+
<!-- <div class="list-group-item" v-for="(element, index) in renderList" :key="index + Date.now()"> -->
15+
<div class="list-group-item" v-for="(element) in renderList" :key="element[1] + Date.now()">
16+
{{ element[0] }}
17+
<i class="fas fa fa-trash fa-md" @click="deleteElement(element[1])"></i>
1718
</div>
1819
</draggable>
1920
</section>
@@ -44,7 +45,10 @@ export default {
4445
renderList: {
4546
get () {
4647
if (this.activeComponent === '') return this.selectedElementList
47-
return this.componentMap[this.activeComponent].htmlList
48+
let newArr = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index]).filter(el => {
49+
return el[0] !== undefined
50+
})
51+
return newArr
4852
},
4953
set (value) {
5054
this.$store.dispatch(setSelectedElementList, value)

src/store/actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ const actions = {
5858
activeComponent = this.activeComponent,
5959
routeArray = this.routes[this.activeRoute],
6060
activeComponentData = this.activeComponentData
61-
}*/
61+
} */
6262

63-
commit(types.UPDATE_COMPONENT_POSITION, payload)
63+
commit(types.UPDATE_COMPONENT_POSITION, payload)
6464

6565
},
6666
[types.updateComponentLayer]: ({ commit }, payload) => {
6767
commit(types.UPDATE_COMPONENT_LAYER, payload)
6868
},
6969

70-
//does the same as update component position, but needed to record the initial spot of the draggable resizeable in component display
70+
// does the same as update component position, but needed to record the initial spot of the draggable resizeable in component display
7171
// or else undo/redo won't work
7272
[types.updateStartingPosition]: ({ commit }, payload) => {
7373
commit(types.UPDATE_COMPONENT_POSITION, payload)

src/store/mutations.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const mutations = {
8484
// console.log('This is our defaultstate still', defaultState)
8585
console.log("hopefully this stays pure", payload)
8686
payload.store.replaceState(cloneDeep(payload.initialState))
87-
// {
87+
// {
8888
// icons,
8989
// htmlElementMap,
9090
// // every single time we create a component
@@ -129,8 +129,8 @@ const mutations = {
129129
[types.ADD_PARENT]: (state, payload) => {
130130
state.componentMap[payload.componentName].parent[state.parentSelected] = state.componentMap[state.parentSelected]
131131
state.componentMap[state.parentSelected].children.push(payload.componentName)
132+
state.componentMap[state.parentSelected].htmlList.push(payload.componentName)
132133
},
133-
134134
// adds a html tag from the Icons.vue to the HomeQueue.vue
135135
// event: getClickedIcon @Icons.vue
136136
[types.ADD_TO_SELECTED_ELEMENT_LIST]: (state, payload) => {
@@ -183,7 +183,10 @@ const mutations = {
183183
for (let compKey in newObj) {
184184
let children = newObj[compKey].children
185185
children.forEach((child, index) => {
186-
if (activeComponent === child) children.splice(index, 1)
186+
if (activeComponent === child) {
187+
children.splice(index, 1)
188+
newObj[compKey].htmlList = newObj[compKey].htmlList.filter(el => el !== activeComponent)
189+
}
187190
})
188191
}
189192

@@ -323,6 +326,13 @@ const mutations = {
323326
].children.filter(el => !payload.includes(el))
324327
state.componentMap[child[0]].parent[state.activeComponent] = state.componentMap[state.activeComponent]
325328
}
329+
const copy = [...state.componentMap[state.activeComponent].htmlList]
330+
for (var x in payload) {
331+
if (!copy.includes(payload[x])) {
332+
copy.push(payload[x])
333+
}
334+
}
335+
state.componentMap[state.activeComponent].htmlList = copy
326336
},
327337
// allows usr to change the name of component!!
328338
[types.UPDATE_COMPONENT_NAME_INPUT_VALUE]: (state, payload) => {

src/store/state/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const newState = {
6666
modalOpen: false,
6767
parentSelected: false,
6868
imagePath: {
69-
HomeView: '',
69+
HomeView: ''
7070
}
7171
}
7272

0 commit comments

Comments
 (0)