Sha256: cc92f0c3d74083e5dbb57cb32bce4e0da836f2b7a01736c20cb179e749745e69

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

class <%= resource.namespaced_class_name.pluralize %>Datatable < Effective::Datatable

  datatable do
    order :<%= (attributes.find { |att| att.name == 'updated_at' } || attributes.first).name %>

<% if attributes.find { |att| att.name == 'updated_at' } -%>
    col :updated_at, visible: false
<% end -%>
<% if attributes.find { |att| att.name == 'created_at' } -%>
    col :created_at, visible: false
<% end -%>
<% if attributes.find { |att| att.name == 'id' } -%>
    col :id, visible: false

<% end -%>
<% resource.belong_tos.each do |reference| -%>
    col :<%= reference.name %>
<% end -%>
<% resource.nested_resources.each do |reference| -%>
    col :<%= reference.name %>
<% end -%>
<% attributes.reject { |att| ['created_at', 'updated_at', 'id'].include?(att.name) }.each do |attribute| -%>
    col :<%= attribute.name %>
<% end -%>

<% if non_crud_actions.present? -%>
    actions_col do |<%= singular_name %>|
<% non_crud_actions.each_with_index do |action, index| -%>
      icon_to('ok', <%= resource.action_path_helper(action, at: false) %>, title: '<%= action.titleize %>')<%= ' +' if (index+1) < (invoked_actions - crud_actions).length %>
<% end -%>
    end
<% else -%>
    actions_col
<% end -%>
  end

  collection do
    <%= resource.class_name %>.deep.all
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_developer-0.3.0 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.14 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.13 lib/scaffolds/datatables/datatable.rb