module ReleaseTypesHelper
  def options_for_release_type_select(project = nil, release_type = "talent")
    release_types = Project::SIGNABLE_RELEASE_TYPES

    if project
      release_types = release_types.select { |type| project.feature_enabled?("#{type}_release") }
    end

    release_types = release_types.map { |type| [ "#{release_type_title(type)} Release", type ] }

    options_for_select(release_types, release_type)
  end

  def release_type_title(releasable_type)
    releasable_type.titleize
  end

  def releasable_type_heading(releasable_type)
    releasable_type.titleize.pluralize
  end

  def available_release_types
    Project::AVAILABLE_RELEASE_TYPES.map { |release| "#{release}_release"}
  end

  def available_release_types_model_names
    available_release_types.map(&:classify).map(&:constantize).map(&:model_name)
  end
end
