app/views/itineraries/_form.html.slim

Summary

Maintainability
Test Coverage
fieldset#single
  = f.input :leave_date, as: :datetime, default: default_leave_date, start_year: Time.current.year, end_year: 1.year.from_now.year, minute_step: 10, ampm: t('time.ampm'), input_html: { class: 'date-time' }, wrapper: :horizontal_form
  = f.input :round_trip, as: :boolean, wrapper: :horizontal_boolean
  = f.input :return_date, as: :datetime, default: default_leave_date, start_year: Time.current.year, end_year: 1.year.from_now.year, minute_step: 10, ampm: t('time.ampm'), input_html: { class: 'date-time' }, disabled: !@itinerary.round_trip, wrapper: :horizontal_form
  = f.input :fuel_cost, wrapper: :horizontal_form do
    .input-group
      = f.text_field :fuel_cost, class: 'form-control text-end form-control--short'
      span.input-group-text = APP_CONFIG.currency
    p.form-text.text-body-secondary.mb-0#fuel-help data-avg-consumption=current_user.vehicle_avg_consumption
      small#fuel-help-text
  = f.input :tolls, wrapper: :horizontal_form do
    .input-group
      = f.text_field :tolls, class: 'form-control text-end form-control--short'
      span.input-group-text = APP_CONFIG.currency
    - if @itinerary.errors.include?(:tolls)
      span.help-inline
        = @itinerary.errors.messages[:tolls].join(', ')
  = f.input :description, as: :text, input_html: { rows: 5, maxlength: Itinerary::MAX_DESCRIPTION_LENGTH }, hint: t('.description_hint'), wrapper: :horizontal_form
  .form-group.row
    .col-sm-9.offset-sm-3
      - if current_user.female?
        = f.input :pink, as: :boolean, hint: t('.pink_hint'), wrapper: false, form_check_wrapper_html: { class: 'mb-2' }
      = f.input :smoking_allowed, as: :boolean, wrapper_class: false, form_check_wrapper_html: { class: 'mb-2' }
      = f.input :pets_allowed, as: :boolean, wrapper: false

/
  fieldset#daily.hide.mock
    .control-group
      .controls
        table.table.table-condensed.daily-itinerary-table
          thead
            tr
              th
              th= t('.day')
              th= t('.leave_time')
              th= t('.return_time')
          tbody
            - (0..6).each_with_index do |index|
              tr
                td
                  p.text-center
                    = check_box_tag "day-#{index}"
                td= label_tag "day-# index ", t('date.day_names')[index]
                td
                  = time_select 'one', 'two', { minute_step: 10, default: { hour: 8 }, ampm: t('time.ampm') }, class: 'date-time', disabled: (index > 0)
                td
                  = time_select 'one', 'two', { minute_step: 10, default: { hour: 18 }, ampm: t('time.ampm') }, class: 'date-time', disabled: (index > 0)
          tfoot
            tr
              td colspan="2"
              td colspan="2"
                = label_tag 'edit-all-times', class: 'checkbox inline' do
                  = check_box_tag 'edit-all-times', nil, checked: true
                  = t('.edit_all_times')

/
  .control-group.hide
    .controls
      = label_tag nil, class: 'radio inline' do
        = f.input, :daily, false, as: :radio, checked: true
        = t('.single_itinerary')
      |  
      = label_tag nil, class: 'radio inline mock' do
        = f.default_tag :radio_button, :daily, true, class: 'inline'
        = t('.daily_itinerary')