expandorg / worker-app

worker application
https://portal.expand.org/
Mozilla Public License 2.0
2 stars 0 forks source link

Input field modules needs the ability to set a default value #183

Closed kieranoreilly closed 5 years ago

kieranoreilly commented 5 years ago
{
  "modules": [
    {
      "title": "Find and Confirm the Details for Princeton University",
      "type": "title",
      "name": "title"
    },
    {
      "label": "University Name",
      "placeholder": "Type University Name",
      "type": "text",
      "name": "university",
      "value": "test",
      "validation": {
        "isRequired": "University Name is required"
      }
    },
    {
      "label": "Location",
      "placeholder": "Enter Location",
      "type": "text",
      "name": "location",
      "validation": {
        "isRequired": "Location is required"
      }
    },
    {
      "label": "Google Scholar Organization ID",
      "placeholder": "Google Scholar Organization ID",
      "type": "text",
      "name": "scholar",
      "validation": {
        "isRequired": "Google Scholar ID is required"
      }
    },
    {
      "label": "Website URL",
      "placeholder": "Website URL",
      "type": "text",
      "name": "website",
      "validation": {
        "isRequired": "Website is required"
      }
    },
    {
      "caption": "Submit",
      "type": "submit",
      "name": "children"
    }
  ]
}

I'm using the above json. We need to be able to set values for the information we have before the task begins so the user doesn't have to repeat University Name, or Location if we have it

kieranoreilly commented 5 years ago

@sslava can we prioritize this issue?

sslava commented 5 years ago

sure! will do it

kieranoreilly commented 5 years ago

Awesome! I saw there is an initial value now, but the initial value doesn't propagate when you click submit

sslava commented 5 years ago

aahh- that's weird, let me fix this

sslava commented 5 years ago

actually there is a few ways to fix it.

First on is good but it requires to introduce a naming convention for initial value, (all "initial" value is set as form values by default),

Another one is hacky and it work per component (call onChange(initial) in InputModule.componentDIdMount() method)

I will implement 2nd as a quickfix and rewrite it in proper way later

sslava commented 5 years ago

done! you can merge #187

kieranoreilly commented 5 years ago

Hi @sslava the form is still throwing errors for validation on submit. Happens locally but seems fine on the playground