Sha256: 0d25064524ff42ce393afd927785737a7505e277bee872a9b3730c6e44b338ca

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

class Skyline::Presenters::Table < Skyline::Presenters::Presenter
  
  def output
    content_tag("table",super, :class => "listing")
  end
        
  def header
    "<thead><tr>#{self.heading_collection.map{|f| content_tag("th",f.singular_label.capitalize)}.join("\n")}<th></th><th></th></tr></thead>"
  end
  
  def body
    if self.collection.any?
      self.collection.map{|el| next if el.new_record?; content_tag("tr",self.row(el).join("\n"), :class => cycle("odd","even")) }
    else
      "<tr class=\"blank-slate\"><td colspan=\"#{self.heading_collection.size + 2}\">#{t(:blank_slate, :scope => [:content,:list], :class => self.fieldset.plural_name.downcase)}.</td></tr>"
    end
  end
  
  def row(record)
    return if record.new_record? # there can't be any new records in a list!
    content_cells = self.heading_collection.map do |field| 
      content,options = self.value(record,field); 
      content_tag("td",content,options)
    end
    
    [content_cells, content_tag("td",edit_button(record), :class => "edit"), content_tag("td",delete_button(record),:class => "delete")]
  end
  
        
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
westarete-skylinecms-3.0.8.20100329 app/helpers/skyline/presenters/table.rb
westarete-skylinecms-3.0.8.20100330 app/helpers/skyline/presenters/table.rb
skylinecms-3.0.8 app/helpers/skyline/presenters/table.rb
skylinecms-3.0.7 app/helpers/skyline/presenters/table.rb