activeadmin-searchable_select 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86f2b11107d464955292c9d5a51629757ff3fb213aafdeb9302b948f421796ee
4
- data.tar.gz: 961efac5444a994afac0b8a13437bbd96ec8effedbbc6356b606a9d23bc80849
3
+ metadata.gz: afca3ffb2bd7868c51afc6e6793fc4b3080a1fdb0f92a248ccdbe264faa58597
4
+ data.tar.gz: defeafa115233119aacc2bde15424810bdd1fd05187c2c48536879586b96b00b
5
5
  SHA512:
6
- metadata.gz: 79b204c1f6af56e2d39c4ee658cfde5af5ca31733ed3d2eb657ab78a8de66511b9e7387dd5fa64a457768095c67858e64f3fd598058ef1458fceba0575880522
7
- data.tar.gz: 9bcbd53a3504788a0c18ce8f701efefcc2f0495625eedf277a30c738c5083d4b3a4602fdd95c05ca904ad8b0034e551ea1706a46f077805c5b0146f0121ee2fc
6
+ metadata.gz: 527c21ae72869785419007a81436186684d589e87abc4aeb64213a8fe46af2ca1701e98296f8d2a9c64c756a9331a625aac166994591a57d1c43c70cf277ccb0
7
+ data.tar.gz: 71f29f997879afec190f430697d57362dba21802e322b8045d20b247f3c1ef0df8ed8b88b0a84a4e43910dda1ef9221050e8843fac45133b3c9fd15defe028be
data/CHANGELOG.md CHANGED
@@ -1,14 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 1.6.0
3
+ ### Version 1.7.0
4
4
 
5
- 2022-04-05
5
+ 2023-05-03
6
6
 
