Skip to content

Commit fb6140f

Browse files
committed
Merge branch 'dev2021' of https://github.com/oslabs-beta/OverVue into sean/edit
2 parents 828e70b + c08d0f5 commit fb6140f

File tree

7 files changed

+66
-51
lines changed

7 files changed

+66
-51
lines changed

src/App.vue

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ let redoMixin = {
4040
// console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
4141
if (!this.isTimetraveling) {
4242
if (this.undoneAction[this.undoneAction.length - 1]) {
43-
if (action.type === this.undoneAction[this.undoneAction.length - 1].type &&
44-
deepEqual(action.payload, this.undoneAction[this.undoneAction.length - 1].payload)) {
43+
if (
44+
action.type ===
45+
this.undoneAction[this.undoneAction.length - 1].type &&
46+
deepEqual(
47+
action.payload,
48+
this.undoneAction[this.undoneAction.length - 1].payload
49+
)
50+
) {
4551
this.undoneAction.pop()
4652
} else {
4753
this.undoneAction = []
@@ -50,19 +56,21 @@ let redoMixin = {
5056
}
5157
})
5258
},
53-
59+
// undo + redo function calling
60+
// metaKey accounts for Command Key on Mac
5461
mounted () {
5562
const throttledUndo = throttle(this.undo, 300)
5663
const throttledRedo = throttle(this.redo, 300)
57-
64+
// undo function calling
5865
window.addEventListener('keydown', event => {
59-
if (event.ctrlKey && event.key === 'z') {
66+
if ((event.ctrlKey || event.metaKey) && event.key === 'z') {
6067
event.preventDefault()
6168
throttledUndo()
6269
}
6370
})
71+
// redo function calling
6472
window.addEventListener('keydown', event => {
65-
if (event.ctrlKey && event.key === 'y') {
73+
if ((event.ctrlKey || event.metaKey) && event.key === 'y') {
6674
event.preventDefault()
6775
throttledRedo()
6876
}
@@ -90,8 +98,10 @@ let redoMixin = {
9098
this.undoneAction.push(undone)
9199
if (ignoredActions.has(undone.type)) {
92100
// console.log('We undid an ignored action!')
93-
while (this.doneAction[this.doneAction.length - 1] &&
94-
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)) {
101+
while (
102+
this.doneAction[this.doneAction.length - 1] &&
103+
ignoredActions.has(this.doneAction[this.doneAction.length - 1].type)
104+
) {
95105
this.undoneAction.push(this.doneAction.pop())
96106
}
97107
/* if we get here, that means we have undone all "useless" actions
@@ -130,7 +140,6 @@ let redoMixin = {
130140
this.redo()
131141
}
132142
}
133-
134143
}
135144
}
136145
@@ -140,5 +149,4 @@ export default {
140149
}
141150
</script>
142151

143-
<style>
144-
</style>
152+
<style></style>

src/components/ComponentDisplay.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,9 @@ export default {
382382
},
383383
watch: {
384384
activeComponent: function () {
385-
if (this.activeComponent){
385+
if (this.activeComponent) {
386386
this.onActivated(this.activeComponentObj)
387-
}
388-
else{
387+
} else {
389388
this.onDeactivated()
390389
}
391390
}

src/components/dashboard_items/CodeSnippet.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export default {
6565
},
6666
// Creates <template> boilerplate
6767
writeTemplateTag (componentName) {
68-
// console.log('writeTemplateTag invoked!')
6968
// create reference object
7069
const htmlElementMap = {
7170
div: ['<div>', '</div>'],
@@ -82,6 +81,7 @@ export default {
8281
}
8382
8483
// Helper function that recursively iterates through the given html element's children and their children's children.
84+
// also adds proper indentation to code snippet
8585
function writeNested (childrenArray, indent) {
8686
if (!childrenArray.length) {
8787
return ''
@@ -91,7 +91,6 @@ export default {
9191
9292
childrenArray.forEach(child => {
9393
nestedString += indented
94-
// console.log(child)
9594
if (!child.text) {
9695
nestedString += `<${child}/>\n`
9796
} else {
@@ -113,7 +112,6 @@ export default {
113112
let htmlArr = this.componentMap[componentName].htmlList
114113
let outputStr = ``
115114
for (let el of htmlArr) {
116-
// console.log(el)
117115
if (!el.text) {
118116
outputStr += ` <${el}/>\n`
119117
} else {
@@ -130,7 +128,6 @@ export default {
130128
}
131129
}
132130
}
133-
// console.log(`outputStr from writeTemplateTag: ${outputStr}`)
134131
return outputStr
135132
},
136133
// Creates boiler text for <script> and <style>
@@ -156,15 +153,14 @@ export default {
156153
this.getWindowHeight()
157154
})
158155
},
159-
// Updates code snippet
156+
// Updates code snippet when adding children
160157
updated () {
161-
// console.log(`code: ${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`)
162-
// console.log('component map: ', this.componentMap);
163158
if (this.componentMap[this.activeComponent]) {
164159
this.code = `${this.createCodeSnippet(
165160
this.activeComponent,
166161
this.componentMap[this.activeComponent].children
167162
)}`
163+
// else if there is not existing component/no active component
168164
} else {
169165
this.code = `Your component boilerplate will be displayed here.`
170166
}

src/components/dashboard_items/ComponentDetails.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<!--
2+
Description:
3+
Located in the Dashboard
4+
Contains the Code Snippet, HTMLQueue Components, and the Component state, actions, and props as well
5+
Functionality includes: Contains the Code Snippet and HTMLQueue Components,
6+
as well as tabs to show the Component state, actions, and props
7+
8+
-->
9+
110
<template>
211
<div class="container">
312
<q-card id="store-cards" v-if="this.activeComponentObj">

src/components/dashboard_items/Dashboard.vue

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!--
22
Description:
33
Displays OverVue's dashboard containing Component Details, Vuex Store, and the Project Tree
4-
Functionality includes: opening/closing drawer, deselecting active html, and
5-
toggling to html elements tab during component creation
4+
Functionality includes: opening/closing drawer, and contains the different Tabs
5+
As of now, no default tab selected when not selecting anything, but might change to Project Tree in the future if we want
66
-->
77

88
<template>
@@ -85,27 +85,30 @@ export default {
8585
}
8686
}
8787
},
88-
// toggles dashboard to "html" tab when existing component is not in focus
8988
watch: {
89+
// toggles dashboard to "Component Details" tab when a components is selected
9090
activeComponent: function () {
91-
// console.log('watching activeComponent in Dashboard');
92-
if (this.activeComponent === '' && this.selectedElementList.length !== 0) {
93-
this.tab = 'html'
91+
if (this.activeComponent !== '') {
92+
this.tab = 'detail'
93+
} else {
94+
// otherwise toggle dashboard to 'Project Tree' tab if no component is selected
95+
this.tab = 'tree'
9496
}
9597
},
96-
// toggles dashboard to "html" tab if component name has value & elements are in queue
98+
// otherwise toggle dashboard to 'Project Tree' tab if no component is selected or the
99+
// user is in the process of creating a component
97100
componentNameInputValue: function () {
98-
// console.log('watching componentNameInputVal')
99-
if (this.componentNameInputValue !== '' && this.selectedElementList.length !== 0 && this.activeComponent === '') {
100-
// console.log(this.selectedElementList)
101-
this.tab = 'html'
101+
if (this.componentNameInputValue !== '' && this.activeComponent === '') {
102+
console.log(this.selectedElementList.length)
103+
this.tab = 'tree'
102104
}
103105
},
104-
// toggles dashboard to "html" tab if elements are added to queue on component creation
106+
// // toggles dashboard to "Project Tree" tab if:
107+
// // no component is selected and either:
108+
// // elements are being added to component or name is being typed
105109
selectedElementList: function () {
106-
// console.log('watching selectedElementList')
107110
if (this.activeComponent === '' && this.selectedElementList.length !== 0) {
108-
this.tab = 'html'
111+
this.tab = 'tree'
109112
}
110113
}
111114
}

src/components/dashboard_items/HTMLQueue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { setSelectedElementList, deleteSelectedElement, deleteFromComponentHtmlL
3838
import { breadthFirstSearch } from '../../utils/search.util'
3939
4040
export default {
41-
name: 'HTML Queue',
41+
name: 'HTMLQueue',
4242
props: {
4343
name: {
4444
type: String

test/jest/__tests__/App.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ describe("Test mutations + actions to remove action from component and userActio
2525
};
2626
});
2727

28-
xit("deleting user action from state.userActions", () => {
28+
it("deleting user action from state.userActions", () => {
2929
mutations.DELETE_USER_ACTIONS(state, "action");
3030
expect(state.userActions.length).toBe(0);
3131
});
3232

33-
xit('deleting "action" from componentMap', () => {
33+
it('deleting "action" from componentMap', () => {
3434
mutations.REMOVE_ACTION_FROM_COMPONENT(state, "action");
3535
expect(state.componentMap.component.mapActions.length).toBe(0);
3636
});
3737
});
3838

39-
xdescribe("Adding actions and state to components", () => {
39+
describe("Adding actions and state to components", () => {
4040
let state;
4141
beforeEach(() => {
4242
state = {
@@ -52,15 +52,15 @@ xdescribe("Adding actions and state to components", () => {
5252
activeComponent: "testComponent"
5353
};
5454
});
55-
xdescribe("Adding actions to components", () => {
55+
describe("Adding actions to components", () => {
5656
it("should add a single action to active component", () => {
5757
mutations.ADD_TO_COMPONENT_ACTIONS(state, "testAction");
5858
expect(
5959
state.componentMap[state.activeComponent].componentActions
6060
).toEqual(["testAction"]);
6161
});
6262
});
63-
xdescribe("Adding state to components", () => {
63+
describe("Adding state to components", () => {
6464
it("should add a single state string to active component", () => {
6565
mutations.ADD_TO_COMPONENT_STATE(state, "testState");
6666
expect(state.componentMap[state.activeComponent].componentState).toEqual([
@@ -70,7 +70,7 @@ xdescribe("Adding actions and state to components", () => {
7070
});
7171
});
7272

73-
xdescribe("userActions mutation", () => {
73+
describe("userActions mutation", () => {
7474
let actions;
7575
let store;
7676
beforeEach(() => {
@@ -88,31 +88,31 @@ xdescribe("userActions mutation", () => {
8888
});
8989
});
9090

91-
xdescribe("userStore mutation", () => {
91+
describe("userStore mutation", () => {
9292
let actions;
9393
let store;
9494
store = {
9595
userStore: {}
9696
};
97-
xit("should be able to update store with a key defined by the user and a value of type object", () => {
97+
it("should be able to update store with a key defined by the user and a value of type object", () => {
9898
mutations.ADD_TO_USER_STORE(store, { dummyKey: {} });
9999
// console.log('store.userStore.dummyKey', store.userStore.dummyKey);
100100
expect(store.userStore.dummyKey).toStrictEqual({});
101101
});
102-
xit("should update user store with a key value pair with value strictly equal to empty array", () => {
102+
it("should update user store with a key value pair with value strictly equal to empty array", () => {
103103
mutations.ADD_TO_USER_STORE(store, { dummyKey: [] });
104104
expect(store.userStore.dummyKey).toStrictEqual([]);
105105
});
106-
xit("should be able to store booleans in the store as the key", () => {
106+
it("should be able to store booleans in the store as the key", () => {
107107
mutations.ADD_TO_USER_STORE(store, { boolean: true });
108108
expect(store.userStore.boolean).toBe(true);
109109
});
110-
xit("should add to userStore a key with a value of type number", () => {
110+
it("should add to userStore a key with a value of type number", () => {
111111
mutations.ADD_TO_USER_STORE(store, { number: 696 });
112112
expect(store.userStore.number).toBe(696);
113113
});
114114

115-
xit("should work with strings too", () => {
115+
it("should work with strings too", () => {
116116
mutations.ADD_TO_USER_STORE(store, { string: "string" });
117117
expect(store.userStore.string).toBe("string");
118118
});
@@ -126,7 +126,7 @@ xdescribe("userStore mutation", () => {
126126
* `userStore` holds the user defined state objects
127127
*/
128128

129-
xdescribe("Delete state in userStore/componentMap", () => {
129+
describe("Delete state in userStore/componentMap", () => {
130130
let state;
131131
beforeEach(() => {
132132
state = {
@@ -143,13 +143,13 @@ xdescribe("Delete state in userStore/componentMap", () => {
143143
userStore: { state1: true, state2: [] }
144144
};
145145
});
146-
xdescribe('"DELETE_USER_STATE" should delete property from "userStore" object', () => {
146+
describe('"DELETE_USER_STATE" should delete property from "userStore" object', () => {
147147
it("should delete a single state property", () => {
148148
mutations.DELETE_USER_STATE(state, "state1");
149149
expect(state.userStore).toEqual({ state2: [] });
150150
});
151151
});
152-
xdescribe('"REMOVE_STATE_FROM_COMPONENT" should delete state in "activeComponent"', () => {
152+
describe('"REMOVE_STATE_FROM_COMPONENT" should delete state in "activeComponent"', () => {
153153
it("should remove state from active component", () => {
154154
mutations.REMOVE_STATE_FROM_COMPONENT(state, "state2");
155155
expect(state.componentMap.test.componentState).toEqual(["state1"]);

0 commit comments

Comments
 (0)