BathHacked/energy-sparks

View on GitHub
app/views/schools/interventions/_form.html.erb

Summary

Maintainability
Test Coverage
<fieldset class="form-group">
  <label><%= t('interventions.form.what_did_you_do') %></label>
  <p><%= intervention_type.name %></p>
  <% if !observation.persisted? %>
    <p class="small text-muted">
      <% if observation.intervention_type.exceeded_maximum_in_year?(@school) %>
        <%= t('interventions.form.exceeded_maximum_in_year', maximum: observation.intervention_type.maximum_frequency) %>
      <% else %>
        <%= t('interventions.form.completing_this_activity',
              maximum: observation.intervention_type.maximum_frequency,
              count: observation.intervention_type.score) %>
      <% end %>
    </p>
    <p class="small text-muted">
      <%= t('interventions.form.previous_years') %>
    </p>
  <% end %>
</fieldset>
<fieldset class="form-group mt-4">
  <%= f.label t('interventions.form.when_did_you_complete_this_action'), for: :at %>
  <small class="form-text text-muted"><%= t('interventions.form.you_can_record_label') %>.</small>
  <%= f.input :at, as: :tempus_dominus_date, label: false, input_html: { class: "form-control form-control-lg" } %>
</fieldset>

<fieldset class="form-group mt-4">
  <%= f.label t('interventions.form.tell_us_more'), for: :description %>
  <small class="form-text text-muted"><%= t('interventions.form.adding_some_background_detail_label') %></small>
  <small class="form-text text-muted"><%= t('interventions.form.you_can_add_formatting_label') %>.</small>

  <% if SiteSettings.current&.photo_bonus_points&.nonzero? %>
    <small class="form-text text-muted">
      <%= t('interventions.form.adding_a_photo_to_document_your_action_will_score_you') %>
      <span class="badge badge-success"><%= SiteSettings.current.photo_bonus_points %></span>
      <%= t('interventions.form.bonus_points', count: SiteSettings.current.photo_bonus_points) %>
    </small>
  <% end %>

  <div class="mt-4">
    <%= f.rich_text_area :description, wrapper_html: {class: ''}%>
  </div>
</fieldset>

<fieldset class="form-group mt-4">
  <%= f.input :pupil_count, as: :numeric, label: t('activities.form.how_many_pupils_were_involved_in_this_activity') %>
</fieldset>

<fieldset>
  <%= f.hidden_field :intervention_type_id, value: intervention_type.id, required: true %>
</fieldset>
<%= f.submit observation.persisted? ? t('interventions.form.update_action') : t('interventions.form.record_action'), class: 'btn btn-success' %>