<% if @bind_vars.any? %> <% var_params = request.query_parameters %>
<% date_vars = ["start_time", "end_time"] %> <% if (date_vars - @bind_vars).empty? %> <% @bind_vars = @bind_vars - date_vars %> <% else %> <% date_vars = nil %> <% end %> <% @bind_vars.each_with_index do |var, i| %>
<%= label_tag var, var %> <% if (data = @smart_vars[var]) %> <%= select_tag var, options_for_select([[nil, nil]] + data, selected: var_params[var]), data: { controller: "selectize" }, style: "margin-right: 20px; width: 200px; display: none;" %> <% elsif var.end_with?("_at") || var == "start_time" || var == "end_time" %>
<%= hidden_field_tag var, var_params[var], data: { datepicker_target: "input" } %> Select a date
<% else %> <%= text_field_tag var, var_params[var], autofocus: i == 0 && !var.end_with?("_at") && !var_params[var], class: "form-control" %> <% end %>
<% end %> <% if date_vars %> <% date_vars.each do |var| %> <%= hidden_field_tag var, var_params[var] %> <% end %> <%= label_tag nil, date_vars.join(" & ") %>
Select a time range
<% end %>
<% end %>