osunyorg/admin

View on GitHub
app/views/server/universities/_form.html.erb

Summary

Maintainability
Test Coverage
<%= simple_form_for [:server, university] do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="row">
    <div class="col-md-4">
      <%= f.input :name %>
      <%= f.input :identifier %>
      <%= f.input :is_really_a_university %>
      <%= f.input :private %>
      <%= f.input :sms_sender_name,
                  maxlength: 11 %>
    </div>
    <div class="col-md-4">
      <%= f.input :address %>
      <div class="row">
        <div class="col-md-4">
          <%= f.input :zipcode %>
        </div>
        <div class="col-md-8">
          <%= f.input :city %>
        </div>
      </div>
      <%= f.input :country, input_html: { class: 'form-select' } %>
    </div>
    <div class="col-md-4">
      <%= f.input :logo,
                  as: :single_deletable_file,
                  input_html: { accept: default_images_formats_accepted },
                  preview: false %>
    </div>
  </div>

  <h3 class="mt-5"><%= Language.model_name.human(count: 2) %></h3>
  <div class="row">
    <div class="col-lg-6">
      <%= f.association :languages,
                        as: :check_boxes,
                        required: true,
                        wrapper_html: { class: "js-languages" },
                        label_method: lambda { |l| language_name(l.iso_code) },
                        hint: t(
                          'simple_form.hints.university.languages',
                          used_languages: Language.where(id: university.websites.map(&:language_ids).flatten.uniq).ordered.map(&:name).join(', ')
                        ) %>
    </div>
    <div class="col-lg-6">
      <%= f.association :default_language,
                        include_blank: t('simple_form.include_blanks.defaults.language'),
                        label_method: lambda { |l| language_name(l.iso_code) },
                        input_html: { class: "js-default-language" },
                        required: true %>
    </div>
  </div>


  <h3 class="mt-5"><%= t('university.sso') %></h3>
  <div class="row">
    <div class="col-md-6">
      <%= f.input :has_sso, input_html: { data: { 'conditional': true }, id: 'has_sso' } %>
      <div class="d-none"
           data-conditional-source="has_sso"
           data-conditional-value="true"
           >
        <%= f.input :sso_target_url, required: true %>
        <%= f.input :sso_cert, required: true %>
        <%= f.input :sso_name_identifier_format, required: true %>
        <%= f.input :sso_button_label %>
      </div>
    </div>
    <div class="col-md-6">
      <div class="d-none"
           data-conditional-source="has_sso"
           data-conditional-value="true"
           >
        <h4 class="mb-4"><%= University.human_attribute_name('sso_mapping') %></h4>
        <%= f.error_notification message: f.object.errors[:sso_mapping].to_sentence if f.object.errors[:sso_mapping].present? %>
        <%= render 'sso_mapping', object: university %>
      </div>
    </div>
  </div>

  <h3 class="mt-5"><%= t('server_admin.universities.invoice_informations') %></h3>
  <div class="row">
    <div class="col-md-4">
      <%= f.input :invoice_date, html5: true %>
    </div>
    <div class="col-md-4">
      <%= f.input :contribution_amount %>
    </div>
  </div>
  <% content_for :action_bar_right do %>
    <%= submit f %>
  <% end %>
<% end %>