forest_liana 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/forest_liana/search_query_builder.rb +42 -6
- data/lib/forest_liana/version.rb +1 -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: 65bc0a94633ab9554e51ace04fb84e302b2afb0b
|
4
|
+
data.tar.gz: f026a0b61db387f8045b4f50a48ba54288e75b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80fd90903e69868ed3132c6b5a49b9526922ca38a7961b415fcf977db027c03589f3142ed77b39511921aef38061b6928cd774322d7981ac10eb260197ebd739
|
7
|
+
data.tar.gz: c818a6da4a756d1deafbb07caef9299866fea4d72fb85aa20ae49d68017abc5f25d626a6c39970e48e355bb9d150fe628f69caf21a8ce791aa2d6e9bec48149d
|
@@ -34,6 +34,16 @@ module ForestLiana
|
|
34
34
|
ForestLiana::AdapterHelper.format_column_name(table_name, column_name)
|
35
35
|
end
|
36
36
|
|
37
|
+
def acts_as_taggable_query(tagged_records)
|
38
|
+
ids = tagged_records
|
39
|
+
.map {|t| t[@resource.primary_key]}
|
40
|
+
.join(',')
|
41
|
+
|
42
|
+
if ids.present?
|
43
|
+
return "#{@resource.primary_key} IN (#{ids})"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
37
47
|
def search_param
|
38
48
|
if @params[:search]
|
39
49
|
conditions = []
|
@@ -60,6 +70,15 @@ module ForestLiana
|
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
73
|
+
# ActsAsTaggable
|
74
|
+
if @resource.respond_to?(:acts_as_taggable)
|
75
|
+
@resource.acts_as_taggable.each do |field|
|
76
|
+
tagged_records = @records.tagged_with(@params[:search].downcase)
|
77
|
+
condition = acts_as_taggable_query(tagged_records)
|
78
|
+
conditions << condition if condition
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
63
82
|
SchemaUtils.one_associations(@resource).map(&:name).each do |association|
|
64
83
|
if @includes.include? association.to_sym
|
65
84
|
resource = @resource.reflect_on_association(association.to_sym)
|
@@ -84,13 +103,25 @@ module ForestLiana
|
|
84
103
|
def filter_param
|
85
104
|
if @params[:filterType] && @params[:filter]
|
86
105
|
conditions = []
|
106
|
+
|
87
107
|
@params[:filter].each do |field, values|
|
88
|
-
|
108
|
+
# ActsAsTaggable
|
109
|
+
if acts_as_taggable?(field)
|
110
|
+
tagged_records = @records.tagged_with(values.tr('*', ''))
|
111
|
+
|
112
|
+
if @params[:filterType] == 'and'
|
113
|
+
@records = tagged_records
|
114
|
+
elsif @params[:filterType] == 'or'
|
115
|
+
conditions << acts_as_taggable_query(tagged_records)
|
116
|
+
end
|
117
|
+
else
|
118
|
+
next if association?(field)
|
89
119
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
120
|
+
values.split(',').each do |value|
|
121
|
+
operator, value = OperatorValueParser.parse(value)
|
122
|
+
conditions << OperatorValueParser.get_condition(field, operator,
|
123
|
+
value, @resource, @params[:timezone])
|
124
|
+
end
|
94
125
|
end
|
95
126
|
end
|
96
127
|
|
@@ -113,10 +144,15 @@ module ForestLiana
|
|
113
144
|
[:has_many, :has_and_belongs_to_many].include?(association.try(:macro))
|
114
145
|
end
|
115
146
|
|
147
|
+
def acts_as_taggable?(field)
|
148
|
+
@resource.respond_to?(:acts_as_taggable) &&
|
149
|
+
@resource.acts_as_taggable.include?(field)
|
150
|
+
end
|
151
|
+
|
116
152
|
def has_many_filter
|
117
153
|
if @params[:filter]
|
118
154
|
@params[:filter].each do |field, values|
|
119
|
-
next
|
155
|
+
next if !has_many_association?(field) || acts_as_taggable?(field)
|
120
156
|
|
121
157
|
values.split(',').each do |value|
|
122
158
|
if field.include?(':')
|
data/lib/forest_liana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forest_liana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Munda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|