blocks 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/app/views/blocks/_table.html.erb +24 -6
  2. metadata +2 -2
@@ -25,22 +25,40 @@
25
25
  <%= table.define :header_columns do |options| %>
26
26
  <% table.columns.each do |column| %>
27
27
  <%= content_tag :th, options.merge(column.options)[:header_html] do %>
28
- <%= table.use "#{column.name.to_s}_header", options.merge(:column => column) %>
28
+ <%= table.use "#{column.name.to_s}_header", options.merge(column.options) %>
29
29
  <% end %>
30
30
  <% end %>
31
31
  <% end %>
32
32
 
33
33
  <% table.columns.each do |column| %>
34
- <%= table.define "#{column.name.to_s}_header", :column => column do |record, options| %>
35
- <%= column.options[:label] ? column.options[:label] : column.name.to_s.titleize %>
34
+ <%= table.define "#{column.name.to_s}_header", :column => column do |options| %>
35
+ <% if options[:sortable] %>
36
+ <%= table.use "#{options[:column].name.to_s}_header_sortable_link", options %>
37
+ <% else %>
38
+ <%= options[:label] ? options[:label] : options[:column].name.to_s.titleize %>
39
+ <% end %>
40
+ <% end %>
41
+
42
+ <%= table.define "#{column.name.to_s}_header_sortable_link", :column => column do |options| %>
43
+ <%= table.use :header_sortable_link, options %>
36
44
  <% end %>
37
- <% end %>
45
+ <% end %>
46
+
47
+ <%= table.define :header_sortable_link do |options| %>
48
+ <% label = (options[:label] ? options[:label] : options[:column].name.to_s.titleize) %>
49
+ <% sort_mode = ((params[:order] != options[:order].to_s or params[:sort_mode] == "desc") ? "asc" : "desc") %>
50
+ <% ui_icon = sort_mode == "desc" ? "ui-icon-triangle-1-s" : "ui-icon-triangle-1-n" %>
51
+ <% parameters = params.merge({:order => (options[:order] ? options[:order] : options[:column].name), :sort_mode => sort_mode}) %>
38
52
 
39
- <%= table.define :tbody do %>
53
+ <%= link_to label, parameters %>
54
+ <span class="ui-icon <%= ui_icon %>" style="display:<%= params[:order] == options[:order].to_s ? "inline-block" : "none" %>; float:none"></span>
55
+ <% end %>
56
+
57
+ <%= table.define :tbody do %>
40
58
  <tbody>
41
59
  <%= table.use :rows %>
42
60
  </tbody>
43
- <% end %>
61
+ <% end %>
44
62
 
45
63
  <%= table.define :rows do %>
46
64
  <% records.each do |record| %>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: blocks
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.5
5
+ version: 1.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Hunter
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-15 00:00:00 -04:00
14
+ date: 2011-04-22 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies: []
17
17