VxFormGenerator icon indicating copy to clipboard operation
VxFormGenerator copied to clipboard

Add a WASM example

Open Aaltuj opened this issue 5 years ago • 5 comments

By popular rquest add a WASM example.

VxFormgenerator should support WASM.

Aaltuj avatar Jan 07 '21 13:01 Aaltuj

Hi, I need implement this feature but in my WASM project. but through a configurator that saves this configuration in the database. What do you recommend me. is this library available in nuget?

mserey avatar Jan 24 '21 14:01 mserey

hi @mserey, You can find the nugets here. The readme in the develop branch contains the WASM Setup, no release yet, but 0.4.0 should work with those instructions.

Not sure what you mean with 'but through a configurator that saves this configuration in the database'

Aaltuj avatar Jan 26 '21 21:01 Aaltuj

Hi Instead of drawing the form through a poc, we must do it dynamically through a form builder whose configuration will be saved in the database. We thought to use expandobject generating the object at runtime obtaining the parameters from the database

mserey avatar Jan 26 '21 22:01 mserey

Aah I see what you are trying to accomplish. That is indeed the usecase for the expando object. However #5 is on the roadmap, here the idea is that the ExpandoObject will be deprecated, in favour for a JSON based schema. (this should be more a less a serialized object containing Built-in classes. Like the VxFormElementLayoutAttribute and the ValidationAttributes)

{
   "nameOfProperty": { // name of the property
     "attributes": 
                    {"MinLength": { "Length": 5  }, 
                     "Required":{}, 
                     "VxFormElementLayout": {  // VxFormElementLayoutAttribute  
                                          "label": "",
                                          "order": 0
                                          }",
                                           
                     }, // Attributes
     "type": "String", // Or a custom type
     "value": "The value of the property" // could be a complex type
    }
}

// Following this approach it is easier to parse and we could create nested objects as well, supporting VxGroup etc..

Under the hood there is a converter that use a 'empty' base class, where the properties would be added dynamicly via reflection. This converter is can be built separately from the generator and create an object that is usable with the form generator.

This also allows to construct an object with reflection added attributes, so no need for the component to handle the expandoobjects anymore. It is just an annotated object this way, removing complexity in the component and easier external definition storage.

so... to make a long story short: I recommend you try the described approach up here. Otherwise use the expando object way, but that doesn't support validations...

Feel free to add an concept of your solution in the issue #5 so we can discuss your proposed implementation . It would be nice if you could take issue #5 some steps further.

Aaltuj avatar Jan 27 '21 08:01 Aaltuj

ok I'll take your recommendation and try to dynamically build an object through reflection

mserey avatar Jan 28 '21 13:01 mserey