Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command argument types when importing from history #159

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/fprime_gds/flask/static/addons/commanding/command-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,29 @@ Vue.component("command-history", {
cmd.full_name = template.full_name;
// Can only set command if it is a child of a command input
if (this.$parent.selectCmd) {
this.$parent.selectCmd(cmd.full_name, cmd.args);
// command-input expects an array of strings as arguments
this.$parent.selectCmd(cmd.full_name, this.preprocess_args(cmd.args));
}
},
/**
* Process the arguments for a command. If the argument is (or contains) a number, it
* is converted to a string. Other types that should be pre-processed can be added here.
*
* @param {*} args
* @returns args processed for command input (numbers converted to strings)
*/
preprocess_args(args) {
if (Array.isArray(args)) {
return args.map(el => this.preprocess_args(el));
} else if (typeof args === 'object' && args !== null) {
return Object.fromEntries(
Object.entries(args).map(([key, value]) => [key, this.preprocess_args(value)])
);
} else if (typeof args === 'number') {
return args.toString();
} else {
return args;
}
}
}
});
});
Loading