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

[Epic] JSON Form: Generate forms from JSON Object/Queries/APIs #2504

Closed
3 tasks
areyabhishek opened this issue Jan 9, 2021 · 48 comments · Fixed by #8472
Closed
3 tasks

[Epic] JSON Form: Generate forms from JSON Object/Queries/APIs #2504

areyabhishek opened this issue Jan 9, 2021 · 48 comments · Fixed by #8472
Assignees
Labels
Community Reported issues reported by community members Documentation Pod Issues related to user education Documentation Improvements or additions to documentation Epic A zenhub epic that describes a project Form Widget Medium effort Takes < 2 weeks Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets

Comments

@areyabhishek
Copy link
Contributor

areyabhishek commented Jan 9, 2021

Objective

As a user, I should be able to generate a form with input fields by using fields of a DB table schema that automatically generates the queries, bindings and child widgets. As a user, I should be able to configure changes/validations easily here.

Features

  • It should automatically identify the datatypes and associated widgets for the form
  • It should be able to add basic validations that can be enhanced by the user
  • It should be able to automatically connect the submit buttons to the relevant queries (PUT/POST/CREATE/UPDATE).

Success Metrics

Goal Metric
Simplify user experience One-click to generate a form from a single DB schema and be able to map it to a PUT/POST request which updates/saves data
Decrease the time needed to build a form Time that user spends creating a form

Assumptions

  • Forms are the core building block of a web application
  • It is currently difficult/time-taking to set up a working form comprising of multiple child widgets and bind them all the data query and finally be able to add them to a post request
  • One of the most common operations in any DB is the insert/add/create entry operation. It would go a long way to save the user time by generating the scaffolding, if not the complete widget for users

Requirements

Requirement User Story Importance Notes
Connecting to Query/API As a user, I should be provided with all the option to connect to different queries and APIs. Furthermore, I should be able to select the fields I need inside the form and I should be able to change the datatype to others from what was automatically connected High If this is not going to be based on the response object and depend on the DB schema, this will be removed from the scope
Create a form from a JSON object As a user, I should be provided with all the option to create a form from a JSON object apart from the Queries/APIs. All the other functionalities mentioned above will be extended here as well High -
Identify datatypes and associated widgets As a user, after connecting a DB query to the form, the platform needs to identify the widget types based on the data types. For ex: Array maps to Select widget. All the widgets need to remain configurable High related to the first requirement
Basic input validation As a user, I should be able to see basic input validations for the form I have created from an internal DB query and also be able to modify any of these easily High related to the first requirement
Connect submit action to queries that update related DB schema As a user, I should be able to easily configure the submit request which finally updates or saves my data. I should be shown all fields preloaded in my query and appropriate bindings against them High This might not be involved in this scope
Auto naming with schema / object keys All fields & label in the form should be named based on the schema key they are mapped to High -
Reopen form config Once import all fields from an object/datasource I should be able to reopen the config page view to alter any initial configurations. This will reset and changes made to the form elements individually. High The default connect data will be used for this, another CTA might be required to update the form data through the same workflow

Discussion 21-Sept-2021

  • We will get rid of the modal which shows up in when setting up the form fields, Instead we show the fields under the field configuration directly
  • Fields on the form will be deep linked to the property pane field configuration, i.e. the respective property pane field setting should open when the field on the form is clicked
  • The form fields / view will reflect changes as the form data is updates
  • We need to keep in mind a future scope while developing the feature. Nesting of form fields / handling nested form data objects needs design **_pending_**

Discussion 27-Sept-2021

We decided that the following will be the type of widget taking into consideration, Additionally the component used in this widget will have there own set of properties (like the table widget) which should be covered by automated tests to avoid any regressions in the future. We also discussed the form properties which will need design review

Types of fields:

  • Text
  • Number
  • Phone
  • Email
  • Switch (boolean)
  • Checkbox (boolean)
  • RadioGroup (exclusive or)
  • Select (one out of many)
  • Multi-Select (many out of many)
  • Files
  • Date
  • Time

    Complex fields:
  • Grouped fields

    Additional (optional) fields:
  • Rate (Range)
  • Map (search)
  • JSON object
  • Audio

We figured Properties of fields:

Common:

  • Type
  • Default
  • Label
  • Disabled
  • Required
  • Tooltip
  • Visible
  • helperText

    Not common:
  • Validation Fn
  • Error
  • Possible values (options)
  • Placeholder
  • onChange

**_needs design_**
Main properties of the form for it to work:
Form: data
Form: submit (action)
Form: source data
Form: Edit the field types and properties
​​
Features in the form:
Form -> input type -> possible properties
Form -> has state of the fields
Form -> onSubmit
Form -> onCancel
Form -> can hide cancel button
Form -> can disable submit button
Form -> can reset itself*
Form -> checks for validations -> knows which fields have errors
Form -> tab navigation works
Form -> can scroll to selected fields
Form -> button location (sticky | bottom)
Form -> field styling (borders, colors, label alignment, error colors, helper text, etc)
Form -> spacing between fields
Form -> all fields have full width


