BathHacked/energy-sparks

View on GitHub
app/views/shared/meter_attributes/_hash.html.erb

Summary

Maintainability
Test Coverage
<fieldset class='form-group'>
  <%= form.label field_name, label: label.to_s.humanize, required: field.required?, class: 'col-form-label-lg', hint: field.hint unless label.blank? %>
  <%= form.hint field.hint %>

  <% if field_name != 'root' && can_ignore_children?(field) %>
    <%= check_box_tag "disable", false, false, { title: "Disable section" , class: 'disable-attributes' } %>
    <%= label_tag 'disabled-label', '(disabled)', class: 'hidden disabled-label' %>
  <% end %>

  <div class="<%= 'ml-5' unless field_name == 'root' %>">
    <% field.structure.each do |key, structure| %>
      <%= render "shared/meter_attributes/#{structure.type.to_s}", value: value ? value[key.to_s] : nil, field: structure, field_name: field_name + "[#{key}]", form: form, label: key %>
    <% end %>
  </div>

</fieldset>