From 7837cf2e2240db456fc028ba370efc327a3400a0 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 17 Mar 2019 23:24:08 +0100 Subject: [PATCH] Implement & fix action edit popup showing existing actions --- src/options/App.vue | 1 + src/options/controls-settings/add-edit-action-popup.vue | 9 +++++++++ .../controls-settings/command-builder/command-block.vue | 5 +++-- .../controls-settings/command-builder/command-chain.vue | 1 + .../scope-settings-component/set-shortcut-button.vue | 8 ++++---- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/options/App.vue b/src/options/App.vue index 04c227b..f3b82e1 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -159,6 +159,7 @@ export default { showEditActionPopup(event) { console.log("SHOW EDIT ACTION/APP:", event) this.editActionPopupVisible = true; + this.editActionIndex = event; this.anyOpenedPopups = true; }, closePopups(){ diff --git a/src/options/controls-settings/add-edit-action-popup.vue b/src/options/controls-settings/add-edit-action-popup.vue index 7d05364..5a5222d 100644 --- a/src/options/controls-settings/add-edit-action-popup.vue +++ b/src/options/controls-settings/add-edit-action-popup.vue @@ -118,6 +118,12 @@ export default { } }, created () { + console.log("Opening action edit popup. Action index:", this.actionIndex, "\nAction:", this.settings.active.actions[this.actionIndex]); + if (this.actionIndex >= 0) { + // this.currentCmdIndex = this.actionIndex; + this.action = this.settings.active.actions[this.actionIndex]; + this.currentCmdIndex = this.actionIndex; + } }, computed: { globalScopeOptions: function() { @@ -145,6 +151,9 @@ export default { watch: { action: { deep: true, + handler: function(val) { + this.action = val; + } } }, methods: { diff --git a/src/options/controls-settings/command-builder/command-block.vue b/src/options/controls-settings/command-builder/command-block.vue index b5e2820..98cfc95 100644 --- a/src/options/controls-settings/command-builder/command-block.vue +++ b/src/options/controls-settings/command-builder/command-block.vue @@ -2,8 +2,8 @@
- {{ActionList[action.cmd].name}}: {{ - /*ActionList[action.cmd].args.find(x => x.arg === action.arg).arg ||*/ action.arg + {{ActionList[action.action].name}}: {{ + (ActionList[action.action].args.find(x => x.arg === action.arg) || action).arg }}
@@ -47,6 +47,7 @@ export default { } }, created () { + console.log("Creating command block for action:", JSON.parse(JSON.stringify(this.action)), JSON.parse(JSON.stringify(ActionList))) }, props: { action: Object, diff --git a/src/options/controls-settings/command-builder/command-chain.vue b/src/options/controls-settings/command-builder/command-chain.vue index 5ebcb00..567c9bc 100644 --- a/src/options/controls-settings/command-builder/command-chain.vue +++ b/src/options/controls-settings/command-builder/command-chain.vue @@ -26,6 +26,7 @@ import CommandAddEdit from './command-add-edit'; export default { created () { + console.log("Initializing command chain. Command:", JSON.parse(JSON.stringify(this.command))) }, components: { CommandBlock, diff --git a/src/options/controls-settings/scope-settings-component/set-shortcut-button.vue b/src/options/controls-settings/scope-settings-component/set-shortcut-button.vue index 9a33403..7810b4d 100644 --- a/src/options/controls-settings/scope-settings-component/set-shortcut-button.vue +++ b/src/options/controls-settings/scope-settings-component/set-shortcut-button.vue @@ -16,7 +16,7 @@ import KeyboardShortcutParser from '../../../common/js/KeyboardShortcutParser' export default { props: { - shortcut: Object, + shortcut: Array, // note: array in unlikely case we ever try to implement choords waitingForPress: false, }, data() { @@ -25,8 +25,8 @@ export default { } }, created(){ - if (this.shortcut) { - this.shortcutText = KeyboardShortcutParser.parseShortcut(shortcut); + if (this.shortcut && this.shortcut.length) { + this.shortcutText = KeyboardShortcutParser.parseShortcut(this.shortcut[0]); } }, methods: { @@ -45,7 +45,7 @@ export default { onKeyUp: true, onKeyDown: false, }; - this.$emit('set-shortcut', shortcut) + this.$emit('set-shortcut', [shortcut]) this.$refs.input.blur(); this.shortcutText = KeyboardShortcutParser.parseShortcut(shortcut); }