Library to consider: react-hook-forms


Discussion 19-Oct-2021

Files component is being considered out of scope right now as the implementation of the widget component is not well constructed to be used in this widget and would need a lot of refactoring.
This can be considered in the next iteration.

Out of Scope

  • Dynamic width / auto layout of form elements
  • Alignment templates/Layouts - As a dev, I should be able to choose the layout for aligning my input fields in the form. Templates can be 2 Column, Single column, Label & input side by side. Or, Drag to re-order elements side by side or one below the other

Developer Handoff Document in Figma

Link: https://www.figma.com/file/pZuLD9mWXtk45TOjAeh32b/Form-Widget-Thu-26-Aug?node-id=2%3A2

Questions

Question Answer Date Answered
How to identify the submit request needs to be Create/Update? It will by default be POST the user can change to there choice
Can we add necessary formatting function ex: JSON.stringify() automatically to remove any invalid api attributes
@naveennazimudeen
Copy link

naveennazimudeen commented Mar 30, 2021

It will be great if this can be combined with #2576 to show related information below. Tables have relationship, sometimes expressed in database as foreign keys, sometimes relationships exist but is deliberately not defined as foreign key relationships in DB. For example Invoices have a 1:n relationship with line-items, line-items might have 1:1 relationship to product. Similarly for Users and Logins, for Companies and Contacts, Subscription and Payments and so on.

So when defining an invoice page (View Page), it should be possible to see Invoice Line items as table below, where you can possibly filter, search, create (line by line, or go to new page), and edit (line by line, or go to individual edit page). The product column can possibly be linked to the product view page. While creating a line-item, it should be possible to "search as you type" for product (1:1 relation) with an option to create a product (in a modal window) if one does not exist .

Relationships can be captured independent of DB Foreign keys in appsmith, may be when a query is defined for view page, users can define more queries for relationship records, with an option to define 1:1 relationship columns such as productId from the invoice example.

@somangshu
Copy link
Contributor

#1724 is a related issue. Can one of them be closed?

@Nikhil-Nandagopal
Copy link
Contributor

Why is

The form can be generated from the JSON object

out of scope? That should be the core of it since to generate the form from the DB schema, we need a JSON object right?

@somangshu
Copy link
Contributor

Just for the purpose of the design phases, You are right though! I will add it to the list of requirements!

@somangshu
Copy link
Contributor

Create granular tasks after design is completed.

@somangshu somangshu changed the title [Feature] Generate forms from JSON, DB table, API response [Feature] Form builder: Generate forms from Object/Queries/APIs Jul 15, 2021
@rishabhsaxena
Copy link
Contributor

Just to pitch in, I was wondering if we have any plans to do wizard forms, basically a form with multiple steps

@Nikhil-Nandagopal
Copy link
Contributor

@rishabhsaxena great point. Thought might need to be a separate widget. Could you raise an issue for a wizard?

@rishabhsaxena
Copy link
Contributor

@Nikhil-Nandagopal Yeah just created an issue for this #6351

@somangshu
Copy link
Contributor

somangshu commented Aug 3, 2021

