table_sortable 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9f41a38a9c6e8e3dd84971893d87b4bd6c08598
4
- data.tar.gz: 0550a5e7bf7d84b9de93023ab5fb190f91cf38e6
3
+ metadata.gz: 5279a6fe61465b9302bd136458b22910ff165fcf
4
+ data.tar.gz: 2435e4f604291e32bd9fadf74d1320d151b975a2
5
5
  SHA512:
6
- metadata.gz: c38f714a9562509915a9b1f09f0b532f0bd1ae81295c41a77b9417eb92315d706065e6dd484c879850aa9fa61b7a5d457b24e45f753abca92b98e11edd1df5a2
7
- data.tar.gz: 5a7fa03f35248a87c2c67fc1f5eac760978c0c91a83e3eab51762a3ef51f23febc61eb2c5ecaf8a662aadd33e9a4237f1fd6e698079af14627d9bb3303d8ce67
6
+ metadata.gz: fe0393056ab45eb0de56d5c23d28592b1cb16c691dd55cf9124212b0953d423f146766e38214c2e33780299f8ac18e5ae189ff41e63f846300bc4815223cb501
7
+ data.tar.gz: d5b042e11f44d186a80ff4a5bdce8f9de6a15259f262b6c1db6d07a0da123b44209d7a8ec582b78332717547c30e37bf35478b9b43ee9be1e9465503001ee353
@@ -1,3 +1,3 @@
1
1
  module TableSortable
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
@@ -24,26 +24,31 @@ module TableSortable
24
24
 
25
25
  def table_sortable_headers(html_options = {})
26
26
  controller.columns.map.with_index do |col, index|
27
+ label = col.label
28
+ placeholder = col.placeholder
29
+ filter = col.filter
30
+
27
31
  th_options = {}
28
- th_options['data-placeholder'] = col.placeholder if col.placeholder
32
+ th_options['data-placeholder'] = placeholder if placeholder
29
33
  # th_options['data-priority'] = col.sort_priority if col.sort_priority
30
- th_options['data-filter'] = 'false' if col.filter.disabled?
34
+ th_options['data-filter'] = 'false' if filter.disabled?
31
35
  th_options['data-sorter'] = 'false' if col.sorter.disabled?
32
- unless col.filter.collection.blank?
36
+ unless filter.collection.blank?
33
37
  th_options['filter-select'] = true
34
- th_options['data-filter-options'] = col.filter.collection
38
+ th_options['data-filter-options'] = filter.collection
35
39
  end
36
- th_options['data-value'] = col.filter.default_value if col.filter.default_value
40
+ th_options['data-value'] = filter.default_value if filter.default_value
37
41
  th_options.merge!(html_options)
38
-
39
- begin
40
- render partial: "#{col.template_path || controller_path}/table_sortable/#{col.template}_header.html",
41
- locals: {label: col.label,
42
+ view_path = "#{col.template_path || controller_path}/table_sortable/"
43
+ view_filename = "#{col.template}_header.html"
44
+ if Dir.glob(File.join(Rails.root, 'app', 'views', view_path, "_#{view_filename}.*")).any?
45
+ render partial: File.join(view_path, view_filename),
46
+ locals: {label: label,
42
47
  column: col,
43
48
  index: index}
44
- rescue ActionView::MissingTemplate
49
+ else
45
50
  content_tag :th, th_options do
46
- col.label
51
+ label
47
52
  end
48
53
  end
49
54
  end.join.html_safe
@@ -51,20 +56,23 @@ module TableSortable
51
56
 
52
57
  def table_sortable_columns(record, html_options = {})
53
58
  controller.columns.map.with_index do |col, index|
59
+ value = col.value(record)
60
+ content = col.content(record)
54
61
  td_options = {}
55
- td_options['data-text'] = col.value(record) if col.value(record) != col.content(record)
62
+ td_options['data-text'] = value if value != content
56
63
  td_options.merge!(html_options)
57
-
58
- begin
59
- render partial: "#{col.template_path || controller_path}/table_sortable/#{col.template}_column.html",
60
- locals: {content: col.content(record),
61
- value: col.value(record),
64
+ view_path = "#{col.template_path || controller_path}/table_sortable/"
65
+ view_filename = "#{col.template}_column.html"
66
+ if Dir.glob(File.join(Rails.root, 'app', 'views', view_path, "_#{view_filename}.*")).any?
67
+ render partial: File.join(view_path, view_filename),
68
+ locals: {content: content,
69
+ value: value,
62
70
  source: record,
63
71
  column: col,
64
72
  index: index}
65
- rescue ActionView::MissingTemplate
73
+ else
66
74
  content_tag :td, td_options do
67
- col.value(record)
75
+ value
68
76
  end
69
77
  end
70
78
  end.join.html_safe
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.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Davidov