search_autocomplete 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +12 -0
- data/lib/search_autocomplete/form_builder_helper.rb +1 -1
- data/lib/search_autocomplete/searchable.rb +3 -3
- data/lib/search_autocomplete/version.rb +1 -1
- metadata +52 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dce201acb963770b2b39fa7a4ede136a05f202047f0afc54a86ed09bf7681e2b
|
4
|
+
data.tar.gz: dc565979afc405dd53ddf95ad3cd9961146ae344da9abcf069630cfc4369204f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e9635eef637b53f4376ae1264e2ad9f3a51967cbd08b8314a622d340371c80cce2b4587c06fe81da2d78da26477b4010d18bee6eb4eac2b9a6e431fb9b62b2
|
7
|
+
data.tar.gz: cc552950c207df79d1080e52ead0ad3ff4daf6a29e1df49c66496465eff2aeee65e513ab650a901b141d58436c55e3c245a3c91b80fbce24fe0dbec46e60fe88
|
data/README.md
CHANGED
@@ -76,6 +76,18 @@ You can also search namespaced models by adding the lowercase name of every name
|
|
76
76
|
|
77
77
|
If your model is `Admin::User` the search would be: `{APP URL}/autocomplete/admin/user?term=Roger`
|
78
78
|
|
79
|
+
You can also specify more filters and additional fields to display instead of the base field:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
class Category < ApplicationRecord
|
83
|
+
belongs_to :category, optional: true
|
84
|
+
|
85
|
+
autocomplete :name, %i[name last_name], %i[last_name]
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
You can search names AND last_names like this: `{APP URL}/autocomplete/person?term=Roger&last_name=Smith`
|
90
|
+
|
79
91
|
### Search / Filter
|
80
92
|
|
81
93
|
You can use the method `search` on your controllers as a way to filter data.
|
@@ -8,7 +8,7 @@ module ActionView
|
|
8
8
|
class FormBuilder
|
9
9
|
##
|
10
10
|
# Creates an autocomplete element from form builder
|
11
|
-
def autocomplete_field(method, display_value, autocomplete_path, options
|
11
|
+
def autocomplete_field(method, display_value, autocomplete_path, **options)
|
12
12
|
options.reverse_merge!(
|
13
13
|
'display-value': find_autocomplete_value(display_value),
|
14
14
|
value: @object.send(method),
|
@@ -24,13 +24,13 @@ module ActionController
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
def prepare_search_fields(table, fields,
|
27
|
+
def prepare_search_fields(table, fields, **options)
|
28
28
|
search_conditions = []
|
29
29
|
fields.each do |field|
|
30
30
|
if field.is_a?(Array)
|
31
|
-
search_conditions.push prepare_jsonb_condition(table, field, exact)
|
31
|
+
search_conditions.push prepare_jsonb_condition(table, field, options[:exact])
|
32
32
|
else
|
33
|
-
search_conditions.push prepare_simple_condition(table, field, exact)
|
33
|
+
search_conditions.push prepare_simple_condition(table, field, options[:exact])
|
34
34
|
end
|
35
35
|
end
|
36
36
|
search_conditions
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_autocomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Schiavo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description: Search and autocomplete based on Arel and WebComponents.
|
14
56
|
email:
|
15
57
|
- francischiavo@gmail.com
|
@@ -31,7 +73,12 @@ files:
|
|
31
73
|
homepage: https://github.com/francis-schiavo/search_autocomplete
|
32
74
|
licenses:
|
33
75
|
- MIT
|
34
|
-
metadata:
|
76
|
+
metadata:
|
77
|
+
homepage_uri: https://github.com/francis-schiavo/search_autocomplete
|
78
|
+
source_code_uri: https://github.com/francis-schiavo/search_autocomplete
|
79
|
+
bug_tracker_uri: https://github.com/francis-schiavo/search_autocomplete/issues
|
80
|
+
changelog_uri: https://github.com/francis-schiavo/search_autocomplete/blob/master/CHANGELOG.md
|
81
|
+
documentation_uri: https://rubydoc.info/gems/search_autocomplete
|
35
82
|
post_install_message:
|
36
83
|
rdoc_options: []
|
37
84
|
require_paths:
|
@@ -40,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
87
|
requirements:
|
41
88
|
- - ">="
|
42
89
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
90
|
+
version: 2.7.2
|
44
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
92
|
requirements:
|
46
93
|
- - ">="
|