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