vaadin / form-filler-addon

Other
4 stars 0 forks source link

Dynamic form investigation. #114

Open czp13 opened 1 year ago

czp13 commented 1 year ago

Feature explanation from the PRD doc made by Tarek:

Dynamic forms: In some forms (e.g., Bakery’s Order form), several items are added to the form by the user clicking on something like an “add” button. The API should enable the programmer an easy way to add several items to this kind of form based on the reply from ChatGPT.

We discussed on today's daily with @mgarciavaadin and @mshabarov that the feature is feasible, and we see the following way to do it right now after some hours of investigation and tech discussions:

Problematic parts:

  1. Extending the FormFiller API with a new method potential naming could be AutoFormFiller::aaddDymanicForm() or AutoFormFiller::addDynamicComponents()

  2. The new method would ask for the component and the callback arguments (AutoFormFiller::addDynamicComponents(verticalLayout, callback),

    • where the component would be the layout for the dynamic part of the form,
    • and the callback is a method, which would describe, how we would need to add the response components (in a different div or a layout? or different order of the components?)
  3. Then similarly to the Grid we would be able to match the response JSON lists with the components and fill one by one them.

As of right now ComponentUtils and FormFiller classes are handling components and not layouts for fills (big if-else part), We need to refactor and change quite many parts of the code and further investigation is needed how complex is this change.

+1) Potentially as we had this proposal, we could solve this without introducing a new API method, but in that case, we would need to have some assumptions for example:

This is a big question of coding convention over configuration

+2) We also brought up the topic of a fully dynamically generated form/components from a text: