noesya/osuny

View on GitHub
app/views/admin/education/programs/_form.html.erb

Summary

Maintainability
Test Coverage
<%= simple_form_for [:admin, program] do |f| %>
  <%= f.simple_fields_for :localizations, l10n do |lf| %>
    <%= f.error_notification %>
    <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
    <%= lf.hidden_field :language_id, value: current_language.id %>

    <div class="row">
      <div class="col-lg-8 col-xxl-9">
        <div class="row">
          <div class="col-lg-9">
            <%= lf.input :name %>
          </div>
          <div class="col-lg-3">
            <%= lf.input :short_name %>
          </div>
        </div>
        <%= render 'admin/application/summary/form', f: lf, about: l10n %>
        <%= render 'admin/application/categories/form', f: f, categories: @categories %>
        <div class="row">
          <div class="col-lg-4">
            <%= f.association :diploma,
                              collection: osuny_collection(current_university.diplomas, localized: true) %>
            <%= f.association :schools,
                              as: :check_boxes,
                              collection: osuny_collection(current_university.education_schools, localized: true) %>
          </div>
          <div class="col-lg-8">
            <%= lf.input :url %>
            <%= lf.input :duration %>
            <%= lf.input :downloadable_summary,
                        as: :single_deletable_file,
                        direct_upload: true %>
          </div>
        </div>
        <%= osuny_separator %>
        <div class="row">
          <div class="col-lg-4">
            <%= render 'admin/application/shared_image/edit', f: lf, about: l10n %>
          </div>
          <div class="col-lg-8">
            <%= render 'admin/application/meta_description/form', f: lf, about: l10n %>
          </div>
        </div>
        <%= osuny_separator %>
        <div class="row">
          <div class="col-lg-4">
            <%= osuny_label t('education.program.registration_scheme') %>
            <div class="mb-n3"><%= f.input :initial %></div>
            <div class="mb-n3"><%= f.input :continuing %></div>
            <div><%= f.input :apprenticeship %></div>
            <%= f.input :capacity %>
          </div>
          <div class="col-lg-8">
            <%= lf.input  :presentation,
                          as: :summernote,
                          input_html: {
                            data: { 'summernote-config' => 'mini' }
                          } %>
            <%= render 'admin/education/programs/forms/input_with_inheritance', f: lf, property: :objectives %>
          </div>
        </div>
      </div>
      <div class="col-lg-4 col-xxl-3">
        <%= lf.input :published %>
        <%= render  "admin/application/slug/form",
                    f: lf,
                    source: '#education_program_localizations_attributes_0_name' %>
        <%= f.association :parent,
                          collection: osuny_collection_tree(
                            current_university.education_programs.root,
                            localized: true,
                            except: program
                          ) %>
        <%= f.input :bodyclass %>
        <%= lf.input :logo,
                    as: :single_deletable_file,
                    hint: images_formats_accepted_hint,
                    input_html: { accept: default_images_formats_accepted }
                    %>
        <%= render 'admin/application/featured_image/edit', f: lf, about: l10n %>
      </div>
    </div>

    <% content_for :action_bar_right do %>
      <%= submit f %>
    <% end %>
  <% end %>
<% end %>