table_sortable 0.4.7 → 1.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8def2534bcfe05e1ab749a6853d1edd26a751ad
4
- data.tar.gz: 91ad20906e10c0d9d4a49afaa198a88e9cf6e7f7
3
+ metadata.gz: 16a4f40f3be133c7ec573c4b44ed7a0e09d4ff32
4
+ data.tar.gz: 8c5b23bb0ca2f978ac6e521a8c3ff6ec0b5f19c0
5
5
  SHA512:
6
- metadata.gz: 0d0c532401296051648a7ec339a08ab7fcb4d970df8026177210c4e31f0bf1d054dbf129044c917d12a45137c1014822179f4413ca6eade55cef9093820fab08
7
- data.tar.gz: 0731c3520684a99a85ad022bc30027f3f7aac04a8d6804856502013114af07f536736364e45c94c43c4bf408a4d9a17813bed72ac5c6917cbd1b9d9b91960596
6
+ metadata.gz: cded6091b5b1f9ca2fc93dcb89dda9282b1793a1e5ba3c6930bb5a58e1ef98a1058f0139eb4a80bb3491758c5d051d4be047744b67f6382fed5dc12d3bba14f2
7
+ data.tar.gz: b2b5058c8231d4150bcb39b118b5645bab6d26416e3f2b70c227a6b5d8762d39798b4ca47775df077124f33d8f2f430cb3fedbec7b0bda945af03fc6089d8628
@@ -0,0 +1,3 @@
1
+ <% @column_html[column.name][record_counter] = capture do %>
2
+ <%= yield %>
3
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= table_sortable_columns record, record_counter, html_options %>
@@ -24,15 +24,13 @@ module TableSortable
24
24
  @template = template
25
25
  @template_path = template_path
26
26
 
27
- view_path = @template_path || (defined?(Rails) ? File.join(Rails.root, 'app', 'views', "#{controller.controller_path}/table_sortable/") : '')
27
+ view_path = @template_path || (defined?(Rails) ? File.join("#{controller.controller_path}/table_sortable/") : '')
28
28
 
29
- view_filename = "_#{@template}_column.html"
30
- view = Dir.glob(File.join(view_path, "#{view_filename}.*"))
31
- @column_partial = view.any? ? File.join(view_path, "#{view_filename}") : false
29
+ view_filename = "#{@template}_column.html"
30
+ @column_partial = controller.lookup_context.find_all(File.join(view_path, "_#{view_filename}")).any? ? File.join(view_path, "#{view_filename}") : false
32
31
 
33
- view_filename = "_#{@template}_header.html"
34
- view = Dir.glob(File.join(view_path, "#{view_filename}.*"))
35
- @header_partial = view.any? ? File.join(view_path, "#{view_filename}") : false
32
+ view_filename = "#{@template}_header.html"
33
+ @header_partial = controller.lookup_context.find_all(File.join(view_path, "_#{view_filename}")).any? ? File.join(view_path, "#{view_filename}") : false
36
34
 
37
35
  @options = column_options
38
36
  @filter = TableSortable::Column::Filter.new(options.merge(:column => self) )
@@ -1,3 +1,3 @@
1
1
  module TableSortable
2
- VERSION = "0.4.7"
2
+ VERSION = "1.0.0-alpha.1"
3
3
  end
@@ -36,7 +36,7 @@ module TableSortable
36
36
  th_options.merge!(html_options)
37
37
 
38
38
  if col.header_partial
39
- render file: col.header_partial,
39
+ render partial: col.header_partial,
40
40
  locals: {label: col.label,
41
41
  column: col,
42
42
  index: index}
@@ -48,7 +48,7 @@ module TableSortable
48
48
  end.join.html_safe
49
49
  end
50
50
 
51
- def table_sortable_columns(record, html_options = {})
51
+ def table_sortable_columns(record, row_number, html_options = {})
52
52
  controller.columns.map.with_index do |col, index|
53
53
  value = col.value(record)
54
54
  content = col.content(record)
@@ -57,12 +57,7 @@ module TableSortable
57
57
  td_options.merge!(html_options)
58
58
 
59
59
  if col.column_partial
60
- render file: col.column_partial,
61
- locals: {content: content,
62
- value: value,
63
- source: record,
64
- column: col,
65
- index: index}
60
+ @column_html[col.name][row_number]
66
61
  else
67
62
  content_tag :td, td_options do
68
63
  content
@@ -70,5 +65,14 @@ module TableSortable
70
65
  end
71
66
  end.join.html_safe
72
67
  end
68
+
69
+ def table_sortable_rows(layout, collection, html_options = {})
70
+ @column_html = {}
71
+ controller.columns.select{|col| col.column_partial}.each do |col|
72
+ @column_html[col.name] = []
73
+ render partial: col.column_partial, collection: collection, as: :record, layout: '/table_sortable/capture_column.html.erb', locals: {column: col}
74
+ end
75
+ render partial: '/table_sortable/row.html.erb', layout: layout, collection: collection, as: :record, locals: {html_options: html_options}
76
+ end
73
77
  end
74
78
  end
@@ -9,7 +9,7 @@ module TableSortable
9
9
  PAGE = 'page'
10
10
  PAGESIZE = 'pagesize'
11
11
 
12
- # class Engine < Rails::Engine; end
12
+ class Engine < Rails::Engine; end
13
13
 
14
14
  end
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_sortable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 1.0.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Davidov
@@ -160,6 +160,8 @@ files:
160
160
  - LICENSE.txt
161
161
  - README.md
162
162
  - Rakefile
163
+ - app/views/table_sortable/_capture_column.html.erb
164
+ - app/views/table_sortable/_row.html.erb
163
165
  - bin/console
164
166
  - bin/setup
165
167
  - lib/table_sortable.rb
@@ -205,9 +207,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
207
  version: '0'
206
208
  required_rubygems_version: !ruby/object:Gem::Requirement
207
209
  requirements:
208
- - - ">="
210
+ - - ">"
209
211
  - !ruby/object:Gem::Version
210
- version: '0'
212
+ version: 1.3.1
211
213
  requirements: []
212
214
  rubyforge_project:
213
215
  rubygems_version: 2.6.12