From 12aaa2beb8ed7e50d30e7fac1ef03c9b0a98ac38 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 26 Jun 2020 23:43:37 +0200 Subject: [PATCH] Better representation for action default arguments and no more loss of values while changing the form --- src/options/Run.vue | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/options/Run.vue b/src/options/Run.vue index f35626b..67e2289 100644 --- a/src/options/Run.vue +++ b/src/options/Run.vue @@ -27,18 +27,18 @@
-
+
@@ -50,7 +50,7 @@
-
@@ -63,7 +63,7 @@
-
@@ -75,7 +75,7 @@
- +
@@ -111,7 +111,7 @@
- +
@@ -174,6 +174,7 @@ export default { action: { name: null, args: [], + defaultArgs: {}, }, }; }, @@ -244,6 +245,7 @@ export default { clearAction() { this.action.name = null; this.action.args = []; + this.action.defaultArgs = {}; this.actionResponse = null; this.actionError = null; }, @@ -287,6 +289,14 @@ export default { }); }, + removeActionArgument(i) { + this.action.args.splice(i, 1); + }, + + toggleSaveMode() { + this.saveMode = !this.saveMode; + }, + async loadPlugins() { this.pluginsLoading = true; @@ -377,12 +387,21 @@ export default { }, onActionChange(action) { + if (action === this.action.name) { + return; + } + this.action.name = action; this.action.args = []; - }, - onCategoryInput(event) { - console.log(event); + if (action in this.actions) { + this.action.defaultArgs = Object.entries(this.actions[action].args).reduce((obj, [name, arg]) => { + obj[name] = { ...arg, value: arg.default }; + return obj; + }, {}); + } else { + this.action.defaultArgs = {}; + } }, },