BathHacked/energy-sparks

View on GitHub
app/views/admin/comparisons/reports/_form.html.erb

Summary

Maintainability
Test Coverage
<%= render partial: 'display_custom_period' %>

<div class="row">
  <div class="col">
    <% url = report.new_record? ? admin_comparisons_reports_path : admin_comparisons_report_path(report) %>
    <%= simple_form_for(report, as: :report, url: url) do |f| %>
      <%= render 'admin/shared/locale_tabs', f: f, field: :title do |locale| %>
        <%= f.input t_field(:title, locale), as: :string %>
      <% end %>
      <%= f.association :report_group, label_method: :title, value_method: :id, include_blank: false %>
      <%= f.input :reporting_period,
                  collection: Comparison::Report.reporting_periods.keys,
                  label_method: :humanize %>
      <div class="custom_period">
        <div>
          <%= f.simple_fields_for :custom_period do |custom_period| %>
            <%= render 'custom_period_fields', f: custom_period %>
          <% end %>
        </div>
      </div>
      <%= render 'admin/shared/locale_tabs', f: f, field: :introduction do |locale| %>
        <%= f.label "Introduction #{locale}" %>
        <%= f.rich_text_area t_field(:introduction, locale), label: 'Introduction', as: :string %>
      <% end %>
      <%= render 'admin/shared/locale_tabs', f: f, field: :notes do |locale| %>
        <%= f.label "Notes #{locale}" %>
        <%= f.rich_text_area t_field(:notes, locale), as: :string %>
      <% end %>
      <%= f.input :public %>
      <%= f.input :disabled %>
      <%= f.submit 'Save', class: 'btn btn-primary' %>
    <% end %>
  </div>
</div>