auto_awesomplete 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of auto_awesomplete might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/auto_awesompletes_controller.rb +3 -3
- data/lib/auto_awesomplete/search_adapter/base.rb +7 -6
- data/lib/auto_awesomplete/search_adapter/default.rb +3 -3
- data/lib/auto_awesomplete/version.rb +1 -1
- data/vendor/assets/javascripts/auto_awesomplete/ajax.js.coffee +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40cc0f7e3e197e8de6d6bf81f35e886ff23a3d08
|
4
|
+
data.tar.gz: 05d0162800498929f5782d13fca7d35db58b2ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dc960a1e442f20cd2d884fe69a544a527caba43ce971e0e017c1ec1b1babd693d35ecf5ff6d106d0e1fa63561cf412839ad2f935700b0ce8f2c89d51e5e3ff1
|
7
|
+
data.tar.gz: f31bd30434aafb95c2dffd8259599fe5c535aee00b4ec5bc3674f8b1fecdfecd24ad0db45a977347c0b4de945130cc4ff3891a0a9b3ea08f9432ce3c88192228
|
data/README.md
CHANGED
@@ -106,7 +106,7 @@ or
|
|
106
106
|
class SystemRoleSearchAdapter < AutoAwesomplete::SearchAdapter::Base
|
107
107
|
class << self
|
108
108
|
def search_default(term, page, options)
|
109
|
-
roles = default_finder(SystemRole, term, page: page).pluck(:name)
|
109
|
+
roles = default_finder(SystemRole, term, page: page).pluck(:name)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -6,12 +6,12 @@ class AutoAwesompletesController < ApplicationController
|
|
6
6
|
elsif params[:default_class_name].present?
|
7
7
|
adapter = ::AutoAwesomplete::SearchAdapter::Default
|
8
8
|
else
|
9
|
-
render json: {error: "not enough search parameters'"}
|
9
|
+
render json: {error: "not enough search parameters'"},
|
10
10
|
status: 500
|
11
11
|
return
|
12
12
|
end
|
13
13
|
rescue NameError
|
14
|
-
render json: {error: "not found search adapter for '#{params[:class_name]}'"}
|
14
|
+
render json: {error: "not found search adapter for '#{params[:class_name]}'"},
|
15
15
|
status: 500
|
16
16
|
return
|
17
17
|
end
|
@@ -20,6 +20,6 @@ class AutoAwesompletesController < ApplicationController
|
|
20
20
|
page = params.delete(:page)
|
21
21
|
search_method = params.delete(:search_method)
|
22
22
|
|
23
|
-
render json: adapter.search_from_autocomplete(term, page, search_method, params).
|
23
|
+
render json: adapter.search_from_autocomplete(term, page, search_method, params).uniq
|
24
24
|
end
|
25
25
|
end
|
@@ -56,15 +56,16 @@ module AutoAwesomplete
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def get_awesomplete_label(item,
|
59
|
+
def get_awesomplete_label(item, options)
|
60
|
+
label_method = options[:label_method]
|
61
|
+
text_column = options[:default_text_column]
|
62
|
+
|
60
63
|
if label_method.present? && item.respond_to?(label_method)
|
61
64
|
item.public_send(label_method)
|
65
|
+
elsif text_column.present? && text_column.is_a?(String)
|
66
|
+
item.attributes[text_column]
|
62
67
|
else
|
63
|
-
|
64
|
-
item.to_awesomplete
|
65
|
-
else
|
66
|
-
item.to_s
|
67
|
-
end
|
68
|
+
item.to_s
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
@@ -6,13 +6,13 @@ module AutoAwesomplete
|
|
6
6
|
begin
|
7
7
|
default_arel = options[:default_class_name].camelize.constantize
|
8
8
|
rescue NameError
|
9
|
-
return {error: "not found class '#{options[:default_class_name]}'"}
|
9
|
+
return {error: "not found class '#{options[:default_class_name]}'"}
|
10
10
|
end
|
11
11
|
|
12
12
|
default_values = default_finder(default_arel, term, page: page, column: options[:default_text_column])
|
13
13
|
default_values.map do |default_value|
|
14
|
-
get_awesomplete_label(default_value, options
|
15
|
-
end
|
14
|
+
get_awesomplete_label(default_value, options)
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|