Skip to content
Snippets Groups Projects
Commit b938c676 authored by Eva Bardou's avatar Eva Bardou Committed by Valentin Rigal
Browse files

Rename store mutations

parent eb9ba04e
No related branches found
No related tags found
1 merge request!19Rename store mutations
Pipeline #5660 passed with warnings
...@@ -77,11 +77,11 @@ export default { ...@@ -77,11 +77,11 @@ export default {
displayUTF8, displayUTF8,
}, },
methods: { methods: {
...mapMutations(["updateKey"]), ...mapMutations(["updateKeyboardKey"]),
replace() { replace() {
if (!this.selectedKey || !this.selectedChar) return; if (!this.selectedKey || !this.selectedChar) return;
// Update the keyboard // Update the keyboard
this.updateKey({ this.updateKeyboardKey({
index: this.keyboardIndex, index: this.keyboardIndex,
...this.selectedKey, ...this.selectedKey,
character: displayUTF8(this.selectedChar.code), character: displayUTF8(this.selectedChar.code),
...@@ -91,7 +91,7 @@ export default { ...@@ -91,7 +91,7 @@ export default {
this.picker = false; this.picker = false;
}, },
updateKeyBinding() { updateKeyBinding() {
this.updateKey({ this.updateKeyboardKey({
index: this.keyboardIndex, index: this.keyboardIndex,
...this.selectedKey, ...this.selectedKey,
keyboard_code: this.keyBinding ? this.keyBinding.charCodeAt() : null, keyboard_code: this.keyBinding ? this.keyBinding.charCodeAt() : null,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</a> </a>
<input type="text" v-model="keyboardName" /> <input type="text" v-model="keyboardName" />
<button type="button" v-on:click="updateKeyboardName">Save</button> <button type="button" v-on:click="changeKeyboardName">Save</button>
<KeyboardConfiguration :keyboard-index="editedKeyboard" /> <KeyboardConfiguration :keyboard-index="editedKeyboard" />
</div> </div>
<div v-else-if="selectedKeyboard !== null"> <div v-else-if="selectedKeyboard !== null">
...@@ -104,18 +104,18 @@ export default { ...@@ -104,18 +104,18 @@ export default {
...mapState(["keyboards"]), ...mapState(["keyboards"]),
}, },
methods: { methods: {
...mapMutations(["add", "delete", "updateName"]), ...mapMutations(["addKeyboard", "removeKeyboard", "updateKeyboardName"]),
updateKeyboardName() { changeKeyboardName() {
this.updateName({ this.updateKeyboardName({
index: this.editedKeyboard, index: this.editedKeyboard,
name: this.keyboardName, name: this.keyboardName,
}); });
}, },
createKeyboard() { createKeyboard() {
this.add(); this.addKeyboard();
}, },
deleteKeyboard() { deleteKeyboard() {
this.delete(this.keyboardToDelete); this.removeKeyboard(this.keyboardToDelete);
this.keyboardToDelete = null; this.keyboardToDelete = null;
this.deleteModal = false; this.deleteModal = false;
}, },
......
...@@ -44,17 +44,17 @@ export default new Vuex.Store({ ...@@ -44,17 +44,17 @@ export default new Vuex.Store({
setSelectedScript(state, { name, page }) { setSelectedScript(state, { name, page }) {
state.selectedScript = { name, page }; state.selectedScript = { name, page };
}, },
add(state) { addKeyboard(state) {
state.keyboards = [...state.keyboards, { ...NEW_KEYBOARD }]; state.keyboards = [...state.keyboards, { ...NEW_KEYBOARD }];
}, },
delete(state, index) { removeKeyboard(state, index) {
state.keyboards.splice(index, 1); state.keyboards.splice(index, 1);
}, },
updateName(state, { index, name }) { updateKeyboardName(state, { index, name }) {
if (!state.keyboards[index]) return; if (!state.keyboards[index]) return;
state.keyboards[index].name = name; state.keyboards[index].name = name;
}, },
updateKey(state, { index, ...newKey }) { updateKeyboardKey(state, { index, ...newKey }) {
// Copy the keyboard if the index is correct to avoid modifying it directly in the state // Copy the keyboard if the index is correct to avoid modifying it directly in the state
const keyboard = state.keyboards[index] && { ...state.keyboards[index] }; const keyboard = state.keyboards[index] && { ...state.keyboards[index] };
if (!keyboard) return; if (!keyboard) return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment