]> git.openstreetmap.org Git - rails.git/commitdiff
Refactor user registration form to use bootstrap
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 20 Jan 2021 12:02:41 +0000 (12:02 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 20 Jan 2021 15:38:10 +0000 (15:38 +0000)
app/views/users/new.html.erb
test/controllers/users_controller_test.rb
test/integration/user_creation_test.rb

index 6f97a284a583559d94c977fb2ab0de4f332c4ae6..f8d3a7e8ec5ea29fd2d5a99d4178c1fe5065505c 100644 (file)
   </div>
 
   <div class="col-sm">
-    <%= form_for current_user, :url => { :action => "create" }, :html => { :class => "standard-form" } do |f| %>
+    <%= bootstrap_form_for current_user, :url => { :action => "create" } do |f| %>
       <%= hidden_field_tag("referer", h(@referer)) unless @referer.nil? %>
 
-      <fieldset>
-        <div class="standard-form-row">
-          <label for="email" class="standard-label">
-            <%= t ".email address" %>
-          </label>
-          <%= f.email_field(:email, :tabindex => 1) %>
-          <%= f.error_message_on(:email) %>
-        </div>
-        <div class="standard-form-row">
-          <label for="email_confirmation" class="standard-label">
-            <%= t ".confirm email address" %>
-          </label>
-          <%= f.email_field(:email_confirmation, :tabindex => 2) %>
-          <%= f.error_message_on(:email_confirmation) %>
-        </div>
-        <span class="form-help deemphasize"><%= t(".not_displayed_publicly_html") %></span>
-      </fieldset>
+      <%= f.email_field :email, :label => t(".email address"), :tabindex => 1 %>
+      <%= f.email_field :email_confirmation, :label => t(".confirm email address"), :help => t(".not_displayed_publicly_html"), :tabindex => 2 %>
 
-      <fieldset>
-        <div class="standard-form-row">
-          <label for="display_name" class="standard-label">
-            <%= t ".display name" %>
-          </label>
-          <%= f.text_field(:display_name, :tabindex => 3) %>
-          <%= f.error_message_on(:display_name) %>
-        </div>
-        <span class="form-help deemphasize"><%= t ".display name description" %></span>
-      </fieldset>
+      <%= f.text_field :display_name, :label => t(".display name"), :help => t(".display name description"), :tabindex => 3 %>
 
-      <fieldset class="form-divider" id="auth_field">
-        <div class="standard-form-row">
-          <label for="openid_url" class="standard-label">
-            <%= t ".external auth" %>
-          </label>
-          <%= f.select(:auth_provider, Auth.providers, :default => "", :tabindex => 4) %>
-          <%= f.text_field(:auth_uid, :tabindex => 5) %>
-          <%= f.error_message_on(:auth_uid) %>
+      <fieldset class="form-group" id="auth_field">
+        <label for="user_auth_provider"><%= t(".external auth") %></label>
+        <div class="form-row">
+          <%= f.select(:auth_provider, Auth.providers, :default => "", :hide_label => "true", :wrapper => { :class => "col-auto mb-0" }, :tabindex => 4) %>
+          <%= f.text_field(:auth_uid, :hide_label => true, :wrapper => { :class => "col mb-0" }, :tabindex => 5) %>
         </div>
-        <span class="form-help deemphasize"><%= t ".auth no password" %></span>
+        <small class="form-text text-muted"><%= t ".auth no password" %></small>
       </fieldset>
 
-      <fieldset>
-        <div class="standard-form-row">
-          <label for='user[pass_crypt]' class="standard-label">
-            <%= t ".password" %>
-          </label>
-          <%= f.password_field(:pass_crypt, :tabindex => 6) %>
-          <%= f.error_message_on(:pass_crypt) %>
-        </div>
-        <div class="standard-form-row">
-          <label class="standard-label">
-            <%= t ".confirm password" %>
-          </label>
-          <%= f.password_field(:pass_crypt_confirmation, :tabindex => 7) %>
-          <%= f.error_message_on(:pass_crypt_confirmation) %>
-        </div>
-      </fieldset>
+      <%= f.password_field :pass_crypt, :tabindex => 6 %>
+      <%= f.password_field :pass_crypt_confirmation, :tabindex => 7 %>
 
-      <div id="auth_prompt" class="standard-form-row">
-        <%= link_to t(".use external auth"), "#", :id => "auth_enable" %>
+      <div id="auth_prompt">
+        <p><%= link_to t(".use external auth"), "#", :id => "auth_enable" %></p>
       </div>
 
-      <%= submit_tag t(".continue"), :tabindex => 8 %>
+      <%= f.primary t(".continue"), :tabindex => 8 %>
     <% end %>
   </div>
 </div>
index 12a804bc56cef94f074f482601cc2679d67bc739..c21f820469b42844242ce4cebf76dc8b7ea218a8 100644 (file)
@@ -233,7 +233,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_template "new"
-    assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email"
+    assert_select "form > div.form-group > input.is-invalid#user_email"
   end
 
   def test_save_duplicate_email
@@ -262,7 +262,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_template "new"
-    assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email"
+    assert_select "form > div.form-group > input.is-invalid#user_email"
   end
 
   def test_save_duplicate_email_uppercase
@@ -291,7 +291,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_template "new"
-    assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email"
+    assert_select "form > div.form-group > input.is-invalid#user_email"
   end
 
   def test_save_duplicate_name
@@ -320,7 +320,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_template "new"
-    assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name"
+    assert_select "form > div.form-group > input.is-invalid#user_display_name"
   end
 
   def test_save_duplicate_name_uppercase
@@ -349,7 +349,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_template "new"
-    assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name"
+    assert_select "form > div.form-group > input.is-invalid#user_display_name"
   end
 
   def test_save_blocked_domain
index 8b6b3ef3cd2fb19fda066c19ddeb89e5abcc1862..f331a4b98130fb2de48eec46d2b4c81ad8f9e552 100644 (file)
@@ -51,7 +51,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest
       assert_response :success
       assert_template "users/new"
       assert_equal locale.to_s, response.headers["Content-Language"]
-      assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email"
+      assert_select "form"
+      assert_select "form > div.form-group > input.is-invalid#user_email"
       assert_no_missing_translations
     end
   end
@@ -75,7 +76,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
       end
       assert_response :success
       assert_template "users/new"
-      assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name"
+      assert_select "form > div.form-group > input.is-invalid#user_display_name"
       assert_no_missing_translations
     end
   end