7
- [Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-5-stable...v1.6.0)
7
+ [Compare changes](https://github.com/codevise/activeadmin-searchable_select/compare/1-6-stable...v1.7.0)
8
8
 
9
- - Add option to pass path params for nested resource fetching
10
- ([#39](https://github.com/codevise/activeadmin-searchable_select/pull/39))
9
+ - Fix pre-selected item when using belongs_to
10
+ ([#43](https://github.com/codevise/activeadmin-searchable_select/pull/43),
11
+ [#44](https://github.com/codevise/activeadmin-searchable_select/pull/44))
12
+ - Improvement the examples in Readme for import npm assets
13
+ ([#41](https://github.com/codevise/activeadmin-searchable_select/pull/41))
11
14
 
12
15
  See
13
- [1-5-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-5-stable/CHANGELOG.md)
16
+ [1-6-stable branch](https://github.com/codevise/activeadmin-searchable_select/blob/1-6-stable/CHANGELOG.md)
14
17
  for previous changes.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ActiveAdmin Searchable Select
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/activeadmin-searchable_select.svg)](http://badge.fury.io/rb/activeadmin-searchable_select)
4
+ [![NPM Version](https://badge.fury.io/js/@codevise%2Factiveadmin-searchable_select.svg)](https://badge.fury.io/js/@codevise%2Factiveadmin-searchable_select)
5
+ [![npm](https://img.shields.io/npm/dm/@codevise/activeadmin-searchable_select)](https://www.npmjs.com/package/@codevise/activeadmin-searchable_select)
4
6
  [![Build Status](https://github.com/codevise/activeadmin-searchable_select.svg?branch=master)](https://github.com/codevise/activeadmin-searchable_select/actions)
5
7
 
6
8
  Searchable select boxes (via [Select2](https://select2.org/)) for
@@ -15,6 +17,7 @@ Add `activeadmin-searchable_select` to your Gemfile:
15
17
  gem 'activeadmin-searchable_select'
16
18
  ```
17
19
 
20
+ ##### Using assets via Sprockets
18
21
  Import stylesheets and require javascripts:
19
22
 
20
23
  ```scss
@@ -27,6 +30,39 @@ Import stylesheets and require javascripts:
27
30
  //= require active_admin/searchable_select
28
31
  ```
29
32
 
33
+ ##### Using assets via Webpacker (or any other assets bundler) as a NPM module (Yarn package)
34
+
35
+ Execute:
36
+
37
+ $ npm i @codevise/activeadmin-searchable_select
38
+
39
+ Or
40
+
41
+ $ yarn add @codevise/activeadmin-searchable_select
42
+
43
+ Or add manually to `package.json`:
44
+
45
+ ```json
46
+ "dependencies": {
47
+ "@codevise/activeadmin-searchable_select": "1.6.0"
48
+ }
49
+ ```
50
+ and execute:
51
+
52
+ $ yarn
53
+
54
+ Add the following line into `app/javascript/active_admin.js`:
55
+
56
+ ```javascript
57
+ import '@codevise/activeadmin-searchable_select';
58
+ ```
59
+
60
+ Add the following line into `app/javascript/stylesheets/active_admin.scss`:
61
+
62
+ ```css
63
+ @import '@codevise/activeadmin-searchable_select';
64
+ ```
65
+
30
66
  ## Usage
31
67
 
32
68
  ### Making Select Boxes Searchable
@@ -0,0 +1,2 @@
1
+ import 'select2';
2
+ import './searchable_select/init';
@@ -84,7 +84,7 @@ module ActiveAdmin
84
84
  end
85
85
 
86
86
  def option_collection_scope
87
- option_collection.scope(template, ajax_params)
87
+ option_collection.scope(template, path_params.merge(ajax_params))
88
88
  end
89
89
 
90
90
  def option_collection
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module SearchableSelect
3
- VERSION = '1.6.0'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
5
5
  end
data/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@codevise/activeadmin-searchable_select",
3
+ "version": "1.7.0",
4
+ "description": "Use searchable selects based on Select2 in Active Admin forms and filters.",
5
+ "main": "src/searchable_select.js",
6
+ "style": "src/searchable_select.scss",
7
+ "repository": "git@github.com:codevise/activeadmin-searchable_select.git",
8
+ "author": "Codevise Solutions Ltd <info@codevise.de>",
9
+ "license": "MIT",
10
+ "private": false,
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/codevise/activeadmin-searchable_select.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/codevise/activeadmin-searchable_select/issues"
17
+ },
18
+ "homepage": "https://github.com/codevise/activeadmin-searchable_select#readme",
19
+ "keywords": [
20
+ "select2",
21
+ "active",
22
+ "admin",
23
+ "searchable",
24
+ "select"
25
+ ],
26
+ "dependencies": {
27
+ "jquery": ">= 3.0, < 5",
28
+ "select2": "~> 4.0"
29
+ },
30
+ "files": [
31
+ "src/**/*"
32
+ ],
33
+ "scripts": {
34
+ "prepare_javascripts_src": "rm -rf src && cp -R app/assets/javascripts/active_admin/ src && mv src/searchable_select_pack.js src/searchable_select.js",
35
+ "prepare_stylesheets_src": "cp -R app/assets/stylesheets/active_admin/* src",
36
+ "prepublishOnly": "npm run prepare_javascripts_src && npm run prepare_stylesheets_src"
37
+ }
38
+ }
@@ -180,6 +180,22 @@ RSpec.describe 'end to end', type: :feature, js: true do
180
180
  expect(select_box_items.size).to eq(15)
181
181
  end
182
182
  end
183
+
184
+ describe 'edit page with searchable select filter' do
185
+ it 'preselects item' do
186
+ option_type = OptionType.create(name: 'Color')
187
+ ot = OptionType.create(name: 'Size')
188
+ option_value = OptionValue.create(value: 'Black', option_type: option_type)
189
+ OptionValue.create(value: 'Orange', option_type: option_type)
190
+ OptionValue.create(value: 'M', option_type: ot)
191
+ product = Product.create(name: 'Cap', option_type: option_type)
192
+ variant = Variant.create(product: product, option_value: option_value)
193
+
194
+ visit "/admin/products/#{product.id}/variants/#{variant.id}/edit"
195
+
196
+ expect(select_box_selected_item_text).to eq('Black')
197
+ end
198
+ end
183
199
  end
184
200
 
185
201
  def expand_select_box
@@ -198,6 +214,10 @@ RSpec.describe 'end to end', type: :feature, js: true do
198
214
  all('.select2-dropdown li').map(&:text)
199
215
  end
200
216
 
217
+ def select_box_selected_item_text
218
+ find('.select2-selection').text
219
+ end
220
+
201
221
  def wait_for_ajax
202
222
  Timeout.timeout(Capybara.default_max_wait_time) do
203
223
  sleep 0.1
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.6.0
4
+ version: 1.7.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: 2022-04-05 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -314,6 +314,7 @@ files:
314
314
  - activeadmin-searchable_select.gemspec
315
315
  - app/assets/javascripts/active_admin/searchable_select.js
316
316
  - app/assets/javascripts/active_admin/searchable_select/init.js
317
+ - app/assets/javascripts/active_admin/searchable_select_pack.js
317
318
  - app/assets/stylesheets/active_admin/searchable_select.scss
318
319
  - bin/rspec
319
320
  - gemfiles/rails_5.1_active_admin_1.x.gemfile
@@ -330,6 +331,7 @@ files:
330
331
  - lib/activeadmin/searchable_select/resource_extension.rb
331
332
  - lib/activeadmin/searchable_select/select_input_extension.rb
332
333
  - lib/activeadmin/searchable_select/version.rb
334
+ - package.json
333
335
  - spec/features/ajax_params_spec.rb
334
336
  - spec/features/end_to_end_spec.rb
335
337
  - spec/features/filter_input_spec.rb
@@ -375,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
377
  - !ruby/object:Gem::Version
376
378
  version: '0'
377
379
  requirements: []
378
- rubygems_version: 3.0.8
380
+ rubygems_version: 3.2.3
379
381
  signing_key:
380
382
  specification_version: 4
381
383
  summary: Use searchable selects based on Select2 in Active Admin forms and filters.