noesya/osuny

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

Summary

Maintainability
Test Coverage
<%= simple_form_for [:admin, diploma] 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">
        <%= lf.input :name %>
        <div class="row">
          <div class="col-lg-6">
            <%= lf.input :short_name %>
          </div>
          <div class="col-lg-6">
            <%= f.input :level, include_blank: false %>
          </div>
          <div class="col-lg-6">
            <%= f.input :ects %>
          </div>
          <div class="col-lg-6">
            <%= lf.input :duration, as: :string %>
          </div>
        </div>
        <%= render 'admin/application/summary/form', f: lf, about: l10n %>
      </div>
      <div class="col-lg-4">
        <%= render  "admin/application/slug/form",
                    f: lf,
                    source: '#education_diploma_localizations_attributes_0_name' %>
      </div>
    </div>

    <%= osuny_separator %>

    <%= osuny_label t('admin.education.diplomas.fields_for_programs') %>
    <div class="row">
      <%
      [
        :pedagogy,
        :evaluation,
        :prerequisites,
        :registration,
        :other,
        :pricing,
        :pricing_initial,
        :pricing_continuing,
        :pricing_apprenticeship,
        :accessibility,
        :contacts
      ].each do |property| %>
        <div class="col-xxl-4 col-md-6 mb-4">
          <%= lf.input  property,
                        as: :summernote,
                        input_html: {
                          data: { 'summernote-config' => 'mini' }
                        } %>
        </div>
      <% end %>
    </div>

    <%= f.input :certification,
                as: :radio_buttons,
                collection: Education::Diploma.certifications << '',
                item_wrapper_class: 'd-inline-block mb-5 me-5',
                label_method: Proc.new { |certification|
                  if certification.empty?
                    content_tag :span, t('admin.education.diplomas.certification.none'), class: "ms-2"
                  else
                    image_tag "education/diplomas/certifications/#{certification}.svg",
                              alt: certification,
                              width: 150
                  end
                } %>
    <% content_for :action_bar_right do %>
      <%= submit f %>
    <% end %>
  <% end %>
<% end %>