KyivKrishnaAcademy/ved_akadem_students

View on GitHub
app/views/academic_groups/_form.html.haml

Summary

Maintainability
Test Coverage
- content_for(:js_and_css) do
  = select2_scripts_and_stylesheets

= simple_form_for @academic_group do |f|
  = render 'shared/error_messages', object: f.object

  .form-inputs
    = f.input :title
    = f.input :establ_date, as: :string, input_html: { type: 'date', value: date_value(f.object.establ_date) }
    = f.input :group_description

    = f.association :curator,
                    label_method: :complex_name,
                    collection: [f.object.curator].compact,
                    input_html: { data: { placeholder: t('.curator_placeholder'),
                                          'ajax--url': ui_group_curators_path } }

    = f.association :administrator,
                    label_method: :complex_name,
                    collection: [f.object.administrator].compact,
                    input_html: { data: { placeholder: t('.administrator_placeholder'),
                                          'ajax--url': ui_group_admins_path } }

    - is_group_not_persisted = !f.object.persisted?
    = f.association :praepostor,
                    label_method: :complex_name,
                    hint: is_group_not_persisted && t('.disabled_praepostor_hint'),
                    collection: [f.object.praepostor].compact,
                    input_html: { data: { placeholder: t('.praepostor_placeholder'),
                                          'ajax--url': ui_group_praepostors_path(group_id: f.object.id) },
                                  disabled: is_group_not_persisted }

    = f.association :courses, label_method: :label_for_select, collection: f.object.courses,
                    hint: t('.courses_hint'),
                    input_html: { data: { placeholder: t('.courses_placeholder'),
                                          'ajax--url': ui_courses_path } }

    ~ f.input :message_ru, input_html: { rows: 5 }, hint: t('.message_hint')
    ~ f.input :message_uk, input_html: { rows: 5 }, hint: t('.message_hint')

  .form-actions
    = f.button :button, class: 'btn btn-submit col-xs-12' do
      %span.glyphicon.glyphicon-refresh.spinner{ aria: { hidden: true } }
      = submit_label