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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6005e876f0dee4686fd3f3733d24eef2a4043d01
4
- data.tar.gz: d178124b03fb6b1d6954e32945e13ff937c470c2
3
+ metadata.gz: 40cc0f7e3e197e8de6d6bf81f35e886ff23a3d08
4
+ data.tar.gz: 05d0162800498929f5782d13fca7d35db58b2ec7
5
5
  SHA512:
6
- metadata.gz: 5da020ffb26b01bd6ecee680ae15ad1cccd2dea5b848f2c9bfee40db78fe6399b0e95c402d302d7d97998e9dc4f3b0f81afede5cdf1288f74dcbf2b5a4aff4e0
7
- data.tar.gz: d0b4f8bd78243538c029b782548a63a35d557495632dd7ee4a2f8e710afaf6c4253a0b5603c1c3aab2eda566ffff20dad0be28d342339410ab84f9cb2a3dfb80
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).to_json
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'"}.to_json,
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]}'"}.to_json,
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).to_json
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, label_method)
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
- if item.respond_to?(:to_awesomplete)
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]}'"}.to_json
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[:label_method])
15
- end.to_json
14
+ get_awesomplete_label(default_value, options)
15
+ end
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module AutoAwesomplete
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -6,7 +6,7 @@
6
6
  data: { term: term }
7
7
  ,
8
8
  success: (data) ->
9
- awesomplete.list = JSON.parse(data)
9
+ awesomplete.list = data
10
10
  awesomplete.evaluate()
11
11
  return
12
12
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_awesomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Lisichkin