Module: Showbuilder::ShowModelTable
- Included in:
- Showbuilder
- Defined in:
- lib/showbuilder/show_model_table.rb
Instance Method Summary collapse
- #get_show_model_table_column_count(block) ⇒ Object
-
#show_model_table(models, itext_base = nil, &block) ⇒ Object
show_model_table @sale do |row| = row.show_date_link_column :created_at = row.show_text_link_column :number = row.show_text_link_column :customer, :name, :link => :customer = row.show_currency_link_column :total.
- #show_model_table_body(models, &block) ⇒ Object
- #show_model_table_body_row(model, &block) ⇒ Object
- #show_model_table_header(itext_base, &block) ⇒ Object
- #show_model_table_header_row(itext_base, &block) ⇒ Object
- #show_model_table_no_record_row(block) ⇒ Object
Instance Method Details
#get_show_model_table_column_count(block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/showbuilder/show_model_table.rb', line 64 def get_show_model_table_column_count(block) row = Object.new class << row attr_accessor :column_count def increament_column_count self.column_count ||= 0 self.column_count += 1 end def method_missing(meth, *args, &block) if meth.to_s =~ /^show_(.+)_column$/ self.increament_column_count else super end end end capture row, &block return row.column_count end |
#show_model_table(models, itext_base = nil, &block) ⇒ Object
show_model_table @sale do |row|
= row.show_date_link_column :created_at
= row.show_text_link_column :number
= row.show_text_link_column :customer, :name, :link => :customer
= row.show_currency_link_column :total
13 14 15 16 17 18 |
# File 'lib/showbuilder/show_model_table.rb', line 13 def show_model_table(models, itext_base = nil, &block) contents_tag(:table, :class => "table table-bordered table-striped") do |contents| contents << show_model_table_header(itext_base, &block) contents << show_model_table_body(models, &block) end end |
#show_model_table_body(models, &block) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/showbuilder/show_model_table.rb', line 26 def show_model_table_body(models, &block) contents_tag :tbody do |contents| models.each do |model| contents << show_model_table_body_row(model, &block) end contents << show_model_table_no_record_row(block) if models.count == 0 end end |
#show_model_table_body_row(model, &block) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/showbuilder/show_model_table.rb', line 54 def show_model_table_body_row(model, &block) row = Showbuilder::Builders::ShowModelTableRowBuilder.new(self) row.is_header = false row.model = model content_tag :tr do capture row, &block end end |
#show_model_table_header(itext_base, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/showbuilder/show_model_table.rb', line 20 def show_model_table_header(itext_base, &block) content_tag :thead do show_model_table_header_row itext_base, &block end end |
#show_model_table_header_row(itext_base, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/showbuilder/show_model_table.rb', line 44 def show_model_table_header_row(itext_base, &block) row = Showbuilder::Builders::ShowModelTableRowBuilder.new(self) row.is_header = true row.itext_base = itext_base content_tag :tr do capture row, &block end end |
#show_model_table_no_record_row(block) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/showbuilder/show_model_table.rb', line 35 def show_model_table_no_record_row(block) column_count = get_show_model_table_column_count(block) content_tag :tr do content_tag :td, :colspan => column_count do show_itext 'no_record' end end end |