# frozen_string_literal: true module DashboardsHelper def channel_select(name, channels, options = {}) selected_channel_id = options.delete(:selected) raw_options = tag.option(value: "") channels.each do |(category, channels)| if category raw_options += tag.option(value: "", disabled: true, style: "color-dark-gray") do "---#{category[:name]}---" end end channels.each do |channel| raw_options += tag.option(value: channel[:id], selected: channel[:id] == selected_channel_id) { channel[:name] } end end select_tag(name, raw_options, options) end end