app/helpers/table_builder_helper.rb
def thead(collection, columns, sortable, selectable, has_links, overhead, model, action)
    content_tag :thead do
      # Inserts overhead content if any specified
      over_head = ''

      unless overhead.empty?
        over_head = content_tag :tr, class: 'overhead' do
          oh_cont = []

          overhead.each do |h|
            oh_cont << content_tag(:th, raw(h[:title]), colspan: h[:width], class: h[:cls])
          end
          oh_cont.join.html_safe
        end
      end

      main_head = content_tag :tr do
        hcont = []

        if selectable
          hcont << content_tag(:th, checkbox(id_name: '0', value: 'all'))
        end

        columns.each do |column|
          if overhead.empty?
            hcont << content_tag(:th, build_column_header(
              column,
              sortable,
              model,
              params
            ))

          else
            i = columns.index(column)

            if overhead[i].blank?
              prev = nil
              if i > 0
                (i-1..0).each do |j|
                  o = overhead[j]
                  if (j + o[:width].to_i) >= i
                    prev = o
                    break
                  end
                end
              end
              if prev
                clsArrayH = overhead[i - 1][:cls].split

                hcont << content_tag(:th, build_column_header(
                  column,
                  sortable,
                  model,
                  params
                ), class: td_cls(clsArrayH))

              else
                hcont << content_tag(:th, build_column_header(
                  column,
                  sortable,
                  model,
                  params
                ))
              end

            else
              clsArrayH = overhead[i][:cls].split

              hcont << content_tag(:th, build_column_header(
                column,
                sortable,
                model,
                params
              ), class: td_cls(clsArrayH))

            end

          end
        end

        # Inserts a blank column for the gear menu
        last_item = collection.last
        action_links = last_item && last_item.respond_to?(:action_links) && (last_item&.action_links&.is_a?(AF83::Decorator::ActionLinks) ? last_item.action_links(action) : last_item.action_links)
        if has_links || action_links.try(:any?)
          hcont << content_tag(:th, '')
        end

        hcont.join.html_safe
      end

      (over_head + main_head).html_safe
    end
  end
# TODO: rename this after migration from `table_builder`
rename this after migration from `table_builder`
rename this after migration from ` table_builder `
def thead(collection, columns, sortable, selectable, has_links, overhead, model, action)
    content_tag :thead do
      over_head = ''
      unless overhead.empty?
        over_head = content_tag :tr, class: 'overhead' do
          oh_cont = []
          overhead.each do |h|
            oh_cont << content_tag(:th, raw(h[:title]), colspan: h[:width], class: h[:cls])
          end
          oh_cont.join.html_safe
        end
      end
      main_head = content_tag :tr do
        hcont = []
        if selectable
          hcont << content_tag(:th, checkbox(id_name: '0', value: 'all'))
        end
        columns.each do |column|
          if overhead.empty?
            hcont << content_tag(:th, build_column_header(
              column,
              sortable,
              model,
              params
            ))
          else
            i = columns.index(column)
            if overhead[i].blank?
              prev = nil
              if i > 0
                (i-1..0).each do |j|
                  o = overhead[j]
                  if (j + o[:width].to_i) >= i
                    prev = o
                    break
                  end
                end
              end
              if prev
                clsArrayH = overhead[i - 1][:cls].split
                hcont << content_tag(:th, build_column_header(
                  column,
                  sortable,
                  model,
                  params
                ), class: td_cls(clsArrayH))
              else
                hcont << content_tag(:th, build_column_header(
                  column,
                  sortable,
                  model,
                  params
                ))
              end
            else
              clsArrayH = overhead[i][:cls].split
              hcont << content_tag(:th, build_column_header(
                column,
                sortable,
                model,
                params
              ), class: td_cls(clsArrayH))
            end
          end
        end
        last_item = collection.last
        action_links = last_item && last_item.respond_to?(:action_links) && (last_item&.action_links&.is_a?(AF83::Decorator::ActionLinks) ? last_item.action_links(action) : last_item.action_links)
        if has_links || action_links.try(:any?)
          hcont << content_tag(:th, '')
        end
        hcont.join.html_safe
      end
      (over_head + main_head).html_safe
    end
  end
def thead ( collection , columns , sortable , selectable , has_links , overhead , model , action ) content_tag :thead do over_head = '' unless overhead . empty? over_head = content_tag :tr , class : 'overhead' do oh_cont = [ ] overhead . each do | h | oh_cont << content_tag ( :th , raw ( h [ :title ] ) , colspan : h [ :width ] , class : h [ :cls ] ) end oh_cont . join . html_safe end end main_head = content_tag :tr do hcont = [ ] if selectable hcont << content_tag ( :th , checkbox ( id_name : '0' , value : 'all' ) ) end columns . each do | column | if overhead . empty? hcont << content_tag ( :th , build_column_header ( column , sortable , model , params ) ) else i = columns . index ( column ) if overhead [ i ] . blank? prev = nil if i > 0 ( i - 1 .. 0 ) . each do | j | o = overhead [ j ] if ( j + o [ :width ] . to_i ) >= i prev = o break end end end if prev clsArrayH = overhead [ i - 1 ] [ :cls ] . split hcont << content_tag ( :th , build_column_header ( column , sortable , model , params ) , class : td_cls ( clsArrayH ) ) else hcont << content_tag ( :th , build_column_header ( column , sortable , model , params ) ) end else clsArrayH = overhead [ i ] [ :cls ] . split hcont << content_tag ( :th , build_column_header ( column , sortable , model , params ) , class : td_cls ( clsArrayH ) ) end end end last_item = collection . last action_links = last_item && last_item . respond_to? ( :action_links ) && ( last_item &. action_links &. is_a? ( AF83 :: Decorator :: ActionLinks ) ? last_item . action_links ( action ) : last_item . action_links ) if has_links || action_links . try ( :any? ) hcont << content_tag ( :th , '' ) end hcont . join . html_safe end ( over_head + main_head ) . html_safe end end
TODO: rename this after migration from `table_builder`
TODO : rename this after migration from ` table_builder `
# Inserts overhead content if any specified # Inserts a blank column for the gear menu
collection
columns
sortable
selectable
has_links
overhead
model
action