effective_datatables 3.2.4 → 3.2.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: bff5ff06830aa75fddc8b3f258efb2bcf2172711
4
- data.tar.gz: e8fb0ce5abfb5cda5f923e8129cbac8ffc66fdbe
3
+ metadata.gz: 5f740fcfa8103e4a41cd19d78627e660ed8261d7
4
+ data.tar.gz: 2a38dab4e9bfd6532d6455abdda04f50d928680b
5
5
  SHA512:
6
- metadata.gz: 0f6fdd1eb126d275c1fd1d6b8f3cc94bb03bff1d46ccb61ae2f13b4c66fd159a859b306bc51d24897d579ecc155e9e85abaad18591a91380e374c5f40eea21c7
7
- data.tar.gz: ff02255065aa756979a8389deec17c3a2e7f4778bae700fd21a8502eef4449795e98386836c68ef499a6e848dd8ad8f611fda3dbe43af80224a7d74a18250c2d
6
+ metadata.gz: 28352978829362e667d377d03864e7cde3b9f4ce72230bd61d3c68aa97ba0f29f8ef49697171da41d84931fee1b4beea6229dd9f232e7276b49d82914f3579db
7
+ data.tar.gz: 255b54c6a2763303e7b9d423fa74cc846fe7fa771bd4292a4681e9b2bb90e70d4e1819bb937d88d0132cb92723f30791dcafab4dba6017bcb449e2e7f556aa03
@@ -1,7 +0,0 @@
1
- .effective-datatable-filters {
2
- .form-inline {
3
- .form-group { margin-right: 10px; }
4
- .control-label { margin-right: 10px; }
5
- }
6
- margin-bottom: 12px;
7
- }
@@ -85,12 +85,12 @@ module Effective
85
85
 
86
86
  # term == 'nil' rescue false is a Rails 4.1 fix, where you can't compare a TimeWithZone to 'nil'
87
87
  if (term == 'nil' rescue false)
88
- return collection.select! { |row| obj_to_value(row[index], column) == nil } || collection
88
+ return collection.select! { |row| obj_to_value(row[index], column, row) == nil } || collection
89
89
  end
90
90
 
91
91
  # See effective_resources gem search() method # relation.rb
92
92
  collection.select! do |row|
93
- obj = obj_to_value(row[index], column)
93
+ obj = obj_to_value(row[index], column, row)
94
94
 
95
95
  case column[:as]
96
96
  when :boolean
@@ -165,8 +165,20 @@ module Effective
165
165
  collection.size
166
166
  end
167
167
 
168
- def obj_to_value(obj, column)
169
- ((column[:partial] || column[:format]) && !column[:compute]) ? obj.send(column[:name]) : obj
168
+ def obj_to_value(obj, column, row = nil)
169
+ return obj if column[:compute]
170
+
171
+ # This matches format.rb. Probably should be refactored.
172
+
173
+ if column[:format]
174
+ datatable.dsl_tool.instance_exec(obj, row, &column[:format])
175
+ elsif column[:partial]
176
+ raise 'unsupported'
177
+ elsif obj.respond_to?(column[:name])
178
+ obj.send(column[:name])
179
+ else
180
+ obj
181
+ end
170
182
  end
171
183
 
172
184
  end
@@ -52,7 +52,7 @@ module Effective
52
52
  end
53
53
 
54
54
  def format_column(value, column)
55
- return if value.nil?
55
+ return if value.nil? || (column[:resource] && value.blank?)
56
56
 
57
57
  unless column[:as] == :email
58
58
  return value if value.kind_of?(String)
@@ -19,6 +19,7 @@ module Effective
19
19
  if active_record_collection?
20
20
  columns.each do |name, opts|
21
21
 
22
+ # col 'comments.title'
22
23
  if name.kind_of?(String) && name.include?('.')
23
24
  raise "invalid datatables column '#{name}'. the joined syntax only supports one dot." if name.scan(/\./).count > 1
24
25
 
@@ -28,8 +29,10 @@ module Effective
28
29
  raise "invalid datatables column '#{name}'. unable to find '#{name.split('.').first}' association on '#{resource}'."
29
30
  end
30
31
 
31
- unless collection.joins_values.include?(associated) || collection.joins_values.include?(associated.to_sym)
32
- raise "your datatables collection must .joins(:#{associated}) to work with the joined syntax"
32
+ joins_values = (collection.joins_values + collection.left_outer_joins_values)
33
+
34
+ unless joins_values.include?(associated.to_sym)
35
+ raise "your datatables collection must .joins(:#{associated}) or .left_outer_joins(:#{associated}) to work with the joined syntax"
33
36
  end
34
37
 
35
38
  opts[:resource] = Effective::Resource.new(resource.associated(associated), namespace: controller_namespace)
@@ -1,8 +1,8 @@
1
- .row
2
- .col-sm-12.effective-datatable-filters{'aria-controls' => datatable.to_param}
3
- = simple_form_for :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], html: { class: 'form-inline' } do |form|
1
+ .effective-datatable-filters{'aria-controls': datatable.to_param}
2
+ = simple_form_for :filters, url: (datatable._form[:url] || '#'), method: datatable._form[:verb], html: { class: 'form-inline' } do |form|
4
3
 
5
- - if datatable._scopes.present?
4
+ - if datatable._scopes.present?
5
+ .btn-toolbar
6
6
  = form.input :scope, label: false, required: false, checked: datatable.state[:scope],
7
7
  as: (defined?(EffectiveFormInputs) ? :effective_radio_buttons : :radio_buttons),
8
8
  collection: datatable._scopes.map { |name, opts| [opts[:label], name] },
@@ -15,7 +15,8 @@
15
15
  multiple: opts[:input_html].delete(:multiple),
16
16
  input_html: (({name: ''} unless datatable._filters_form_required?) || {}).merge(opts[:input_html])
17
17
 
18
- - if datatable._filters_form_required?
19
- = form.button :submit, 'Apply', 'data-disable-with' => 'Applying...'
20
- - else
21
- = link_to 'Apply', '#', class: 'btn btn-primary', 'data-apply-datatable-filters' => true
18
+ .btn-group
19
+ - if datatable._filters_form_required?
20
+ = form.button :submit, 'Apply', 'data-disable-with': 'Applying...'
21
+ - else
22
+ = link_to 'Apply', '#', class: 'btn btn-primary btn-effective-datatable-filters', 'data-apply-datatable-filters': true
@@ -1,5 +1,5 @@
1
1
  - Array(datatable.array_collection? ? resource : resource.send(name)).each do |associated|
2
- %p
2
+ .col-resource_item
3
3
  - if show_path
4
4
  = link_to associated.to_s, send(show_path, associated.to_param), title: associated.to_s
5
5
  - elsif edit_path
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.2.4'.freeze
2
+ VERSION = '3.2.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails