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

return drop-down choices from validation function #1526

Open
bradNASA opened this issue Oct 27, 2024 · 1 comment
Open

return drop-down choices from validation function #1526

bradNASA opened this issue Oct 27, 2024 · 1 comment
Labels
clipper Requests from the Europa Clipper project feature New feature or request srl Requests from the SRL project

Comments

@bradNASA
Copy link

bradNASA commented Oct 27, 2024

Checked for duplicates

No - I haven't checked

Alternatives considered

Yes - and alternatives don't suffice

Related problems

I'm frustrated when I want to limit the drop-down choices for an activity (or configuration) parameter dynamically, but I need to determine them from an enum in the mission model Java code.

This closely related to #1075 including a possible solution for it.

Describe the feature request

The UI could use drop-down choices for activity (and simulation configuration) parameters calculated dynamically by validation functions for activities (and the simulation configuration).

Currently, a Java validation function for an activity type returns a boolean for whether the current parameter values are valid paired with an error message String if they are not. The feature request is

  1. that when the returned string is parsable as JSON, it be used to determine drop-down choices (and also the message in the tooltip) for both valid and invalid cases and
  2. that such validation functions be supported for simulation configurations, too.

Some examples of return statements for validation functions:

return new ValidationResult(false, "spice_dir", "{'choices':['spice cfg x', 'spice cfg y', 'spice cfg z'], 'message': 'The specified spice directory, spice_dir = " + spice_dir + " does not exist in " + SPICE_FOLDER + "}'); // invalid case for sim configuration

return new ValidationResult(true, "spice_dir", "{'choices':['spice cfg x', 'spice cfg y', 'spice cfg z'], 'message': 'Spice directories for spice_dir are located in " + SPICE_FOLDER + "}'"); // valid case for sim configuration

return new ValidationResult(true, "device_state", "{'choices' : {'device1' : ['OFF', 'ON'], 'device2' : ['0', '1', '2']}, 'message' : ''}"); // valid result with empty message for activity parameter with a Map value, customizing drop-down for both map keys and map values for each keys

return new ValidationResult(false, "device_state", "{'choices' : {'device1' : ['OFF', 'ON'], 'device2' : ['0', '1', '2']}, 'message' : 'There is no device state " + state + " for device, " + device + "' }"); // invalid result for activity parameter with a Map value, customizing drop-down for both map keys and map values for each keys

For activities, these return values require no change on the backend, but it could be worth adding additional members and constructors (for backwards compatibility) to the ValidationResult class to separate the 'choices' from the 'message'. I expect there are no validation functions for the sim config, but I didn't verify.

@bradNASA bradNASA added feature New feature or request clipper Requests from the Europa Clipper project srl Requests from the SRL project labels Oct 27, 2024
@bradNASA
Copy link
Author

Discussion thread in slack: https://jpl.slack.com/archives/C0163E42UBF/p1729797533146809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clipper Requests from the Europa Clipper project feature New feature or request srl Requests from the SRL project
Projects
None yet
Development

No branches or pull requests

1 participant