osunyorg/admin

View on GitHub
app/views/extranet/experiences/_form.html.erb

Summary

Maintainability
Test Coverage
<%= simple_form_for experience, url: experience.persisted? ? experience_path(experience) : experiences_path do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>
  <%= f.simple_fields_for :localizations, l10n do |lf| %>
    <%= lf.hidden_field :language_id, value: current_language.id %>

    <div class="row">
      <div class="col-lg-6">
        <%= f.input :organization_name,
                    label: University::Organization.model_name.human,
                    as: :autocomplete,
                    required: true,
                    url: search_organizations_path,
                    placeholder: t("extranet.experiences.search_organization"),
                    input_html: {
                      value: (experience.organization_id ? experience.organization.to_s_in(current_language) : ''),
                      data: {
                        "showNoMatches": "false",
                        "autocomplete-target": "#university_person_experience_organization_id",
                        "autocomplete-no-result-target": "#university_person_experience_organization_not_found"
                      },
                      autocomplete: 'off',
                      role: 'presentation'
                    } %>
        <%= f.hidden_field :organization_id %>
        <div class="<%= 'd-none' unless experience.organization_id.nil? && experience.organization_name.present? %>" id="university_person_experience_organization_not_found" data-default-text="<%= t('extranet.account.experiences.create_new_html', name: 'CHANGEME', url: new_organization_path(name: 'CHANGEME')) %>">
          <% if experience.organization_id.nil? && experience.organization_name.present? %>
          <%= t('extranet.account.experiences.create_new_html', name: experience.organization_name, url: new_organization_path(name: experience.organization_name)) %>
          <% end %>
        </div>
      </div>
      <div class="col-lg-6">
        <div class="row">
          <div class="col-6">
            <%= f.input :from_year %>
          </div>
          <div class="col-6">
            <%= f.input :to_year %>
          </div>
        </div>
        <%= lf.input :description, as: :string %>
      </div>
    </div>
    <%= submit f %>
  <% end %>
<% end %>