Disable submit button until all input fields are filled in.
authorradhika chippada <radhika@radhika.curoverse>
Wed, 2 Apr 2014 04:04:16 +0000 (00:04 -0400)
committerradhika chippada <radhika@curoverse.com>
Tue, 8 Apr 2014 17:06:47 +0000 (13:06 -0400)
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/users/_setup_popup.html.erb

index 3a5c2b3ec8751d6830bb9303e15a49b3eac264f4..3696eccedf6385e1c3d8f9a61033eca6d468bd13 100644 (file)
@@ -201,8 +201,8 @@ class UsersController < ApplicationController
                                    name: 'can_login')
 
     if oid_login_perms.any?
-      identiry_url_prefix = oid_login_perms.first.identity_url_prefix
-      current_selections[:identiry_url_prefix] = identiry_url_prefix
+      prefix_properties = oid_login_perms.first.properties
+      current_selections[:identity_url_prefix] = prefix_properties[:identity_url_prefix]
     end
 
     # repo perm
index f27b4749d16d8b3fec233936df94075716870b36..8d44e90e5eba66a46abba2dc83316fe1a51406cc 100644 (file)
@@ -1,15 +1,11 @@
-  <div class="modal-header">
-    <h3 id="myModalLabel">Information you had already provided is prefilled for you. You may change it as needed.</h3>
-  </div>
-
   <div class="modal-body">
     <% uuid = @object.uuid %>
-    <% disable_email = @object.uuid? %>
-    <% identity_url_prefix = @current_selections[:identiry_url_prefix] %>
+    <% disable_email =  @object.uuid? %>
+    <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
     <% selected_repo = @current_selections[:repo_name] %>
     <% selected_vm = @current_selections[:vm_uuid] %>
-
-    <%= form_tag setup_user_url(id: uuid), method: 'get', remote: true, class: 'form-search' do %>    
+    
+    <%= form_tag setup_user_url(id: uuid), {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true, onSubmit: "validate(); return false;"} do %>    
       <div>
         <table><tbody>
           <tr>
@@ -27,7 +23,7 @@
               <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=<%=disable_email%> > </td>
             <% else %>
               <td> Openid Prefix </td>
-              <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"> </td>
+              <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
             <% end %>
           </tr>
           <tr>
         </tbody></table>
       </div>
       <div align="left">
-        <button type="submit" class="btn btn-primary" autofocus>Submit</button>
+        <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
         <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
       </div>
     <% end %>
   </div>
+
+<script>
+  var $input = $('input:text'),
+  $register = $('#register');    
+  $register.attr('disabled', true);
+
+  $input.keyup(function() {
+    var trigger = false;
+    $input.each(function() {
+        if (!$(this).val()) {
+            trigger = true;
+        }
+    });
+    trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
+  });
+</script>