-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
validate agent option json on form submit #1434
Conversation
Great idea @Enfop! There appears to be a bug on Agents that use our form builder, though. Try it with the Basecamp agent. I think it binds the events too early. Maybe this would work better? $('form.agent-form').submit (e) ->
if $('textarea#agent_options').length
try
JSON.parse $('#agent_options').val()
catch err
e.preventDefault()
alert 'Sorry, there appears to be an error in your JSON input. Please fix it before continuing.' |
Uhh sorry about that. Didn't checked the agents which are form_configurable. Your suggestion worked great and fixed the issue. If it's ok i will add some feature specs to ensure the right behaviour. |
That would be great! |
It seems that Poltergeist doesn't support checks for javascript alerts It works but i'm not sure if there is a better solution. |
It may not be worth trying to feature test that the alerts show up. What do you think? Is it worth it? I'd like us to bring in JS unit testing at some point -- Jasmine or Mocha, perhaps -- which would test this more easily. |
I think it's ok to include the workaround, development and test dependencies do not concern me very much. We use alert popups in a few views, this can come in helpful when we add feature tests for them as well. |
That's reasonable. @Enfop, can you merge master back into your PR? |
Sure. |
check for textarea#agent_options after form submit
b7d016b
to
66fe418
Compare
trailing new lines fix specs
66fe418
to
ada5b02
Compare
not sure why travis build is failing. Local tests work fine. |
That was just a random failure, looks good to me. |
Looks great, thanks @Enfop! |
Hi
when i tried to save invalid json for the agent_options my changes got lost. I realized that i could validate my json by using the editor toggle.
The PR adds the same behaviour for the form submit if the agent_options texarea is present.