

  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-header" style="padding-top: 0.6rem; padding-bottom: 0.3rem;">
        <h4 id="agents_header">Execute test case with custom data</h4>
        <button type="button" class="close closefirstmodal"  aria-label="<%= I18n.t(:close) %>">
          <span aria-hidden="true">&times;</span></button>
      </div>
      <div class="modal-body" id="custom_test_execution_content">
        <form id="prepare_custom_test_execution_form" data-remote="true" method="post" action="/test_files/execute_test_custom/<%= @test_case.id %>.js">              
          
          <div class="form-group form-group-sm row">
            <div class="col-sm-12">
              <%= t(:test_case)%>: <b><%= @test_case.name %></b>
            </div>
          </div>
          <div class="" style="margin-right: 1px;" id="env_var_editor">

            <% if @spec_behaviour && @spec_behaviour.wildcards.any? %>

              <% @spec_behaviour.wildcards.each_with_index do |wc, idx| %>
                <% wildcard_data_options = @spec_behaviour.wildcard_option(wc)%>
                 <div class="form-group form-group-sm row" id="env_row_<%= idx %>">
                   <div class="col-sm-5">
                     <input type="text" name="env_var_key[<%= idx %>]" value="<%= wc %>" style="" class="form-control">
                   </div>
                   <div class="col-sm-1" style="text-align: center; margin-left: -1rem; margin-right: -1rem; margin-top: 8px;">
                    =
                   </div>
                   <div class="col-sm-6">
					   
                    <% if wildcard_data_options && wc != "SERVER" && wildcard_data_options.class == Hash && wildcard_data_options.size() > 1%>
                      <select name="env_var_value[<%= idx %>][]" class="select2" multiple="true">			
                        <% wildcard_data_options.each_with_index do |entry, idx| %>
                            <option value="<%= entry[1] %>" <% if idx == 0 %>selected<% end %>><%= entry[0] %></option>
                        <% end %>
                      </select>
					  
                  <% elsif wildcard_data_options && wildcard_data_options.class == Array  %>				  
                      <select name="env_var_value[<%= idx %>][]" class="select2">			
                        <% wildcard_data_options.each_with_index do |entry, idx| %>
                          <% if wc == "SERVER" && !session[:custom_execution_server].blank? %>
                            <option value="<%= entry %>" <% if entry == session[:custom_execution_server] %>selected<% end %>><%= entry %></option>
                          <% else %>
                            <option value="<%= entry %>" <% if idx == 0 %>selected<% end %>><%= entry %></option>
                          <% end %>
                        <% end %>
				     </select>

				  <% elsif wildcard_data_options && wildcard_data_options.class == String %> 
                      <input type="text" name="env_var_value[<%= idx %>]" value="<%= wildcard_data_options.to_s %>" style="" class="form-control"
                        <% if wc && wc.downcase =~ /_date$/ %>placeholder="e.g 1973-03-08"<%end%>  />
                  <% else %>
				  
                  	  <input type="hidden" name="env_var_key[<%= idx %>]" value="<%= wc %>" />
					  <input type="hidden" name="env_var_value[<%= idx %>]" value="<%= wildcard_data_options.to_s %>"/>			  
                   <% end %>
                  </div>

                </div>         
              <% end %>
              
              <% end %>
              
          </div>

          <div style="text-align:right; padding-right: 1.8rem;">
	          <span id="execution-timing" style="display:none; margin-right: 1rem;"></span>
	          <input type="submit" class="btn btn-sm btn-primary"  value="Execute" style="margin-right: 0.5rem;"/>
	          <img id="execution-in-progress" style="display:none;" src="/images/loading.gif"/>
          </div>
        </form>
                
        <div id="test-execution-output" style="display:none;">
          
          <pre id="test-stdout" style="padding: 10px;"></pre>
          <div id="test-request-data"></div>
          <div id="test-response-data"></div>

        </div>
        
      </div>
    </div>
  </div>

<script type="text/javascript">

  $(function() {

    $("button.closefirstmodal").click(function() {
       $("#Warning").modal("show");
    });

    $(".confirmclosed").click(function () { 
      $("#Warning").modal("hide");
      $("#custom_test_execution_modal").modal("hide"); 
    });

  });
</script>
