OfficeMomsandDads/scheduler

View on GitHub
app/views/needs/_form_fields.html.haml

Summary

Maintainability
Test Coverage
- if f.object.errors.any?
  #error_explanation
    %h5
      = pluralize(f.object.errors.count, "error")
      prohibited this task from being saved:
    %ul
      - f.object.errors.full_messages.each do |msg|
        %li= msg

%fieldset.fieldset
  %legend Start Date/Time
  .grid-x
    .cell
      = react_component("NewNeedDatePicker/index", { startAt: f.object.start_at, exists: f.object.id.present? })
%fieldset.fieldset
  %legend Expected Duration
  .grid-x.grid-margin-x
    .cell.small-12.medium-shrink
      = f.label :expected_duration, class: 'duration-label' do
        = f.number_field :expected_duration, min: 1, max: 9, step: 0.25, class: 'duration-input', disabled: action == :edit
        .align-self-middle{style: 'padding-left:.5rem;'}
          %p Hours
    .cell.small-12.medium-auto
      .slider{ data: { slider: true, step: '0.25', start: '1', end: '9', initial_start: @need.expected_duration.to_f / 60 }, class: (action == :edit ? 'disabled' : '') }
        %span.slider-handle{ role: 'slider', data: { slider_handle: true}, tabindex: '1', aria: { controls: 'need_expected_duration' } }
        %span.slider-fill{ data: { slider_fill: true } }
%fieldset.fieldset
  %legend Office
  .grid-x
    .cell
      = f.label :office_id do
        = f.select :office_id, options_for_select(policy_scope(Office).map { |o| [o.name, o.id]}), { include_blank: false }, disabled: action == :edit, data: { action: 'change->new-need-form#handleOfficeChange' }
%fieldset.fieldset
  %legend Child Welfare Workers
  .grid-x
    .cell
      = f.label :social_worker_ids do
        %div{ data: { target: 'new-need-form.socialWorkerSelectContainer' } }
          = render template: 'needs/office_social_workers', locals: { office: @need.office || policy_scope(Office).first }
.grid-x
  .cell
    = react_component("NeedChildForm/index", { children: @need.children, childSexes: Child.sexes.keys }, id: 'NeedChildForm')
%fieldset.fieldset
  %legend Preferred Culture
  .grid-x
    .cell
      = f.label :race_id do
        = f.select :race_id, options_for_select(race_options_for_select), { include_blank: true }, class: 'single'
%fieldset.fieldset
  %legend Preferred Language
  .grid-x
    .cell
      = f.label :preferred_language_id do
        = f.select :preferred_language_id, language_options_for_select, { include_blank: false }, class: 'single'
%fieldset.fieldset
  %legend Notes
  .grid-x
    .cell
      = f.label :notes do
        = f.text_area :notes, :rows => 6, :placeholder => 'Enter notes here'