noesya/osuny

View on GitHub
app/views/admin/users/_form.html.erb

Summary

Maintainability
Test Coverage
<%= simple_form_for [:admin, user] 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 :email %>
      <%= f.input :first_name %>
      <%= f.input :last_name %>
      <%= render 'admin/application/l10n/form', f: f %>
    </div>
    <div class="col-md-4">
      <%= f.input :mobile_phone %>
      <%= f.input :role, include_blank: false, collection: current_user.managed_roles, label_method: lambda { |k| t("activerecord.attributes.user.roles.#{k[1]}")} %>
      <div data-show-for-roles="program_manager">
        <%= f.association :programs_to_manage,
                          as: :check_boxes,
                          collection: osuny_collection_tree(current_university.education_programs.root, localized: true) %>
      </div>
      <div data-show-for-roles="author,contributor,website_manager">
        <%= f.association :websites_to_manage,
                          as: :check_boxes,
                          collection: osuny_collection(current_university.communication_websites, localized: true) %>
      </div>
    </div>
    <div class="col-md-4">
      <%= f.input :picture,
              as: :single_deletable_file,
              input_html: { accept: default_images_formats_accepted },
              preview: 200,
              resize: 1 %>
    </div>
  </div>
  <% content_for :action_bar_right do %>
    <%= submit f %>
  <% end %>
<% end %>