Skip to content
Browse files

introduced engine

  • Loading branch information...
1 parent 3bc6c25 commit 7c602009994425570b8e7e23dd6102c7bb23c497 @diegosteiner committed Dec 19, 2011
Showing with 54 additions and 0 deletions.
  1. +50 −0 app/views/index_helper/index.html.erb
  2. +4 −0 lib/index_helper/engine.rb
View
50 app/views/index_helper/index.html.erb
@@ -0,0 +1,50 @@
+<% sort_column = params[:sort].try(:to_sym) %>
+<div class="index-container">
+ <div class="index-navigation">
+ <h2><%= builder.title %></h2>
+ <div class="index-filter"></div>
+ </div>
+ <div class="index-table">
+ <table>
+ <thead>
+ <tr>
+ <% builder.columns.each do |c| %>
+ <% unless options[:pagination] == false %>
+ <% ascending = (c.name == sort_column && params[:order] == 'asc') %>
+ <th class="<%= "sorting_column #{ascending ? :desc : :asc}" if c.name == sort_column %>">
+ <%= link_to(send("#{builder.model.model_name.plural}_path", {sort: c.name, order: ( ascending ? :desc : :asc )})) do %>
+ <%= content_tag :span, c.head %>
+ <% end %>
+ </th>
+ <% else %>
+ <th>
+ <%= content_tag :span do %>
+ <%= c.head %>
+ <% end %>
+ </th>
+ <% end %>
+ <% end %>
+ </tr>
+ </thead>
+ <tbody>
+ <% builder.records.each do |r| %>
+ <tr>
+ <% builder.columns.each do |c| %>
+ <td><%= c.body r %></td>
+ <% end %>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+ <div class="index-navigation-bottom">
+ <div class="index-buttons">
+ <%= link_to 'New Member', send("new_#{builder.model.model_name.singular}_path") %>
+ </div>
+ <% unless options[:pagination] == false %>
+ <div class="index-pager">
+ <%= paginate builder.records, window: 1%>
+ </div>
+ <% end %>
+ </div>
+</div>
View
4 lib/index_helper/engine.rb
@@ -0,0 +1,4 @@
+module IndexHelper
+ class Engine < ::Rails::Engine
+ end
+end

0 comments on commit 7c60200

Please sign in to comment.
Something went wrong with that request. Please try again.