module ExcelReports
  module VideoReports
    module DiscoveryProductionElementsLogs
      class TalentSheet < ::ExcelReports::Worksheet
        def title
          "Talent"
        end

        def fill_content(sheet)
          sheet.add_row ["TALENT AGREEMENT LOG (for all episodes/programs)"]
          sheet.add_row
          sheet.add_row ["Episode Number(s) or list \"All\"", "Episode Title(s) or list \"All\"", "SERVICES", "NAME/COMPANY"]

          data.each do |confirmation|
            sheet.add_row [confirmation.episode_number, confirmation.episode_title, "", confirmation.name]
          end
        end

        def format(sheet)
          sheet.column_widths *column_widths
        end

        def style(sheet)
          sheet.add_style "A1", Styles::BOLD, { sz: 14 }
          sheet.add_style "A3:D3", Styles::TABLE_HEADER
          sheet.add_style "A3", Styles::WRAP_TEXT

          if data.any?
            sheet.add_style "A#{data_start_index}:D#{data_end_index}", Styles::TABLE_DATA
          end
        end

        private

        def column_widths
          [20, 20, 30, 60]
        end

        def data_start_index
          4
        end

        def data_end_index
          (data_start_index + data.size) - 1
        end
      end
    end
  end
end
