Sha256: 8807a363c8d2e4889d44ed8bb57cc94d84bdbbf969e384f10198bb25079ec3b1

Contents?: true

Size: 1.26 KB

Versions: 8

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| -%>
      glyphicon_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 %>.all
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
effective_developer-0.2.12 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.11 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.10 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.9 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.8 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.7 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.6 lib/scaffolds/datatables/datatable.rb
effective_developer-0.2.5 lib/scaffolds/datatables/datatable.rb