app/helpers/itineraries_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module ItinerariesHelper
  def boolean_options_for_select
    @boolean_options_for_select ||= [[t('boolean.true'), true], [t('boolean.false'), false]]
  end

  def default_leave_date
    @default_leave_date ||= Time.current.change(min: (Time.current.min / 10) * 10) + 10.minutes
  end

  def boolean_tag(value, field, allowed_icon: 'check', forbidden_icon: 'ban')
    status = value ? 'allowed' : 'forbidden'

    tag.div class: "tag tag-#{status}" do
      concat tag.span(nil, class: "fas fa-#{status == 'allowed' ? allowed_icon : forbidden_icon}")
      concat ' '
      concat t(".#{field}.#{status}")
    end
  end
end