<% if @query.errors.any? %>
<%= @query.errors.full_messages.first %>
<% end %> <%= form_for @query, url: (@query.persisted? ? query_path(@query, variable_params) : queries_path(variable_params)), html: {class: "the_form", autocomplete: "off"} do |f| %>
<%= f.hidden_field :statement %>
<%= @query.statement %>
<%= link_to "Back", :back %>
<%= f.select :data_source, Blazer.data_sources.values.map { |ds| [ds.name, ds.id] }, {}, class: ("hide" if Blazer.data_sources.size == 1), style: "width: 140px;" %>
<%= render partial: "tables" %>
<%= link_to "Run", "#", class: "btn btn-info", id: "run", style: "vertical-align: top; width: 70px;" %> <%= link_to "Cancel", "#", class: "btn btn-danger hide", id: "cancel", style: "vertical-align: top; width: 70px;" %>
<%= f.label :name %> <%= f.text_field :name, class: "form-control" %>
<%= f.label :description %> <%= f.text_area :description, placeholder: "Optional", style: "height: 80px;", class: "form-control" %>
<% if @query.persisted? %> <%= link_to "Delete", query_path(@query), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %> <%= f.submit "Fork", class: "btn btn-info" %> <% end %> <%= f.submit @query.persisted? ? "Update" : "Create", class: "btn btn-success" %>
<% if @query.persisted? %> <% dashboards_count = @query.dashboards.count %> <% checks_count = @query.checks.count %> <% words = [] %> <% words << pluralize(dashboards_count, "dashboard") if dashboards_count > 0 %> <% words << pluralize(checks_count, "check") if checks_count > 0 %> <% if words.any? %>
Part of <%= words.to_sentence %>. Be careful when editing.
<% end %> <% end %>
<% end %>