0

I have form. This form has lot of input elements. User interaction with form: User first selects a product from multiselect (can select up to 32 products). Based on the selected product we show other form elements, which user has to fill. Input fields for a particular product can be categorized in mainly 3 categories.

  1. Company related fields: (Company selection component) who is the buyer? etc.
  2. Other fields: (Radio buttons, checkboxes, text, date etc..) Does buyer has sufficient money to buy? Etc.
  3. Special other fields: These are same as other fields but their answer can add more products in the form, which in-term will add more input fields. E.g. if answer of Does buyer has sufficient money to buy is NO. Then you might ask another question such as, if buyer doesn’t have money then do you think we should include product 2 as well which is for raising money for buyer to buy this commodity.

After that user fills some common fields, these are not related to a particular product. As per the mocks given, entire form is divided in multiple accordions. See attached screenshots. Notes:

  1. Model to support this form looks like this: (One model for entire form)

Form : { Buyers: [ { Name : "Abc", Id : 1234 }, ], Sellers: [ { Name : "Abc", Id : 1234 }, ], Money: "", Question1: "", Question2 : "", }

  1. Common company related questions should be grouped together. E.g. say product 1 has a question called “Who is the buyer” and product 2 also has a question called “Who is the buyer”, then if user selects both the products, question with name Who is the buyer should not be shown more than once.
  2. Form needs to be validated for validations such as “required”, “min-length” and any other custom validation.
  3. Data model json (point # 1) will be saved when user clicks the submit button on the bottom of the page.

My Questions:

  1. Scalable: How to architect the form so that adding/updating more form sections is not a pain later. This also needs to take care of the custom event handling for form elements. (Adding another product based on the answer of a question is an example of that)
  2. Performance: How to design this form so that it loads fast, even if user adds 5+ products.
  3. Maintainable: Another most important aspect is readability; it shouldn’t become one giant blob of elements which a new developer in the team is scared of touching.

High level design/architecture will be really helpful. Mock of UI Page

Tech stack I am thinking of using: React and Redux

1
  • 1
    Have you tried to do this yourself yet? If you are going to use react and redux then consider redux form, redux-form.com/6.7.0. Commented Jun 8, 2017 at 5:04

1 Answer 1

1

You can use React + Redux + Webpack

Videos : Click here to watch React + Redux + Webpack videos

You have to create Model (data) and Component visibility flag (componentToLoad) inside store like:

store={
    data:{
        Buyer:'xxx',
        Seller:'xxx',
        etc,
    },
    componentToLoad:{
        LoadBuyerComponent:true,
        LoadSellerComponent:false,
        etc,
    }
}

Create different component for Buyers,Sellers,etc

class Buyer extends Component {
    render() {
        return (
          //HTML Code
          <div>        
          </div>
     )
}

class Seller extends Component {
    render() {
        return (
          //HTML Code
          <div>        
          </div>
     )
}

You can load component dynamically based on store

class MainForm extends Component {
    render() {
        var components = [];
        if(this.props.componentToLoad.LoadBuyerComponent == true)
            components.push(<Buyer/>)
        if(this.props.componentToLoad.LoadSellerComponent == true)
            components.push(<Seller/>)
        return (
          <div>      
              {components}  
          </div>
     )
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.