effective_datatables 3.0.7 → 3.0.8

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: 76b1cc1f0029f8a223dee58f8631d9287eac4b85
4
- data.tar.gz: 128aeb70dd5f4a02356356c4b9668117773202bd
3
+ metadata.gz: 96df2e08f32b87a62ce043e3760697cb7439d134
4
+ data.tar.gz: e053c8993e6f151086fe31e1daeb4a24b984f17a
5
5
  SHA512:
6
- metadata.gz: 4e5a42ac21c1228b1bdfedf8b84721f633cb6de20add6fb0137208c0df4646f6957d9c1ffadaed3204cf9d3a93f992e7f3093c0781319f4f7313a93bc615e42e
7
- data.tar.gz: 9fab83262b0d391514892d21e4cde08c85213a23efdbfb0dfb02b901448d96680134d882d06c62eb2a5b06de0800e3f8c2b95eb149489b5a07ea305338683d9a
6
+ metadata.gz: 1b3b944e79218ff0a5ae54d6080be055e4b15c14da25337b2d6400efc8a1703839b41c25a4dafb8759a645ea8f5dc9a015b4fed5545c416f76802c5711436efe
7
+ data.tar.gz: dfb15a2aceb2d3615c7cae86453fd5ed8e2e10eae999ed9672aa5923dde2798d1ae4a1e04a7451b4ba67383418d0da662238c0c23c9582b079dfd644595c0a14
data/README.md CHANGED
@@ -863,7 +863,7 @@ datatable do
863
863
  end.search do |collection, term, column, sql_column|
864
864
  # collection is an ActiveRecord scoped collection
865
865
  # term is the incoming PostCategory ID as per the search
866
- # column is this column's attributes Hash
866
+ # column is this column's options Hash
867
867
  # sql_column is the column[:sql_column]
868
868
  categories = current_user.post_categories.where(id: term.to_i)
869
869
 
@@ -911,13 +911,13 @@ The search and sort for each column will be merged together to form the final re
911
911
 
912
912
  ### Default search collection
913
913
 
914
- When using a `col :user` type belongs_to or has_many column, a search collection for that class will be loaded.
914
+ When using a `col :comments` type belongs_to or has_many column, a search collection for that class will be loaded.
915
915
 
916
916
  Add the following to your related model to customize the search collection:
917
917
 
918
918
  ```ruby
919
919
  class Comment < ApplicationRecord
920
- scope :datatables_filter, -> { Comment.includes(:user) }
920
+ scope :datatables_filter, -> { includes(:user) }
921
921
  end
922
922
  ```
923
923
 
@@ -993,7 +993,7 @@ There are a few other ways to customize the behaviour of effective_datatables
993
993
 
994
994
  ## Checking for Empty collection
995
995
 
996
- Check whether the datatable has records by calling `@datatable.empty?` and `@datatable.present?`.
996
+ Check whether the datatable has records by calling `@datatable.present?` and `@datatable.blank?`.
997
997
 
998
998
  ## Override javascript options
999
999
 
@@ -142,7 +142,7 @@ initializeDataTables = ->
142
142
  $th = $(api.column(index).header())
143
143
  settings = api.settings()[0].aoColumns[index] # column specific settings
144
144
 
145
- if settings.search && ('' + settings.search).length > 0 # Assign preselected values
145
+ if settings.search != null # Assign preselected values
146
146
  api.settings()[0].aoPreSearchCols[index].sSearch = settings.search
147
147
 
148
148
  if settings.searchHtml # Append the search html and initialize input events
@@ -158,4 +158,9 @@ table.dataTable tbody {
158
158
  td.col-bulk_actions {
159
159
  input[type='checkbox'] { margin-left: 1px; margin-right: 1px; }
160
160
  }
161
+
162
+ td {
163
+ p { margin-bottom: 0px; }
164
+ }
165
+
161
166
  }
@@ -69,7 +69,7 @@ module Effective
69
69
  elsif array_collection?
70
70
  obj[opts[:index]]
71
71
  elsif opts[:sql_as_column]
72
- obj[name] || obj.send(name)
72
+ obj[name] || (obj.send(name) if obj.respond_to?(name))
73
73
  else
74
74
  obj.send(name)
75
75
  end
@@ -89,12 +89,17 @@ module Effective
89
89
 
90
90
  if search[:collection].kind_of?(ActiveRecord::Relation)
91
91
  search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.to_param] }
92
+ elsif search[:collection].kind_of?(Array) && search[:collection].first.kind_of?(ActiveRecord::Base)
93
+ search[:collection] = search[:collection].map { |obj| [obj.to_s, obj.to_param] }
92
94
  elsif search[:collection].kind_of?(Array)
93
95
  search[:collection].each { |obj| obj[1] = 'nil' if obj[1] == nil }
94
96
  end
95
97
 
98
+ search[:value] ||= search.delete(:selected) if search.key?(:selected)
99
+
96
100
  search[:as] ||= :select if (search.key?(:collection) && opts[:as] != :belongs_to_polymorphic)
97
- search[:fuzzy] = true unless search.key?(:fuzzy)
101
+
102
+ search[:fuzzy] = (opts[:sql_as_column] != true) unless search.key?(:fuzzy)
98
103
 
99
104
  if array_collection? && opts[:resource].present?
100
105
  search.reverse_merge!(resource.search_form_field(name, collection.first[opts[:index]]))
@@ -148,9 +148,9 @@ module Effective
148
148
  # Set default order direction
149
149
  state[:order_dir] ||= ['_at', '_on', 'date'].any? { |str| order_name.to_s.end_with?(str) } ? :desc : :asc
150
150
 
151
- if state[:search].blank?
151
+ if state[:search].blank? && !datatables_ajax_request?
152
152
  columns.each do |name, opts|
153
- state[:search][name] = opts[:search][:value] if opts[:search].kind_of?(Hash) && opts[:search].key?(:value)
153
+ state[:search][name] = opts[:search][:value] if (opts[:search] || {}).key?(:value)
154
154
  end
155
155
  end
156
156
 
@@ -38,7 +38,4 @@ EffectiveDatatables.setup do |config|
38
38
  destroy: true,
39
39
  }
40
40
 
41
- # Which packages to load when using the charts DSL
42
- config.google_chart_packages = ['corechart']
43
-
44
41
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '3.0.7'.freeze
2
+ VERSION = '3.0.8'.freeze
3
3
  end
@@ -8,7 +8,6 @@ module EffectiveDatatables
8
8
 
9
9
  mattr_accessor :default_length
10
10
  mattr_accessor :actions_column # A Hash
11
- mattr_accessor :google_chart_packages
12
11
 
13
12
  def self.setup
14
13
  yield self
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.0.7
4
+ version: 3.0.8
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-05-24 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails