appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.56k stars 3.73k forks source link

[Feature]: Dynamically generating form structures #17617

Open Schniemax opened 2 years ago

Schniemax commented 2 years ago

Is there an existing issue for this?

Summary

Currently, the function "Generate from data table" already exists, which reads values from MongoDB and creates a nice editor. However, all components are generated statically and are therefore not customizable if multiple data types are present in the MongoDB collection. For example, a field "value" could accept values of type Object, as well as of type String or Integer and then differentiate. Also, when creating new elements, it should be possible to create Objects without a predefined structure.

Why should this be worked on?

I am currently trying to add some sort of stripped down version of MongoDB Compass to Appsmith for end users to view and or edit specific Collections in Appsmith. All items in these collections have approximately the following structure:

{ name: "string", value: >any< }

Here, value can actually have any data type supported by MongoDB.

If you create a table from MongoDB data for the first time, all table components and forms are generated based on the structure of the already existing elements.

Now the problem: If the collection has a not very static structure, it is problematic that the table elements are relatively static. So it may be that the form for creating new elements now has a field "value" which only supports Objects, although you want to enter a String or a Date, or instead of a String you want to enter an Object.

Another case is when you want to insert an object with custom columns, but the form just doesn't support it, because it only supports the previously defined columns.

Would it be possible in general to provide a dynamic generation as an option for e.g. some fields?

Nikhil-Nandagopal commented 2 years ago

@Schniemax I'd like to learn a bit more about your use case. As I understand it, in your data, the value type of the key is dynamically changing but in the case of the JSON form, it should automatically update based on the type of data

Schniemax commented 2 years ago

Im sorry for the late response. Our use case is the following:

We have created a MongoDB Collection, which we are using as a storage for configuration settings for several projects. We want to use appsmith for editing the configuration within the browser (basically some user-friendly simplified sort of replacement of MongoDB Compass).

Therefore a table for each collection of configurations is created.

Each setting entry has this structure:

{ name: "string", value: >any<, release: "boolean", delete: "boolean" }

Basically all entries just differ in the type of the value. It is possible that one entry contains an int, the other one a set and the third one an object inside.

The problem is, that the table just creates the edit form for one datatype, normally the first element. This can be changed, so that it adapts to all types of data, but still there are several problems. For example:

Also the creation of a new element can only support the first datatype in the collection. Therefore, when e.g. a String is loaded first, you can not create new objects or other types of data, because they will all be stored as string.

And thats the point. It would be great if the edit and new element form would support any datatype without the need of creating big workarounds that reduce usability.