Skip to content

Commit bf461ef

Browse files
author
Julia Bakerink
committed
Added export Typescript checkbox option and successfully changed the state using v-bind
1 parent b03dd41 commit bf461ef

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

src/layouts/MyLayout.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Description:
1818
</q-btn>
1919
<q-toolbar-title> OverVue </q-toolbar-title>
2020
<label for="typescript" style="margin-right: 10px;">
21-
<input type="checkbox" name="typescript" id="typescript" />
21+
<input type="checkbox" name="typescript" id="typescript" :value="exportAsTypescript" @change="syncTypescriptFlag" />
2222
Use Typescript
2323
</label>
2424
<SlackLoginWindow />
@@ -117,6 +117,7 @@ import OpenProjectComponent from "../components/file_system_interface/OpenProjec
117117
import SlackLoginWindow from "../components/slack_login/SlackLoginWindow.vue";
118118
import ComponentTab from "../components/home_sidebar_items/ComponentTab/ComponentTab.vue";
119119
import StoreTab from "../components/home_sidebar_items/StoreTab/StoreTab.vue";
120+
import { mapState } from "vuex";
120121
121122
export default {
122123
// Passed down from App.vue
@@ -137,6 +138,11 @@ export default {
137138
ComponentTab,
138139
StoreTab,
139140
},
141+
computed: {
142+
...mapState([
143+
"exportAsTypescript"
144+
]),
145+
},
140146
methods: {
141147
undo() {
142148
// this.$router.app.$children[0].undo();
@@ -146,6 +152,15 @@ export default {
146152
redo() {
147153
this.$emit("redo");
148154
},
155+
syncTypescriptFlag(e) {
156+
let checkboxValue;
157+
if (e.target.value === "off") {
158+
checkboxValue = "on"
159+
} else {
160+
checkboxValue = "off"
161+
}
162+
this.$store.commit('EXPORT_AS_TYPESCRIPT', checkboxValue);
163+
},
149164
},
150165
};
151166
</script>

src/store/mutations.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ const mutations = {
8989

9090
// *** VUEX *** //////////////////////////////////////////////
9191

92+
93+
[types.EXPORT_AS_TYPESCRIPT]: (state, payload) => {
94+
state.exportAsTypescript = payload;
95+
},
96+
9297
[types.CREATE_ACTION]: (state, payload) => {
9398
state.userActions.push(payload);
9499
state.userActions.sort();

src/store/state/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import icons from './icons'
22
import htmlElementMap from './htmlElementMap'
33

4+
45
const cloneDeep = require('lodash.clonedeep')
56

67
const newState = {
@@ -56,7 +57,7 @@ const newState = {
5657
copyNumber: 0,
5758
pastedComponent: {},
5859

59-
exportAsTypescript: false,
60+
exportAsTypescript: 'off',
6061
}
6162

6263
// closured method to ensure we only ever write the default state ONCE

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const UPDATE_COMPONENT_SIZE = 'UPDATE_COMPONENT_SIZE'
6262
export const UPDATE_OPEN_MODAL = 'UPDATE_OPEN_MODAL'
6363
export const DELETE_USER_ACTIONS = 'DELETE_USER_ACTIONS'
6464
export const DELETE_USER_STATE = 'DELETE_USER_STATE'
65+
export const EXPORT_AS_TYPESCRIPT = 'EXPORT_AS_TYPESCRIPT'
6566

6667
// Actions
6768
export const addActionSelected = 'addActionSelected'
@@ -123,6 +124,7 @@ export const updateStartingSize = 'updateStartingSize'
123124
export const deleteUserActions = 'deleteUserActions'
124125
export const deleteUserState = 'deleteUserState'
125126

127+
126128
// inactive mutations
127129
// export const SET_STATE = 'SET_STATE'
128130
// export const DELETE_COMPONENT = 'DELETE_COMPONENT'

0 commit comments

Comments
 (0)