1 <%= form_tag setup_user_path, {id: 'setup_form', name: 'setup_form', method: 'get',
2 class: 'form-search', remote: true} do %>
4 <div class="modal-header">
5 <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
6 <h3 class="modal-title">Setup User</h4>
9 <div class="modal-body">
11 <% uuid = @object.uuid %>
12 <% email = @object.email %>
14 <% disable_email = uuid != nil %>
15 <% identity_url_prefix = @current_selections[:identity_url_prefix] %>
16 <% disable_url_prefix = identity_url_prefix != nil %>
17 <% selected_repo = @current_selections[:repo_name] %>
18 <% selected_vm = @current_selections[:vm_uuid] %>
20 <input id="user_uuid" maxlength="250" name="user_uuid" type="hidden" value="<%=uuid%>">
22 <table><tbody><div class="form-group">
24 <% if disable_email %>
26 <td> <input id="email" maxlength="250" name="email" type="text" value="<%=email%>"
30 <td> <input id="email" maxlength="250" name="email" type="text" > </td>
34 <% if disable_url_prefix %>
35 <td> Identity URL Prefix   </td>
36 <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
37 value="<%=identity_url_prefix%>" disabled=true > </td>
39 <td> Openid Prefix </td>
40 <td> <input id="openid_prefix" maxlength="250" name="openid_prefix" type="text"
41 value="<%= Rails.configuration.default_openid_prefix %>"> </td>
45 <td> Repository Name </td>
46 <td> <input id="repo_name" maxlength="250" name="repo_name" type="text" value="<%=selected_repo%>">
49 <td> Virtual Machine </td>
51 <select name="vm_uuid">
53 <option value=""> Choose One: </option>
55 <option value="" selected> Choose One: </option>
57 <% @vms.each do |vm| %>
58 <% if selected_vm == vm.uuid %>
59 <option value=<%=vm.uuid%> selected> <%=vm.hostname%> </option>
61 <option value=<%=vm.uuid%> > <%=vm.hostname%> </option>
67 </div></tbody></table>
71 <div class="modal-footer">
72 <button type="submit" id="register" class="btn btn-primary" autofocus>Submit</button>
73 <button class="btn btn-default" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">Cancel</button>
79 var $input = $('input:text'),
80 $register = $('#register');
82 var email_disabled = document.forms["setup_form"]["email"].disabled;
83 var email_value = document.forms["setup_form"]["email"].value;
84 var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
85 if ((email_disabled == false) && (email_value == null || email_value == "" ||
86 prefix_value == null || prefix_value == "")) {
87 $register.attr('disabled', true);
90 $input.keyup(function() {
93 var email_disabled = document.forms["setup_form"]["email"].disabled;
94 var email_value = document.forms["setup_form"]["email"].value;
95 var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
97 var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
98 var validEmail = false;
99 if (emailRegExp.test(email_value )) {
103 if ((email_disabled == false) && (!validEmail || email_value == null ||
104 email_value == "" || prefix_value == null || prefix_value == "")){
108 trigger ? $register.attr('disabled', true) : $register.removeAttr('disabled');
111 function reset_form() {
113 $('#openid_prefix').val("");
114 $('#repo_name').val("");