<% content_for :js do %> <%= javascript_include_tag 'views/avaliations/form' %> <% end %> <%= simple_form_for @avaliation, html: { class: "smart-form" } do |f| %> <%= f.error_notification %> <% if @avaliation.errors.any? %>
<% @avaliation.errors.full_messages.each do |message| %> <%= message %>
<% end %>
<% end %>
<%= f.association :test_setting, as: :select2, elements: @test_settings, hide_empty_element: true, input_html: { data: { hide_empty_element: true }, value: @test_settings.first.id } %>
<%= f.input :unity, as: :select2_unity, user: current_user %>
<% if current_user.current_role_is_admin_or_employee? %> <%= f.association :classroom, as: :select2_classroom, user: current_user, record: f.object %> <% else %> <%= f.association :classroom, as: :select2, elements: @classrooms, user: current_user, record: f.object, readonly: action_name.eql?('edit') %> <% end %>
<% if current_user.current_role_is_admin_or_employee? %> <%= f.association :discipline, as: :select2_discipline, user: current_user, record: f.object, classroom_id: @avaliation.classroom_id %> <% else %> <%= f.association :discipline, as: :select2, elements: @disciplines, user: current_user, record: f.object, classroom_id: @avaliation.classroom_id, readonly: action_name.eql?('edit')%> <% end %>
<%= f.input :test_date, as: :date, input_html: { value: f.object.localized.test_date } %>
<%= f.input :description, required: true %>
<%= f.association :test_setting_test, as: :select2, elements: [] %>
<%= f.input :weight, required: true, label_html: show_avaliation_weight, input_html: show_avaliation_weight.merge({ data: { inputmask: "'digits': #{@avaliation.test_setting&.number_of_decimal_places || 0}" } }) %>
<%= f.association :grades, as: :select2, elements: @grades, multiple: true, required: true, input_html: { value: f.object.grade_ids.join(',').presence || @grades.map{ |g| g.id }.sort.join(','), data: { without_json_parser: true } }%>
<%= f.input :observations %>
<% end %>