-
Notifications
You must be signed in to change notification settings - Fork 107
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
Enable loading of values for all 'select-type' components via Form input data #197
Comments
Hi @dfulgham , thanks for investing into this! Just so that I understand:
Could you please elaborate why you propose to introduce a new property for this and not re-use the existing key (and just give it an array?) I suppose because you want to support the |
Yes in all 3 points, as with all fields I assumed that its "key" would be used to set its existing value from imported data, and hold its selected value if changed, so this is why I elected to go with a new set of properties to select the data that would be used to populate the option values.
To elaborate, yes in keeping with the function of all fields the key indicates which data is to be used for its value, no other reason. Supplying and Array of { label, value } to the fields key would not be aligned with existing function. If I were to use the fields key to pass an array, its initial value would be an array, then once I selected a value, that keys value would change to just that selected value, and then the select would no longer function, as the value would now be a primitive ( string, number, or boolean ). It also has the added benefit of being able to re-use the same options on other fields (if needed), in the example I used the "options" key for both the select and the radio. Use case would be if you have a long standard set of options and there are a few fields where you would need to use them on a single form. |
* Adding OptionsFromKeyEntry to GeneralGroup * added optionFromKey:boolean, optionsKey:string field properties to allow select and radio to load their options form imported data. * updated importer to import initialData for keys used by selects and radios * Also refactored playground submit data to properly filter to only fields that are present. Refs bpmn-io#197
@dfulgham Fair point from a usability perspective homogenizing input and output values is more intuitive 👍 |
As discussed via the dynamic forms Kickoff, we also plan to support providing functions next to a simple list for dynamic values. A sketch of this, not necessarily what we are going to build // Schema
{
"components": [
{
"key": "product",
"label": "Product",
"type": "radio",
"values": [],
"valuesKey": "productValues",
"id": "Field_0te6n1q"
},
...
]
}
// Input data
{
"product": "camunda-platform",
"productValues": async function() {
// do whatever you want
// return possible values
const products = await fetch(...);
return products.map(p => {
return { label: p.name, value: p.key }
}
}
} |
I used this pull request to create a spike.
npx @bpmn-io/sr bpmn-io/form-js#197-dynamic-multi-components -c "npm run start:playground" --verbose Observations / open questions (WIP) general
form-js-editor
form-js-viewer
form-js-playground
|
Very interesting questions you summarized here @pinussilvestrus ! My 2-cents (gut feeling):
I have no insight or opinion on:
|
I'd disagree here. What will be the composition semantics? How are default and dynamic values joined? Could I overrule default values, if so how? Hybrid does raise so many questions, both for the modeler, but also as I hook up dynamic data. My two cents:
Static vs. dynamic is a classic case for me of "using expressions rather than UI". If it was a FEEL expression, static vs. dynamic is handled naturally:
I know that we'll leave the realm of "simple editing" here. But the UI becomes significantly complex with modes, too. If I baked it into the UI, I'd do so via a So what I'd suggest us doing is:
Maybe it is even two different form components? Simple answers 😉:
No we don't we only keep data that is bound to a editable field. Cf. blog post.
Not in the data editors ("playground"), but users can provide them as they integrate form-js. |
Yes, that is what I'd do, at least for radio lists. |
I think so. |
For my personal opinion:
I think a hard cut makes it easier for now, we just need to support some kind of way in the future if it becomes apparent that the merging scenario is often used. If we're ever allowing merging of sources this should be somewhat reflected in our UI/UX. If we ever intend to create sources like functions, will we allow those to be merged in as well? To me, a source of data is a source of data, whether they are static, input driven, generated, queried, ect... If we wanted a configuration level source concatenation, static and input driven should live on a flat plane together IMO. Ultimately I think this is best left to FEEL, Generally I'm just not a fan of two configuration areas to drive the same thing. Right now the way I'd leave it is to rewrite the values group in the properties panel to include a select field with all the different possible "sources" of data, and dynamically display the appropriate configuration fields depending on what you've selected. This is kinda nice because you don't have to worry about individual controls, the configuration is kept neatly within the "Values" block.
Source something? Input something? Input Value Source 😄 I'm also not a big fan of ValuesKey either.
I think it should be a select, we're going to have even more population sources in the future potentially. Then I'd imagine conditional fields that appear from the select.
No. Any process should already be aware of enough context that that particular value shouldn't offer any extra information. |
Alignment with @felix-mueller and @christian-konrad
|
Sorry I've been away for a bit, back now. I agree with @nikku here if you wanted to implement a hybrid that could be accomplished within you own client code, you would have the schema available, to integrate the default values however you like and then modify the schema before substantiating the Form. Adding something like this within the component would not be recommended. Also with the work on custom components you could create a component to handle this anyway you would like. Also now that I'm back, what can I work on here to move this along? |
We had some discussions on whether we want to include a The main reason for this was to know how we'd handle the case where someone sets multiple of these properties. What we'll do however instead is just agree on an order of defaulting priorities, and always make sure that no two properties are set within the implementation in |
Couple of decisions I'd like to document on this for reference in the future:
Expect a Draft PR for this very soon 😄 |
If this indicates "percentage progress wise" I'd argue we do not need it. Data loading (and capturing the three states "loading", "loaded" and "error" can be mapped to promises in a straight forward manner => We should simply offer a promise based interfaces. Happy to checkout your draft PR, I'm looking forward to it. |
@nikku Not intending to have percentage progress, but doing this in a stateful manner is quite nice within React because 1: it lets us do conditional rendering based on the state (picture a spinner based on the 'loading' state) and 2: it gives us the flexibility to mix and match based on our implementation. We can definitely discuss more how we want this to look but the way I see it there will need to be some kind of state somewhere, so might as well go full React with it. (useState/useEffect to drive the async stuff). |
My point is: Let us not go "Full react" with interfaces to the outside we propose. Let us go "Web standards" and allow fetching data "The way users fetch data on the web". Happy to continue the discourse on the PR. Looking forward. |
As I understood it, at this stage, we are not talking about outside API here but how we handle async data loading internally. But let's wait for a PR to discuss this manner 👍 |
Hi all, In the course of loosely defining what we need to do to add this feature to C7, we had an idea I would like to share. The idea revolves around the use case that a developer wants to do rapid prototyping with this feature. How the dynamic values are defined in JSON makes sense for real-world scenarios where you want to assign a proper label to an element. However, it stands a bit in the way of "quickly trying something out". For the "rapid prototyping" use case, we thought we could additionally offer a mapping that would shorten the whole thing a bit: ["dynamicValue1", "dynamicValue2"] Would be mapped to: [
{
"label": "dynamicValue1",
"value": "dynamicValue1"
},
{
"label": "dynamicValue2",
"value": "dynamicValue2"
}
] Both Do you have an opinion on that? We can easily build it ourselves in C7, but I wanted to share the idea with a broader group and get some more thoughts. Best, |
Hi @tasso94, pretty interesting thought, something like a "quick-edit" of input data. I could imagine this not only for the JSON data but also for defining {
"label": "Radio",
"type": "radio",
"id": "myRadio",
"key": "radio",
"values": [ "Value1", "Value2", "Value3" ]
} This would definitely ease the way how you provide values, in case you need it. However, we would also need to maintain this syntax, e.g.: Would the output data then also have this short format, or would it be transformed into the label-value syntax? Can I configure this? To not overload this issue, as it's already shaped and in progress, can you maybe open another one where we can discuss this matter? That would be helpful 🙂 |
I actually had this idea in mind but somewhere along the line I forgot about it. Honestly, nothing stops us from handling this case, and it wouldn't be a big dev effort. I second @pinussilvestrus though we can take this discussion to another issue. |
Is your feature request related to a problem? Please describe
As part of our dynamic data loading initiative for our form components, we would want to enable users to drive their select-able data from sources other than the form schema.
As a starting point, we'll enable users to pass in the data themselves from outside the form via
form input data
, this first ticket handles that functionality. Following up to this will be allowing the configuration of the type of data source via the properties panel, as it is currently blocked by #249.Describe the solution you'd like
We want to support the rendering of 'select-type' component values via Input data, so that a form designer may dynamically build up these components.
To this end, we'll need a few things:
SCHEMA EXAMPLE
schema
form data input
Result
Implementation steps:
Describe alternatives you've considered
n/a
Additional context
Requires #196
Raised during discussion of https://jira.camunda.com/browse/SUPPORT-12025
Also requested via https://jira.camunda.com/browse/SUPPORT-12306
Child of #200
The text was updated successfully, but these errors were encountered: