Skip to content

Commit c479638

Browse files
committed
Fix for complex commanding
1 parent 86b0175 commit c479638

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/fprime_gds/flask/static/addons/commanding/command-history.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,27 @@ Vue.component("command-history", {
103103
// Can only set command if it is a child of a command input
104104
if (this.$parent.selectCmd) {
105105
// command-input expects an array of strings as arguments
106-
this.$parent.selectCmd(cmd.full_name, cmd.args.map(el => el.toString ? el.toString() : el));
106+
this.$parent.selectCmd(cmd.full_name, this.preprocess_args(cmd.args));
107+
}
108+
},
109+
/**
110+
* Process the arguments for a command. If the argument is (or contains) a number, it
111+
* is converted to a string. Other types that should be pre-processed can be added here.
112+
*
113+
* @param {*} args
114+
* @returns args processed for command input (numbers converted to strings)
115+
*/
116+
preprocess_args(args) {
117+
if (Array.isArray(args)) {
118+
return args.map(el => this.preprocess_args(el));
119+
} else if (typeof args === 'object' && args !== null) {
120+
return Object.fromEntries(
121+
Object.entries(args).map(([key, value]) => [key, this.preprocess_args(value)])
122+
);
123+
} else if (typeof args === 'number') {
124+
return args.toString();
125+
} else {
126+
return args;
107127
}
108128
}
109129
}

0 commit comments

Comments
 (0)