recordselect 3.3.9 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -37,25 +37,25 @@ module RecordSelect
|
|
37
37
|
# generate conditions from params[:search]
|
38
38
|
# override this if you want to customize the search routine
|
39
39
|
def record_select_conditions_from_search
|
40
|
-
|
41
|
-
|
42
|
-
if params[:search] and !params[:search].strip.empty?
|
40
|
+
if params[:search] && !params[:search].strip.empty?
|
43
41
|
if record_select_config.full_text_search?
|
44
42
|
tokens = params[:search].strip.split(' ')
|
45
43
|
else
|
46
|
-
tokens = []
|
47
|
-
tokens << params[:search].strip
|
44
|
+
tokens = [params[:search].strip]
|
48
45
|
end
|
49
|
-
|
50
|
-
|
51
|
-
phrase = "(#{where_clauses.join(' OR ')})"
|
52
|
-
|
53
|
-
sql = ([phrase] * tokens.length).join(' AND ')
|
54
|
-
tokens = tokens.collect{ |value| [search_pattern.sub('?', value)] * record_select_config.search_on.length }.flatten
|
55
|
-
|
56
|
-
conditions = [sql, *tokens]
|
46
|
+
search_pattern = record_select_config.full_text_search? ? '%?%' : '?%'
|
47
|
+
build_record_select_conditions(tokens, record_select_like_operator, search_pattern)
|
57
48
|
end
|
58
49
|
end
|
50
|
+
|
51
|
+
def build_record_select_conditions(tokens, operator, search_pattern)
|
52
|
+
where_clauses = record_select_config.search_on.collect { |sql| "#{sql} #{operator} ?" }
|
53
|
+
phrase = "(#{where_clauses.join(' OR ')})"
|
54
|
+
sql = ([phrase] * tokens.length).join(' AND ')
|
55
|
+
|
56
|
+
tokens = tokens.collect { |token| [search_pattern.sub('?', token)] * record_select_config.search_on.length }.flatten
|
57
|
+
[sql, *tokens]
|
58
|
+
end
|
59
59
|
|
60
60
|
# generate conditions from the url parameters (e.g. users/browse?group_id=5)
|
61
61
|
def record_select_conditions_from_params
|
@@ -169,7 +169,7 @@ module RecordSelectHelper
|
|
169
169
|
# just return the string
|
170
170
|
render_record_from_config(record, renderer)
|
171
171
|
end
|
172
|
-
description.match(/<label[^>]*>(.*)<\/label>/)[1]
|
172
|
+
description.match(/<label[^>]*>(.*)<\/label>/){ |match| match[1] } || description if description
|
173
173
|
end
|
174
174
|
|
175
175
|
def assert_controller_responds(controller_name)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recordselect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 3.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 3.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Cambra
|
@@ -117,10 +117,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
117
|
requirements:
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
hash:
|
120
|
+
hash: 49
|
121
121
|
segments:
|
122
|
-
-
|
123
|
-
|
122
|
+
- 1
|
123
|
+
- 9
|
124
|
+
- 1
|
125
|
+
version: 1.9.1
|
124
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
127
|
none: false
|
126
128
|
requirements:
|