noesya/osuny

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

Summary

Maintainability
Test Coverage
<%
include_id ||= false
l10n = f.object.localization_for(current_language)
if l10n.nil? && f.object.persisted?
  l10n = f.object.localize_in!(current_language)
end
l10n ||= f.object.localizations.build(language_id: current_language.id)
%>
<%= f.simple_fields_for :localizations, l10n do |lf| %>
  <div class="nested-fields mb-2">
    <div class="d-flex align-items-center">
      <i class="<%= Icon::DRAG %> handle"></i>
      <%= lf.hidden_field :id %>
      <%= lf.hidden_field :language_id, value: current_language.id %>
      <%= f.association :person,
                        collection: osuny_collection(@administration_people, localized: true, label_method: :to_s_alphabetical),
                        label: false,
                        include_blank: :translate,
                        wrapper: false,
                        required: true %>
      <%= link_to_remove_association  "<i class=\"#{ Icon::DELETE }\"></i>".html_safe,
                                      f,
                                      class: 'btn btn-sm text-danger' %>
    <%= f.hidden_field :position, data: { 'sortable-input': '' } %>
    <%= f.hidden_field :id if include_id %>
    </div>
  </div>
<% end %>