BathHacked/energy-sparks

View on GitHub
app/views/admin/help_pages/_form.html.erb

Summary

Maintainability
Test Coverage
<%= form_with model: [:admin, help_page], local: true do |f| %>
  <%= render 'shared/errors', subject: help_page, subject_name: 'Help page' %>

  <%= render 'admin/shared/locale_tabs', f: f, field: :name do |locale| %>
    <div class="form-group">
      <%= f.label t_field(:title, locale), "Title", class: "form-label" %>
      <%= f.text_field t_field(:title, locale), class: 'form-control' %>
    </div>
  <% end %>

  <div class="form-group">
    <%= f.label :feature, "Feature", class: "form-label" %>
    <%= f.select :feature, HelpPage.features.keys.to_a, {}, class: 'form-control' %>
    <p class="small">
      Specify which feature this help page is describing
    </p>
  </div>

  <%= render 'admin/shared/locale_tabs', f: f, field: :description do |locale| %>
    <div class="description-trix-editor-<%=locale%> form-group">
      <%= f.label t_field(:description, locale), "Description", class: "form-label" %>
      <%= f.rich_text_area t_field(:description, locale), class: '' %>
    </div>
  <% end %>


  <div class="form-group">
    <div class="form-check form-check-inline">
      <%= f.check_box :published, class: 'form-check-input' %>
      <%= f.label :published, class: 'form-check-label' %>
    </div>
  </div>

  <%= f.submit help_page.persisted? ? "Update" : "Create", class: "btn btn-primary" %>
  <%= link_to "View all help pages", admin_help_pages_path, class: "btn btn-primary" %>
<% end %>