table_on_steroids 0.1.1.5 → 0.1.1.6
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8366b8de497d16595ce9014b84a6f5474a3acb31b7cdfb9d36b32b6f339843e8
|
4
|
+
data.tar.gz: '085a992475e3ca1190308f07bc786cbfea8a6e2d450842d1fbca381b769a86a0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1417185b5afcf7f76fc62bfe647c8c755edae0addc1f07e857f035198e6c05c91af934f1ffb5f203bb339c9926ab33b4f13e3c653079d88f7900a5ccdf7ce1fa
|
7
|
+
data.tar.gz: 00032b6d606863e17298ed5e9f59aafc6bded91c2333401f752d47b2e5b22ae555d49e3e74c037f688872fa7a0bc74d36603e00220b7a599a9ef0dcc7760e853
|
@@ -37,11 +37,11 @@ module TableOnSteroids
|
|
37
37
|
OBJECTS_PER_PAGE = 50
|
38
38
|
end
|
39
39
|
|
40
|
-
def filter_and_order(objects, columns_on_steroid, global_search=nil, include_counts=false, all_pages=false )
|
40
|
+
def filter_and_order(objects, columns_on_steroid, global_search=nil, include_counts=false, all_pages=false, table_on_steroids=nil )
|
41
41
|
# execute the global search if you have one
|
42
42
|
if(params[:search].present?)
|
43
43
|
objects = global_search.call(objects,params[:search]) if global_search
|
44
|
-
objects = all_column_search(objects,columns_on_steroid, params[:search]) if !global_search
|
44
|
+
objects = all_column_search(objects, columns_on_steroid, params[:search], table_on_steroids) if !global_search
|
45
45
|
end
|
46
46
|
|
47
47
|
[:activerecord, :array].each do |t|
|
@@ -64,7 +64,7 @@ module TableOnSteroids
|
|
64
64
|
objects = objects.reorder(nil) if(objects.is_a?(ActiveRecord::Base) || objects.is_a?(ActiveRecord::Relation))
|
65
65
|
objects = object_order[t][:order_lambda].call(objects)
|
66
66
|
end
|
67
|
-
|
67
|
+
elsif ( object_order = columns_on_steroid.select{ |c,v| v[t] && v[t][:default_order] }.first&.last).present?
|
68
68
|
if(object_order[t] && object_order[t][:order_lambda])
|
69
69
|
objects = objects.reorder(nil) if(objects.is_a?(ActiveRecord::Base) || objects.is_a?(ActiveRecord::Relation))
|
70
70
|
objects = object_order[t][:order_lambda].call(objects)
|
@@ -104,8 +104,11 @@ module TableOnSteroids
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def all_column_search(objects, columns_on_steroid, query)
|
108
|
-
|
107
|
+
def all_column_search(objects, columns_on_steroid, query, table_on_steroids=nil)
|
108
|
+
global_search_key = table_on_steroids&.dig(:global_search_key) || :id
|
109
|
+
global_search_key_params = {}
|
110
|
+
matched_object_keys = []
|
111
|
+
|
109
112
|
[:activerecord, :array].each do |t|
|
110
113
|
columns_on_steroid.each do |key, value|
|
111
114
|
if(value[t].present? && ((value[t][:search_lambda].present? && !["date","integer"].include?(value[:datatype])) || value[t][:global_search_lambda].present?))
|
@@ -114,11 +117,13 @@ module TableOnSteroids
|
|
114
117
|
else
|
115
118
|
objects_returned = value[t][:search_lambda].call(objects, query)
|
116
119
|
end
|
117
|
-
objects_returned.each{|o|
|
120
|
+
objects_returned.each{|o| matched_object_keys << o[global_search_key] } if(objects_returned)
|
118
121
|
end
|
119
122
|
end
|
120
123
|
end
|
121
|
-
|
124
|
+
|
125
|
+
global_search_key_params[global_search_key] = matched_object_keys.uniq
|
126
|
+
objects = objects.where(global_search_key_params)
|
122
127
|
end
|
123
128
|
|
124
129
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_on_steroids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1.
|
4
|
+
version: 0.1.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marieke Gueye
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-08-
|
12
|
+
date: 2019-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap-datepicker-rails
|