After a brief discussion, Here is what we understand:

  • Showing all fields as tile inside the property pane (like table widget) can be a viable option, However this is does not let the user see and change all config together and might be tedious to update.
  • Showing all options in the modal can be better but will be an inconsistent experience
  • There are two ways to let the user select layout
    • Through a separate widget (column / layout widget)
    • Giving a few custom options while setting up the form (1 column or 2 column)
  • Technically we feel that once the fields are organised and finalised we can do the following:
    • Let the user drag and drop anything they'd like without any constrain, but the initial settings are no longer available. In case they wish to start again, there changes are going to be lost
    • The user is not allowed to D&D anything directly and only allow them to do this via config panel (probably have a separate widget in this case - [Feature] JSON Form Widget #1724)

@momcilo-appsmith @riodeuno please add anything i might be missing here.

cc: @areyabhishek @Nikhil-Nandagopal

Reference form builder

@tomjose92
Copy link

Hey team, any timeline on this. This would be a great feature to have

@somangshu
Copy link
Contributor

@tomjose92 we are in the process are getting designs done for this feature, We will be taking this up for implementation in the month of sept.

@ashit-rath
Copy link
Contributor

Action Items:

  • Solve for the best way to sanitize/represent JSON keys that cannot be referenced with a dot (.) notation (eg "first name")

@dilippitchika
Copy link
Contributor

For the clear functionality -
I was finding any existing bugs linked to form widget where users wanted to keep/remove defaults on click of reset. Found one in support of keeping defaults #4230. I believe removing defaults can be asked by devs at somepoint, but let's wait to see any evidence of this ask and then decide if we want it.

When we decide to add the functionality, this is what the change may be

  1. Reset a widget will have another option to set to empty vs default. This can be used by all buttons and not just form buttons.
  2. There should be one button element which can be used in a regular case and form case. Today there’s no binding on property pane for form reset button. Even if you turn off reset on success, it still goes ahead and restores defaults after you click. This binding today is implicit i think. We are planning to solve this [Feature]-[800]:Deprecate form button widget #3613

@somangshu
Copy link
Contributor

@dilippitchika #3613 is about merging form and normal button and have one for them, which can be used in both places, And henceforth reducing the chance of being error prone.

I still think that reset should go back to the default set, I am also pointing out to the crud page functionality we have, Where reset goes to default, This is very much expected. Even in this case.

@dilippitchika
Copy link
Contributor

Second that @somangshu, just pointing out what we may need to do if we end up implementing it someday. Not doing the clear functionality for now.

@ashit-rath
Copy link
Contributor

Action Items:
Required field and accordion updated designs @vasanth-appsmith
Sanitize source data keys similar to Table widget V2 @ashit-rath
Test Plan @vivekverma2312

@mmkal
Copy link

mmkal commented Jan 16, 2022

Has https://react-jsonschema-form.readthedocs.io been considered for this? It would cover the majority of use cases, but I'd imagine would take hours/days to implement rather than weeks/months/years. You just install the library! It might be worth a separate issue because it seems like there's a little more in scope here. Rjsf wouldn't know about database schemas out of the box, of course, but there would still be huge value in it. Coming from retool, we have a subsection of our api which we map with zero effort to useable UI forms for ops people. I'm new to appsmith, but familiar with react and typescript - is there a way we could use custom react components right now? If so we could probably get it working then contribute a PR.

@somangshu
Copy link
Contributor

somangshu commented Jan 17, 2022

Hey @mmkal thanks a lot for showing interest on this feature. Yes indeed we have considered this package while building our own JSON Editor. Keeping the usefulness of this feature for the community in mind, we felt we needed customised experience, and hence we went about building stuff by ourself, We are near completion for v1 and would love to have your feedback, Please checkout this deploy preview to try out the feature, You can use any dummy credentials to login.

@Nikhil-Nandagopal
Copy link
Contributor

@mmkal just to add to what somangshu means, react-jsonschema-form requires our users to learn a whole new schema language which we felt was too cumbersome. With our current implementation, you can just connect any object and the form will automatically render. You can then customise the properties of every field visually without needing to learn a schema

@mmkal
Copy link

mmkal commented Jan 18, 2022

I see, that makes sense, thank you for the response. In the case I'm hoping to successfully port from retool, we have json schema objects from the api already, and we don't have json data objects to work with. It sounds like this is a different use case though, so I think I'll do some more exploring and create a separate issue (or PR).

@ashit-rath ashit-rath mentioned this issue Jan 24, 2022
7 tasks
@somangshu somangshu added the Documentation Improvements or additions to documentation label Jan 24, 2022
@github-actions github-actions bot added the Documentation Pod Issues related to user education label Jan 24, 2022
@somangshu
Copy link
Contributor

somangshu commented Jan 24, 2022

Actionable:


@ashit-rath
Copy link
Contributor

Actionables:

@ashit-rath
Copy link
Contributor

Performance issue update:
We had a discussion around the performance of the JSON Form widget when a large source data is used. The render time seems to come around 60 secs if we try to have ~150 fields (mix of arrays and objects) and out of ~60sec evaluations are taking around ~50secs; this is only for the first render.

Next steps:

  1. Triage the cause of evaluations taking ~50secs for evaluating the schema.
  2. We would be having a limit to how many fields the users are allowed to have in a form as having 200+ fields may lead the app to be in an unrecoverable state.

@ashit-rath
Copy link
Contributor

Actionables:

@ashit-rath
Copy link
Contributor

Actionables:

  1. Setup an app-building exercise using JSON form and collect feedback. @ashit-rath
  2. Add default source data @ashit-rath
  3. Modify the limit message for the Appsmith app viewers @ashit-rath
  4. Discuss ways to cache/retain fields to reduce loss of configuration. @ashit-rath @riodeuno @somangshu
  5. Implement the ongoing defaultValue DX changes for the select and multi-select V2. ([Bug][DX] Use both string and Object values for the default values in select and Multiselect widget #11074) @ashit-rath

@ashit-rath
Copy link
Contributor

Actionables:

@ashit-rath
Copy link
Contributor

ashit-rath commented Feb 28, 2022

Actionables:

@dilippitchika
Copy link
Contributor

Accessor name change in JSON form

Suggestion to call this an “Alias” as - "a way to refer this field". We are also following the same pattern in the table widget.

CC - @ashit-rath @somangshu

@ashit-rath
Copy link
Contributor

ashit-rath commented Mar 7, 2022

Actionables:

@somangshu
Copy link
Contributor

  • release
    • Final QA feedback
    • test non-ASCII support
    • address any issue from QA feedback

@Nikhil-Nandagopal Nikhil-Nandagopal added the Widgets & Accelerators Pod Issues related to widgets & Accelerators label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Reported issues reported by community members Documentation Pod Issues related to user education Documentation Improvements or additions to documentation Epic A zenhub epic that describes a project Form Widget Medium effort Takes < 2 weeks Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging a pull request may close this issue.