"Add a new user" link uses setup method to create a "loaded" user.
[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 <% puts "\n\n **************** setup_user_url = #{setup_user_url.inspect}" %>
13     <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get', class: 'form-search', remote: true} do %>
14       <input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
15       <div>
16         <table><tbody>
17           <tr>
18             <% if disable_email %>
19               <td> Email </td>
20               <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>" disabled=true > </td>
21             <% else %>
22               <td> Email </td>
23               <td> <input id="email" maxlength="250" name="email" type="text" > </td>
24             <% end %>
25           </tr>
26           <tr>
27             <% if disable_url_prefix %>
28               <td> Identity URL Prefix &nbsp </td>
29               <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="<%=identity_url_prefix%>" disabled=true > </td>
30             <% else %>
31               <td> Openid Prefix </td>
32               <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text" value="https://www.google.com/accounts/o8/id"> </td>
33             <% end %>
34           </tr>
35           <tr>
36             <td> Repository Name </td>
37             <td> <input id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
38           </tr>
39           <tr>
40             <td> Virtual Machine </td>
41             <td>
42               <select name="vm_uuid">
43                 <% if selected_vm %>
44                   <option value=""> Choose One: </option>
45                 <% else %>
46                   <option value="" selected> Choose One: </option>
47                 <% end %>
48                 <% @vms.each do |vm| %>
49                   <% if selected_vm == vm.uuid %>
50                     <option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
51                   <% else %> 
52                     <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
53                   <% end %>
54                 <% end %>
55               </select>
56             </td>
57           </tr>
58         </tbody></table>
59       </div>
60       <div align="center">
61         <br/>
62         <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
63         <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Cancel</button>
64       </div>
65     <% end %>
66   </div>
67
68 <script>
69   var $input = $('input:text'),
70   $register = $('#register');    
71   $register.attr('disabled', true);
72
73   $input.keyup(function() {
74     var trigger = false;
75     $input.each(function() {
76         if (!$(this).val()) {
77             trigger = true;
78         }
79     });
80     trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
81   });
82 </script>