Skip to content
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

Corrected Signup form validation #5116

Closed
wants to merge 3 commits into from

Conversation

ananyaarun
Copy link
Member

@ananyaarun ananyaarun commented Mar 16, 2019

Fixes #3340

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

signup1

Thanks!

@ananyaarun
Copy link
Member Author

@gauravano , Form doesn't accept null values anymore during signup. Also i have made only username , email. password and repeat password compulsory. Since image and Bio is up to user if they want to add or not.

@plotsbot
Copy link
Collaborator

plotsbot commented Mar 16, 2019

1 Message
📖 @ananyaarun Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

Copy link
Member

@grvsachdeva grvsachdeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sign-up button is not coming back so the user has to refresh their browser tab and fill the form again. the ideal behavior would be to validate all fields on pressing Sign-up button and if fields are incorrect/empty then focus on those fields or messages?

@ananyaarun
Copy link
Member Author

ananyaarun commented Mar 17, 2019

@gauravano , The thing as of now I have used the same method of form validation in Both login and signup. But signup uses a rotating wheel fontawesome icon. ie upon one click the icon appears and signup option disappears as you said. Upon removing this (like how it isnt there for login) this is how it looks.

SIGNUP

So now even if there is an error while filling there is a prompt to refill but the signup icon doesnt appear.
Thoughts ?

@grvsachdeva
Copy link
Member

grvsachdeva commented Mar 18, 2019

Can't we show that progress icon only when JavaScript validation is passed and in other cases we can just focus on the fields with error messages along with each field?

@ananyaarun
Copy link
Member Author

@gauravano , Hmm I just looked into this. So the method of using required: true is basically form validation in ruby. Whereas this button is a JS element which always executes whenever the signup button is clicked.
I'm unsure of how to integrate the ruby validation along with JS spinning button script. I tried adding if conditions but the ruby form elements arent accessible outside the form template where the script is defined.
A solution would be to implement this just like login which doesnt have a spinning button at the moment.
I'll look more into this though and get back to you if something works ?

@ananyaarun
Copy link
Member Author

@gauravano , So far i can get 2 solutions to this issue.

  • The signup from works and ensures it gets submitted only when all fields are filled. But the spinning wheel never appears.(Just like how login is implemented presently)
  • When i try to integrate the spinning wheel icon with ruby form validation, it appears on click no matter which fields are unfilled/filled.

Any thoughts on what can be done ?

@grvsachdeva
Copy link
Member

How about this - "User fills the form partially and goes on to submit the form by pressing sign-up and we can show a warning on hovering over the sign-up button only or maybe disable it too?"

@ananyaarun
Copy link
Member Author

So basically there are 4 compulsory fields a user needs to fill. The user may not fill this in any permutation or combination.
Right now what happens according to the changes i made is that whichever field isnt filled a "pls fill this " msg appears below it when the user clicks signup. So in a way it is disabled until all fields are filled by the user.

@grvsachdeva
Copy link
Member

grvsachdeva commented Mar 20, 2019

But, user need to refresh the screen with your approach right?

@ananyaarun
Copy link
Member Author

ananyaarun commented Mar 20, 2019

No not any more, I made a slight change. I'll attach a gif in 10 minutes.

@ananyaarun
Copy link
Member Author

@gauravano Here is the gif, User need not refresh after each "Pls fill this field" msg. Basically until all fields are filled this msg comes and form is submitted on one click after that.

signup2

<label for="username"><%= t('user_sessions.new.username') %></label>
<%= f.text_field :username, { tabindex: 1, placeholder: "Username", class: 'form-control', id: 'username-signup' } %>
<%= f.text_field :username, { tabindex: 1, placeholder: "Username", class: 'form-control', id: 'username-signup', required:true } %>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Let's remove this empty space

<label for="email"><%= t('users._form.email') %></label>
<%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email' } %>
<%= f.text_field :email, { tabindex: 3, placeholder: "you@email.com", class: 'form-control', id: 'email', required: true } %>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

.html("<i class='fa fa-spinner fa-spin'></i>"); // make a spinner that spins when clicked
})
})();
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this, we can disable the button only when all the required fields are filled i.e., spinner will show only when all required fields are filled otherwise focus on the fields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would be ideal. Do you have any idea how this can be done ?. Because the problem is since button is a JS element and form validation happens in ruby, i wasn't able to find a way to check if all fields are filled before displaying the button. The fields i try to access show "Cant be accessed error on console". I'll keep trying other ways to do this in the meantime maybe i was wrong, Thanks @gauravano :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form/input fields we create in rails also result in the generation of HTML form only and so can be assessed just like that, open the sign-up form of publiclab.org and try $('#username-signup').val() in your console and you'll get the value of username field.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll try this :)

Copy link
Member

@grvsachdeva grvsachdeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give a try to make changes in the script so we don't need to remove the spinner

@ananyaarun
Copy link
Member Author

@gauravano , I got an idea how to implement this keeping the spinner button, Sorry have been a little busy with assignments, exams and writing my proposal lately. Will work on this as soon as i am done with these.

@grvsachdeva
Copy link
Member

No issue! And, thanks for working on it.

@SidharthBansal
Copy link
Member

There are some conflicts in your pr. It will be great if you can rebase your pr.
Thanks for the work done here at PL

@grvsachdeva
Copy link
Member

Hi @ananyaarun, please update this PR too whenever you get time. Thanks!

@ananyaarun
Copy link
Member Author

Sure, I have resolved the conflicts.
Still trying ways to keep the spinner. As of now validation works but I have removed the font awesome spinner icon.

Copy link
Member

@SidharthBansal SidharthBansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, changes looks good to me. Thanks for your work.
@jywarren @gauravano can you please review this and merge this?

@jywarren
Copy link
Member

jywarren commented Jun 5, 2019

OK, just because this being signup, it's a very critical system, would you mind sharing a gif of the current latest functionality just to confirm, @ananyaarun ? Thank you!!!!

@ananyaarun
Copy link
Member Author

@jywarren here
Basically won't allow a user signup without entering username and password.
Also other fields are optional (ie not 'required') as of now, but not entering those gives a spam detection msg as expected.
signup1 1

@jywarren
Copy link
Member

jywarren commented Jun 6, 2019 via email

@ananyaarun
Copy link
Member Author

ananyaarun commented Jun 6, 2019

Can I test this on unstable myself ? Are there permissions required ?
@gauravano @jywarren ?
Thanks!

@ananyaarun
Copy link
Member Author

@gauravano @jywarren I dont have permission to push to unstable to test.
Can someone who has permission test and let me know if there are further changes to be made ?
Thanks !!

@sashadev-sky
Copy link
Member

@gauravano I think this one might be stale, what do you think? The issue with it is it should be reopened perhaps as a general frontend validation feature in addition to the work that needs to be done on #3340.

If we can salvage a part of it and merge then lets do that, otherwise lets close it.
@ananyaarun what are your thoughts

@SidharthBansal
Copy link
Member

SidharthBansal commented Sep 13, 2019 via email

@ananyaarun
Copy link
Member Author

Sure at @sashadev-sky !
Closing this issue would make sense. This has been open for quite some time, We don't want to confuse newcomers / GCI students with stale/ invalid issues.

Will u be opening another issue for this ?

@cesswairimu
Copy link
Collaborator

Hey @ananyaarun , seems the issue you were fixed in this PR was closed..Closing this. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sign-up Form Validation message correction
7 participants