qui-index-table 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gemspec.email = "marcin@saepia.net"
10
10
  gemspec.homepage = "http://q.saepia.net"
11
11
  gemspec.authors = ["Marcin Lewandowski"]
12
- gemspec.version = "0.0.8"
12
+ gemspec.version = "0.0.9"
13
13
  gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "public/stylesheets/qui/*", "lib/*", "rails/*", "README.rdoc" ]
14
14
  end
15
15
  rescue LoadError
@@ -34,12 +34,24 @@ module QUI
34
34
  end
35
35
 
36
36
  if klass
37
- concat content_tag(:th, klass.human_attribute_name(h.to_s[1..-1]))
37
+ attribute = h.to_s[1..-1]
38
+
39
+ sort_sql = nil
40
+ if klass.respond_to? :generic_fields
41
+ generic_field = klass.generic_fields[:index].detect{ |f| f[:name] == attribute.to_sym }
42
+ sort_sql = true if generic_field and generic_field[:options][:sort_sql]
43
+ end
44
+
45
+ if klass.columns_hash.has_key? attribute or sort_sql
46
+ concat index_table_th(klass.human_attribute_name(attribute).mb_chars.upcase, :sort_by => attribute, :sort_order => (params[:sort_by] == attribute and params[:sort_order] == "A" ? "D" : "A"))
47
+ else
48
+ concat index_table_th(klass.human_attribute_name(attribute).mb_chars.upcase)
49
+ end
38
50
  else
39
- concat content_tag(:th, t(h))
51
+ concat index_table_th t(h)
40
52
  end
41
53
  else
42
- concat content_tag(:th, t(h))
54
+ concat index_table_th t(h)
43
55
  end
44
56
 
45
57
  elsif h.is_a? Hash
@@ -78,16 +90,21 @@ module QUI
78
90
  end
79
91
 
80
92
  concat "<tr class=\"#{cycle("even", "odd", :name => options[:id])}\">"
81
- b.call row
93
+ concat b.call(row)
82
94
  concat "</tr>"
83
95
  end
84
96
 
85
97
  concat "</tbody></table>"
86
98
 
87
- concat pagination(data) if data.is_a? WillPaginate::Collection if defined?(WillPaginate) and defined?(pagination)
88
-
99
+ if defined?(WillPaginate) and data.is_a?(WillPaginate::Collection)
100
+ concat pagination(data) if defined?(pagination)
101
+ concat pagination_per_page_selector(data) if defined?(pagination_per_page_selector)
102
+ end
103
+
89
104
  @index_table_count += 1
90
- end
105
+ ""
106
+ end
107
+
91
108
 
92
109
  end
93
110
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qui-index-table
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcin Lewandowski
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-19 00:00:00 +02:00
18
+ date: 2011-02-07 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21