app/helpers/table_builder_helper.rb
# TODO: rename this after migration from `table_builder`
rename this after migration from `table_builder`
rename this after migration from ` table_builder `
def tr item, columns, selectable, links, overhead, model_name, action
    klass = "#{model_name} #{model_name}-#{item.id}"
    content_tag :tr, class: klass do
      bcont = []
      if selectable
        disabled = selectable.respond_to?(:call) && !selectable.call(item)
        bcont << content_tag(
          :td,
          checkbox(id_name: item.try(:id), value: item.try(:id), disabled: disabled)
        )
      end
      columns.each do |column|
        value = column.value(item)
        extra_class = column.td_class(item)
        if column.linkable?
          path = column.link_to(item)
          link = value.present? && path.present? ? link_to(value, path) : value
          if overhead.empty?
            bcont << content_tag(:td, link, title: 'Voir', class: extra_class)
          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
                clsArrayAlt = overhead[i - 1][:cls].split
                bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArrayAlt, extra_class))
              else
                bcont << content_tag(:td, link, title: 'Voir', class: extra_class)
              end
            else
              clsArray = overhead[columns.index(column)][:cls].split
              bcont << content_tag(:td, link, title: 'Voir', class: td_cls(clsArray, extra_class))
            end
          end
        else
          if overhead.empty?
            bcont << content_tag(:td, value, class: extra_class)
          else
            i = columns.index(column)
            if overhead[i].blank?
              if (i > 0) && (overhead[i - 1][:width].to_i > 1)
                clsArrayAlt = overhead[i - 1][:cls].split
                bcont << content_tag(:td, value, class: td_cls(clsArrayAlt, extra_class))
              else
                bcont << content_tag(:td, value, class: extra_class)
              end
            else
              clsArray = overhead[i][:cls].split
              bcont << content_tag(:td, value, class: td_cls(clsArray))
            end
          end
        end
      end
      action_links = item && item.respond_to?(:action_links) && (item.action_links.is_a?(AF83::Decorator::ActionLinks) ? item.action_links(action) : item.action_links)
      if links.any? || action_links.try(:any?)
        bcont << content_tag(
          :td,
          build_links(item, links, action),
          class: 'actions'
        )
      end
      bcont.join.html_safe
    end
  end
def tr item , columns , selectable , links , overhead , model_name , action klass = "#{model_name} #{model_name}-#{item.id}" content_tag :tr , class : klass do bcont = [ ] if selectable disabled = selectable . respond_to? ( :call ) && ! selectable . call ( item ) bcont << content_tag ( :td , checkbox ( id_name : item . try ( :id ) , value : item . try ( :id ) , disabled : disabled ) ) end columns . each do | column | value = column . value ( item ) extra_class = column . td_class ( item ) if column . linkable? path = column . link_to ( item ) link = value . present? && path . present? ? link_to ( value , path ) : value if overhead . empty? bcont << content_tag ( :td , link , title : 'Voir' , class : extra_class ) 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 clsArrayAlt = overhead [ i - 1 ] [ :cls ] . split bcont << content_tag ( :td , link , title : 'Voir' , class : td_cls ( clsArrayAlt , extra_class ) ) else bcont << content_tag ( :td , link , title : 'Voir' , class : extra_class ) end else clsArray = overhead [ columns . index ( column ) ] [ :cls ] . split bcont << content_tag ( :td , link , title : 'Voir' , class : td_cls ( clsArray , extra_class ) ) end end else if overhead . empty? bcont << content_tag ( :td , value , class : extra_class ) else i = columns . index ( column ) if overhead [ i ] . blank? if ( i > 0 ) && ( overhead [ i - 1 ] [ :width ] . to_i > 1 ) clsArrayAlt = overhead [ i - 1 ] [ :cls ] . split bcont << content_tag ( :td , value , class : td_cls ( clsArrayAlt , extra_class ) ) else bcont << content_tag ( :td , value , class : extra_class ) end else clsArray = overhead [ i ] [ :cls ] . split bcont << content_tag ( :td , value , class : td_cls ( clsArray ) ) end end end end action_links = item && item . respond_to? ( :action_links ) && ( item . action_links . is_a? ( AF83 :: Decorator :: ActionLinks ) ? item . action_links ( action ) : item . action_links ) if links . any? || action_links . try ( :any? ) bcont << content_tag ( :td , build_links ( item , links , action ) , class : 'actions' ) end bcont . join . html_safe end end
TODO: rename this after migration from `table_builder`
TODO : rename this after migration from ` table_builder `
item
columns
selectable
links
overhead
model_name
action