module ApplicationHelper
  def icon(name, options = {})
    options[:title] ||= name.underscore.humanize
    options[:aria] = true
    options[:nocomment] = true
    options[:variant] ||= :outline # :outline, :solid
    # options[:class] = options.fetch(:class, nil)
    options[:class] = "size-5" unless options[:class]
    path = options.fetch(:path, "icons/#{options[:variant]}/#{name}.svg")
    icon = path
    inline_svg_tag(icon, options)
  end

  def bool_icon(bool)
    case bool
    when true then "check-circle"
    else "x-circle"
    end
  end

  def operator_tab?
    controller.class.name.split("::").first=="Operator"
  end

  def admin_tab?
    controller.class.name.split("::").first=="Admin"
  end

  def profile_tab?
    controller.class.name=="ProfilesController"
  end

  def root_tab?
    controller.class.name=="JobsController"
  end

  def is_admin_or_operator?
    current_user.admin? || current_user.operator?
  end

  def edit_form?
    action_name != "new" && action_name != "create"
    # alternate:  @model.persisted?
  end
end
