activeadmin-searchable_select 1.3.0 → 1.4.0
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/.rubocop.yml +2 -0
- data/CHANGELOG.md +8 -12
- data/README.md +1 -1
- data/lib/activeadmin/searchable_select/select_input_extension.rb +5 -3
- data/lib/activeadmin/searchable_select/version.rb +1 -1
- data/spec/features/end_to_end_spec.rb +69 -37
- data/spec/internal/db/schema.rb +11 -0
- data/spec/support/models.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe0935611dac081858397d808fa99c65a72944153ce323c8b10f3afb96657a83
|
4
|
+
data.tar.gz: e5c1faa951288612248a1f87f4ed1961f7f45861b7ac1946a404c5f15030f656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097917cab8c292dcf3cdab69661ff59f6a0377698514b6f7323b28a3a70bc2c3f66c41b64a7e26ae47f981559f791d6ae35df96ec1a736f214fcd7753cd25693'
|
7
|
+
data.tar.gz: 10592311d0cf0ad805abaf218ce97a9af4ff8a8350b861571465e01106815d6b3eaddd9641f2256e5323e5a05a6ed7cd0759a6531cdfe5af2cf858e69affedf2
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
### Version 1.
|
3
|
+
### Version 1.4.0
|
4
4
|
|
5
|
-
2021-02-
|
5
|
+
2021-02-04
|
6
6
|
|
7
|
-
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-
|
7
|
+
[Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-3-stable...v1.4.0)
|
8
8
|
|
9
|
-
-
|
10
|
-
([#
|
11
|
-
-
|
12
|
-
([#
|
13
|
-
- Update CI Setup
|
14
|
-
([#25](https://github.com/codevise/activeadmin-searchable_select/pull/25))
|
15
|
-
- Allow Bundler 2 in development dependencies
|
16
|
-
([#18](https://github.com/codevise/activeadmin-searchable_select/pull/18))
|
9
|
+
- Support admin resources for namespaced models.
|
10
|
+
([#30](https://github.com/codevise/activeadmin-searchable_select/pull/30))
|
11
|
+
- Improve README.md
|
12
|
+
([#28](https://github.com/codevise/activeadmin-searchable_select/pull/28))
|
17
13
|
|
18
14
|
See
|
19
|
-
[1-
|
15
|
+
[1-3-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-3-stable/CHANGELOG.md)
|
20
16
|
for previous changes.
|
data/README.md
CHANGED
@@ -238,7 +238,7 @@ for feature specs:
|
|
238
238
|
```ruby
|
239
239
|
RSpec.configure do |config|
|
240
240
|
config.before(:each) do |example|
|
241
|
-
ActiveAdmin::
|
241
|
+
ActiveAdmin::SearchableSelect.inline_ajax_options = (example.metadata[:type] == :feature)
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
@@ -45,9 +45,11 @@ module ActiveAdmin
|
|
45
45
|
|
46
46
|
def ajax_url
|
47
47
|
return unless options[:ajax]
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
[ajax_resource.route_collection_path,
|
49
|
+
'/',
|
50
|
+
option_collection.collection_action_name,
|
51
|
+
'?',
|
52
|
+
ajax_params.to_query].join
|
51
53
|
end
|
52
54
|
|
53
55
|
def all_options_collection
|
@@ -5,60 +5,92 @@ require 'support/capybara'
|
|
5
5
|
require 'support/active_admin_helpers'
|
6
6
|
|
7
7
|
RSpec.describe 'end to end', type: :feature, js: true do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
context 'class name without namespaces' do
|
9
|
+
before(:each) do
|
10
|
+
ActiveAdminHelpers.setup do
|
11
|
+
ActiveAdmin.register(Category) do
|
12
|
+
searchable_select_options(scope: Category, text_attribute: :name)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
ActiveAdmin.register(Post) do
|
16
|
+
filter(:category, as: :searchable_select, ajax: true)
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
form do |f|
|
19
|
+
f.input(:category, as: :searchable_select, ajax: true)
|
20
|
+
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
+
ActiveAdmin.setup {}
|
24
|
+
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
describe 'index page with searchable select filter' do
|
28
|
+
it 'loads filter input options' do
|
29
|
+
Category.create(name: 'Music')
|
30
|
+
Category.create(name: 'Travel')
|
30
31
|
|
31
|
-
|
32
|
+
visit '/admin/posts'
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
expand_select_box
|
35
|
+
wait_for_ajax
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
expect(select_box_items).to eq(%w(Music Travel))
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'allows filtering options by term' do
|
41
|
+
Category.create(name: 'Music')
|
42
|
+
Category.create(name: 'Travel')
|
43
|
+
|
44
|
+
visit '/admin/posts'
|
45
|
+
|
46
|
+
expand_select_box
|
47
|
+
enter_search_term('T')
|
48
|
+
wait_for_ajax
|
49
|
+
|
50
|
+
expect(select_box_items).to eq(%w(Travel))
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'loads more items when scrolling down' do
|
54
|
+
15.times { |i| Category.create(name: "Category #{i}") }
|
55
|
+
visit '/admin/posts'
|
38
56
|
|
39
|
-
|
40
|
-
|
41
|
-
|
57
|
+
expand_select_box
|
58
|
+
wait_for_ajax
|
59
|
+
scroll_select_box_list
|
60
|
+
wait_for_ajax
|
42
61
|
|
43
|
-
|
62
|
+
expect(select_box_items.size).to eq(15)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
44
66
|
|
45
|
-
|
46
|
-
|
47
|
-
|
67
|
+
context 'class name with namespace' do
|
68
|
+
before(:each) do
|
69
|
+
ActiveAdminHelpers.setup do
|
70
|
+
ActiveAdmin.register RGB::Color, as: 'color' do
|
71
|
+
searchable_select_options scope: RGB::Color, text_attribute: :code
|
72
|
+
end
|
48
73
|
|
49
|
-
|
74
|
+
ActiveAdmin.register Internal::TagName, as: 'Tag Name' do
|
75
|
+
filter :color, as: :searchable_select, ajax: { resource: RGB::Color }
|
76
|
+
end
|
77
|
+
|
78
|
+
ActiveAdmin.setup {}
|
79
|
+
end
|
50
80
|
end
|
51
81
|
|
52
|
-
|
53
|
-
|
54
|
-
|
82
|
+
describe 'index page with searchable select filter' do
|
83
|
+
it 'loads filter input options' do
|
84
|
+
RGB::Color.create(code: '#eac112', description: 'Orange')
|
85
|
+
RGB::Color.create(code: '#19bf25', description: 'Green')
|
55
86
|
|
56
|
-
|
57
|
-
wait_for_ajax
|
58
|
-
scroll_select_box_list
|
59
|
-
wait_for_ajax
|
87
|
+
visit '/admin/tag_names'
|
60
88
|
|
61
|
-
|
89
|
+
expand_select_box
|
90
|
+
wait_for_ajax
|
91
|
+
|
92
|
+
expect(select_box_items).to eq(%w(#eac112 #19bf25))
|
93
|
+
end
|
62
94
|
end
|
63
95
|
end
|
64
96
|
|
data/spec/internal/db/schema.rb
CHANGED
@@ -20,6 +20,17 @@ ActiveRecord::Schema.define do
|
|
20
20
|
t.boolean :published
|
21
21
|
end
|
22
22
|
|
23
|
+
create_table(:rgb_colors, force: true) do |t|
|
24
|
+
t.string :code
|
25
|
+
t.text :description
|
26
|
+
end
|
27
|
+
|
28
|
+
create_table(:internal_tag_names, force: true) do |t|
|
29
|
+
t.string :name
|
30
|
+
t.text :description
|
31
|
+
t.integer :color_id
|
32
|
+
end
|
33
|
+
|
23
34
|
create_table(:users, force: true) do |t|
|
24
35
|
t.string :name
|
25
36
|
end
|
data/spec/support/models.rb
CHANGED
@@ -13,6 +13,20 @@ class Post < ActiveRecord::Base
|
|
13
13
|
scope(:published, -> { where(published: true) })
|
14
14
|
end
|
15
15
|
|
16
|
+
module RGB
|
17
|
+
class Color < ActiveRecord::Base
|
18
|
+
self.table_name = :rgb_colors
|
19
|
+
has_many :tags, class_name: 'Internal::TagName'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Internal
|
24
|
+
class TagName < ActiveRecord::Base
|
25
|
+
self.table_name = :internal_tag_names
|
26
|
+
belongs_to :color, class_name: 'RGB::Color', foreign_key: :color_id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
16
30
|
RSpec.configure do |config|
|
17
31
|
config.after do
|
18
32
|
DatabaseCleaner.strategy = :truncation
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-searchable_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
375
375
|
- !ruby/object:Gem::Version
|
376
376
|
version: '0'
|
377
377
|
requirements: []
|
378
|
-
rubygems_version: 3.
|
378
|
+
rubygems_version: 3.0.8
|
379
379
|
signing_key:
|
380
380
|
specification_version: 4
|
381
381
|
summary: Use searchable selects based on Select2 in Active Admin forms and filters.
|