Require only email and openid prefix in the setup popup. The other fields are optional.
[arvados.git] / apps / workbench / app / views / users / _setup_popup.html.erb
1   <div class="modal-body">
2     <% if @object%>
3       <% uuid = @object.uuid %>
4       <% email = @object.email %>
5     <% end %>
6     <% disable_email = uuid != nil %>
7     <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
8     <% disable_url_prefix = (identity_url_prefix != nil) %>
9     <% selected_repo = @current_selections[:repo_name] %>
10     <% selected_vm = @current_selections[:vm_uuid] %>
11     
12     <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true} do %>
13       <input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
14       <div>
15         <table><tbody>
16           <tr>
17             <% if disable_email %>
18               <td> Email </td>
19               <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>" disabled=true > </td>
20             <% else %>
21               <td> Email </td>
22               <td> <input id="email" maxlength="250" name="email" type="text" > </td>
23             <% end %>
24           </tr>
25           <tr>
26             <% if disable_url_prefix %>
27               <td> Identity URL Prefix &nbsp </td>
28               <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=true > </td>
29             <% else %>
30               <td> Openid Prefix </td>
31               <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
32             <% end %>
33           </tr>
34           <tr>
35             <td> Repository Name </td>
36             <td> <input id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
37           </tr>
38           <tr>
39             <td> Virtual Machine </td>
40             <td>
41               <select name="vm_uuid">
42                 <% if selected_vm %>
43                   <option value=""> Choose One: </option>
44                 <% else %>
45                   <option value="" selected> Choose One: </option>
46                 <% end %>
47                 <% @vms.each do |vm| %>
48                   <% if selected_vm == vm.uuid %>
49                     <option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
50                   <% else %> 
51                     <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
52                   <% end %>
53                 <% end %>
54               </select>
55             </td>
56           </tr>
57         </tbody></table>
58       </div>
59       <div align="center">
60         <br/>
61         <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
62         <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
63       </div>
64     <% end %>
65   </div>
66
67 <script>
68   var $input = $('input:text'),
69   $register = $('#register');    
70   $register.attr('disabled', true);
71   $input.keyup(function() {
72     var trigger = false;
73
74     var email_value = document.forms["setup_form"]["email"].value;
75     var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
76
77     if (email_value == null || email_value == "" || prefix_value == null || prefix_value == "") {
78       trigger = true;
79     }
80
81     trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
82   });
83 </script>