effective_datatables 3.0.7 → 3.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/assets/javascripts/effective_datatables/initialize.js.coffee +1 -1
- data/app/assets/stylesheets/effective_datatables/_overrides.scss +5 -0
- data/app/models/effective/effective_datatable/compute.rb +1 -1
- data/app/models/effective/effective_datatable/resource.rb +6 -1
- data/app/models/effective/effective_datatable/state.rb +2 -2
- data/config/effective_datatables.rb +0 -3
- data/lib/effective_datatables/version.rb +1 -1
- data/lib/effective_datatables.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96df2e08f32b87a62ce043e3760697cb7439d134
|
4
|
+
data.tar.gz: e053c8993e6f151086fe31e1daeb4a24b984f17a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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 :
|
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, -> {
|
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.
|
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
|
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
|
@@ -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
|
-
|
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]
|
153
|
+
state[:search][name] = opts[:search][:value] if (opts[:search] || {}).key?(:value)
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
data/lib/effective_datatables.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|