Skip to content

Commit 6d71516

Browse files
committed
redo/undo button completed
1 parent b6afd31 commit 6d71516

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/App.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ let redoMixin = {
9393
if (undone !== undefined) {
9494
this.undoneAction.push(undone)
9595
if (undone.type === 'setActiveComponent') {
96-
console.log('We did something useless!')
96+
// console.log('We did something useless!')
9797
do {
9898
this.undoneAction.push(this.doneAction.pop())
9999
}
@@ -110,9 +110,8 @@ let redoMixin = {
110110
store: this.$store
111111
}
112112
this.$store.commit('EMPTY_STATE', payload)
113-
console.log(this.$store)
114113
this.doneAction.forEach(action => {
115-
console.log('In the loop', this.$store)
114+
// console.log('In the loop', this.$store)
116115
// this.$store.commit(`${mutation.type}`, mutation.payload);
117116
this.$store.dispatch(action.type, cloneDeep(action.payload))
118117
this.doneAction.pop()

src/layouts/MyLayout.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
<!-- <q-avatar></q-avatar> -->
1010
OverVue
1111
</q-toolbar-title>
12+
<div>
13+
<!-- <i class="fa fa-undo" aria-hidden="true"></i> -->
14+
<!-- <i class="fas fa fa-repeat" aria-hidden="true"></i> -->
15+
<i v-if='this.$router.app.$children[0].doneAction.length' class="fa fa-backward" aria-hidden="true" @click="undo"></i>
16+
<i v-else class="fa fa-backward" id="unavailable" aria-hidden="true"></i>
17+
<i v-if='this.$router.app.$children[0].undoneAction.length' class="fa fa-forward" aria-hidden="true" @click="redo"></i>
18+
<i v-else class="fa fa-forward" id="unavailable" aria-hidden="true"></i>
1219
<OpenProjectComponent />
1320
<SaveProjectComponent />
1421
<ExportProjectComponent />
22+
</div>
1523
</q-toolbar>
1624
</q-header>
1725

@@ -55,11 +63,42 @@ export default {
5563
SaveProjectComponent,
5664
OpenProjectComponent,
5765
UploadImage
66+
},
67+
methods: {
68+
undo () {
69+
console.log('UNDO FROM BUTTON')
70+
console.log('look at me ', this.$router.app.$children[0].doneAction)
71+
this.$router.app.$children[0].undo()
72+
},
73+
redo () {
74+
console.log('REDO FROM BUTTON')
75+
this.$router.app.$children[0].redo()
76+
}
5877
}
5978
}
6079
</script>
6180

6281
<style lang="stylus">
82+
83+
.fa-backward, .fa-forward {
84+
padding: 0 5px
85+
}
86+
87+
.fa-backward:hover, .fa-forward:hover {
88+
cursor: pointer;
89+
color: #00ffff
90+
}
91+
92+
#unavailable {
93+
color: grey;
94+
cursor: default
95+
}
96+
97+
.fa-backward:active, .fa-forward:active {
98+
box-shadow: 0 1px inherit;
99+
transform: translateY(1px);
100+
}
101+
63102
.q-layout {
64103
transition-timing-function: ease-in;
65104
}

0 commit comments

Comments
 (0)