Sha256: 356a623d39e59d1fab6694e50d556468e250af7ecc184be09c0a500d183c5715

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

class <%= resource.namespaced_class_name.pluralize %>Datatable < Effective::Datatable
<% if resource.scopes.present? -%>
  filters do<% ([:all] + resource.scopes).uniq.each_with_index do |scope, index| %>
    scope :<%= scope -%><%= ', default: true' if index == 0 -%>
<% end %>
  end

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

<% resource.belong_tos.each do |reference| -%>
    col :<%= reference.name %>
<% end -%>

<% attributes.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

<% if resource.scopes.blank? -%>
  collection do
    <%= resource.class_name %>.all
  end
<% else -%>
  collection do
    <%= resource.class_name %>.all
  end
<% end -%>

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_developer-0.2.4 lib/scaffolds/datatables/datatable.rb