-
Notifications
You must be signed in to change notification settings - Fork 368
Add onChange functionality to our DDF select fields #7311
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
Conversation
6ad928a to
7a3eada
Compare
7a3eada to
085bc05
Compare
|
How does a select have a "schema"? It should have options, but it already has static options in your example, Reading the example, that "schema" is not actually related to the select at all, in fact it just changes the rest of the form. IMO that's architecturally wrong, the form itself (our react component wrapping MiqFormRenderer), should be doing that kind of logic. A form field should not be affecting other form fields from inside itself. |
|
@himdel there's already an example of this in the provider forms: when you select what kind of provider you want to create, we send an API request to retrieve the schema related to the given provider. If you don't like the name of the component, I'm open for better ideas, this is again the problem of starting a metal band. |
|
No, my problem is not with the name, it's with one component changing the whole form schema, instead of the form changing the schema depending on the value from that component. EDIT: or a select-with-a-subform where that select only affects the subform schema But If you're just refactoring that for some other use, go for it 👍. |
The component is not changing anything, the function is defined in the form and passed to the component for calling it when its value changes. This is just an uglier |
|
Oooh.. ok, then |
085bc05 to
7c025b2
Compare
|
@himdel updated |
|
I'm thinking that maybe we can just simply enhance the existing |
|
LGTM :) reimplements the provider select field on top of a new select with an onchange handler exposed.
Up to you :) Then we would have a select that supports onChange, while none of the other standard components do, but then again, it makes sense to have it in the select. OTOH one more custom thing to remember. |
7c025b2 to
564596d
Compare
|
Checked commits skateman/manageiq-ui-classic@4dc7048~...564596d with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint |
|
@himdel changed, I guess it's ready for the final round |
This is a generalization of the
ProviderSelectFieldthat is being used in the provider forms to load the provider schema based on the user's selection in a dropdown. I adjusted the component and the provider form to solely rely on attributes passed to the schema instead of using a react context. We are using the PF3 select with a custom placeholder which has been defined directly in the mapper. In order to avoid circular dependencies, I exported this into a separate file and. Then I renamed the component and moved it out to the global mapper so we can utilize it in other forms as well.The dynamic loadin' is sorted out via the
onChangefunction that gets called on any change in the dropdown with the new value as a single argument. Ideally this can be used together with the state to alter the schema as we do it in the provider forms.@DavidResende0 this is how we're going to load the fields from the API if @himdel agrees