Sha256: 7d6862276b51e8ec6f3d414e7777c26b8a9c9b19f73bd4e6df817c90f429fd3c

Contents?: true

Size: 1.93 KB

Versions: 4

Compression:

Stored size: 1.93 KB

Contents

:ruby
  effective_datatable_params = {
    id: "#{datatable.to_param}-table-#{Time.zone.now.nsec}",
    class: "#{datatable.table_html_class}",
    data: {
      'effective-form-inputs' => defined?(EffectiveFormInputs),
      'bulk-actions' => datatable_bulk_actions(datatable),
      'columns' => datatable_columns(datatable),
      'input-js-options' => local_assigns[:input_js_options],
      'simple' => datatable.simple?.to_s,
      'source' => effective_datatables.datatable_path(datatable, {format: 'json'}.merge(attributes: datatable.attributes)).chomp('?'),
      'default-order' => datatable_default_order(datatable),
      'display-entries' => datatable.display_entries,
      'display-records' => (datatable.to_json[:recordsFiltered] || 0),
      'total-records' => (datatable.to_json[:recordsTotal] || 0)
    }
  }

%table.effective-datatable{effective_datatable_params}
  %thead
    - if datatable.table_columns.any? { |_, opts| opts[:th].present? } == false
      %tr
        - datatable.table_columns.each do |name, opts|
          %th= opts[:label] || name
    - else
      - max_depth = datatable.table_columns.map { |_, opts| opts[:th].try(:[], :depth) || 0 }.max
      - [*0..max_depth].each do |depth|
        %tr
          - table_columns = datatable.table_columns.select { |_, opts| (opts[:th].try(:[], :depth) || 0) == depth }
          - table_columns.each do |name, opts|
            %th{(opts[:th] || {}).merge(title: (opts[:label] || name))}
              = opts[:label] || name
            - (opts[:append_th] || []).each do |faux_col|
              %th{(faux_col[:th] || {}).merge(title: faux_col[:label])}
                = faux_col[:label]

  %tbody
    - datatable.to_json[:data].each do |row|
      %tr
        - row.each do |col|
          %td= col.to_s.html_safe

  - if datatable.aggregates.present?
    %tfoot
      - datatable.to_json[:aggregates].each do |row|
        %tr
          - row.each do |col|
            %td= col.to_s.html_safe

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_datatables-2.12.2 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.12.1 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.12.0 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.11.2 app/views/effective/datatables/_datatable.html.haml