Sha256: e90f149e0a423c3536bf03bd6546126340f5c8b6dc5ac85c7af9ca0970fbbaba

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

%table{ class: table_css_classes }
  - if show_header
    %thead
      %tr
        - columns.each do |name, options|
          - title = options.delete(:title)
          - if title.nil?
            - if resource_class.respond_to?(:human_attribute_name)
              - title = resource_class.human_attribute_name(name)
            - else
              - title = name
          - elsif title === false
            - title = nil
          - if options.has_key?(:sort)
            %th= sort_link(name, title, options[:sort])
          - else
            %th= title
  %tbody
    - collection.each_with_index do |resource, index|
      - tr_options = { class: resource_class.name.underscore.gsub('/', '-') }
      - if resource.respond_to?(:model_name)
        - tr_options[:id] = dom_id(resource)
      - else
        - tr_options[:id] = "#{resource.class.name.underscore.gsub('/', '-')}-#{resource.object_id}"

      %tr{ tr_options.merge(tr_html.respond_to?(:call) ? (tr_html.call(resource, index) || {}) : (tr_html || {})) }
        - columns.each do |name, options|
          - td_html = if options[:td_html].respond_to?(:call)
            - options[:td_html].call(resource) || {}
          - else
            - options[:td_html] || {}
          - td_options = { class: ["attribute-#{name}", td_html[:class]].compact.join(" "), id: "#{tr_options[:id]}-#{name}" }.merge(td_html.except(:class))
          - if options[:block].present?
            %td{ td_options }= options[:block].call(resource)
          - else
            %td{ td_options }
              = render partial: "rao/component/table/body_cells/#{options[:render_as]}", locals: { resource: resource, name: name, options: options }

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rao-component-0.0.52.pre app/views/rao/component/_collection_table.html.haml
rao-component-0.0.51.pre app/views/rao/component/_collection_table.html.haml
rao-component-0.0.50.pre app/views/rao/component/_collection_table.html.haml
rao-component-0.0.49.pre app/views/rao/component/_collection_table.html.haml