rails_admin_selectize 2.0.1 → 2.0.7

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: a694ef611b4a46bdae86d8667c4a2f9667383747ff1dfc38f119bc25b9598a75
4
- data.tar.gz: faa5656472f2a06911d7aed89352474b111582c97eda880df3c78219528833d8
3
+ metadata.gz: c576aa5f3af5bc00a2e99d522848cf6eaea570cd2f1f3cd2b7778a8836133139
4
+ data.tar.gz: 0021a95e6c73eef152d8a1c73936efd35dfda8ea4a12596b3fd6cd63759929c8
5
5
  SHA512:
6
- metadata.gz: 0d1fbe0d298ca1cf3d80d27a4b49470168aea22c83a60fa4a833a8338f1b564772422d6b793ddeb1bc46542e4dd5f399839c145556eb818e95e6f988df830128
7
- data.tar.gz: 2b3d5077539911e27b9a818d52adaf0980fe1efed2f07044203fa868b4835aee36236883e142fe142ba7d89620ab33275eab65dc40729cf3637fcd20b266bcb6
6
+ metadata.gz: e35a56e6d9fbe246b3a4f893af721b2eb099541f19fa3c6d2a0226c15fe8b1fd106a8e38ba239fd0ce2e668c6933a91b03f19d969c3c62f6ca9d9f8c6f143448
7
+ data.tar.gz: f619746152041134957552b1b51a94bfc816d332a900bdb998e1d2b4d3c6bebaa25b6bfa741d2791c5c8f8aab40528fe5c1f7cc20a4dda37c2228b69b3489704
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # RailsAdminSelectize
2
- The default multiselect widget for create and edit forms in [Rails Admin](https://github.com/sferik/rails_admin) is useful, for sure, but some of my custerms find it a bit unpleasant to the eyes. Chatting around with some of them I found they expected, for multi select an approach similar to the normal select, a more streamlined and small element in the page.
2
+ The default multiselect widget for create and edit forms in [Rails Admin](https://github.com/sferik/rails_admin) is useful, for sure, but some of my customers find it a bit unpleasant to the eyes. Chatting around with some of them I found they expected, for multi select an approach similar to the normal select, a more streamlined and small element in the page.
3
3
  Since I used, some time ago, the [selectize.js](https://selectize.github.io/selectize.js/) library, and found it to be full with options and beautiful, I started to look around and find a selectize custom field for Rails Admin, what I found is this [rails_admin_selectize](https://github.com/glyph-fr/rails_admin_selectize), but soon I noticed it was completely abandoned and targeted at very old versions of rails admin, not working in newer versions by just changing the dependency, so I decided to start from scratch and integrate the selectize into the Rails Admin environment one step at a time.
4
4
 
5
5
  This Rails Admin Custom Field is not a fully custimizable selectize implementation, rathere a really straight forward one, aimed at using a selectize Field the KISSier way. I will maintain this and probably add some of the configurations from time to time, when needs arises in one of my future commissions, the code is kept KISS as more as I can, open to further implementations.
@@ -0,0 +1,2 @@
1
+ //= require thecore_ui_commons/thecore
2
+ //= require selectize
@@ -0,0 +1,2 @@
1
+ @import 'selectize';
2
+ @import 'selectize.bootstrap3';
@@ -29,7 +29,7 @@
29
29
  }
30
30
 
31
31
  - selected_ids = (hdv = field.form_default_value).nil? ? selected_ids : hdv
32
- = form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { selectize: true, options: js_data.to_json }, multiple: true, style: 'width:25.5em', class: "form-control pull-left"})
32
+ = form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { selectize: true, options: js_data.to_json }, multiple: true, style: "max-width: max-content", class: "form-control pull-left"})
33
33
 
34
34
  - if authorized?(:new, config.abstract_model) && field.inline_add
35
35
  - path_hash = { model_name: config.abstract_model.to_param, modal: true }
@@ -37,19 +37,19 @@
37
37
  = link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "create btn btn-info", style: 'margin-left:10px'
38
38
 
39
39
  :javascript
40
- const selectizeField = $("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}")
41
40
  // selectizeField.selectize(selectizeField.data('options'))
42
- selectizeField.selectize()
43
- if (selectizeField.parents("#modal").length) {
44
- selectizeField.siblings('.btn').remove();
41
+ $("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}").selectize()
42
+ if ($("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}").parents("#modal").length) {
43
+ $("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}").siblings('.btn').remove();
45
44
  } else {
46
- selectizeField.parents('.control-group').first().remoteForm({success: function(e) {
45
+ $("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}").parents('.control-group').first().remoteForm({success: function(e) {
47
46
  const lastOption = $(this).find("select option").last().first();
48
47
  const value = lastOption.val();
49
48
  const text = lastOption.text()
50
- const selectized = selectizeField[0].selectize;
49
+ const selectized = $("##{field.abstract_model.to_s.parameterize.underscore}_#{field.method_name}")[0].selectize;
51
50
  selectized.addOption({ text: text, value: value });
52
51
  selectized.refreshOptions(false);
53
52
  selectized.addItem(value);
54
53
  }});
54
+
55
55
  }
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSelectize
2
- VERSION = '2.0.1'
2
+ VERSION = "#{`git describe --tags $(git rev-list --tags --max-count=1)`}"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_selectize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -62,8 +62,8 @@ files:
62
62
  - MIT-LICENSE
63
63
  - README.md
64
64
  - Rakefile
65
- - app/assets/javascripts/rails_admin_selectize/thecore_rails_admin.js
66
- - app/assets/stylesheets/rails_admin_selectize/thecore_rails_admin.scss
65
+ - app/assets/javascripts/rails_admin_selectize/index.js
66
+ - app/assets/stylesheets/rails_admin_selectize/index.scss
67
67
  - app/views/rails_admin/main/_form_selectize.html.haml
68
68
  - config/initializers/rails_admin_selectize_app_configs.rb
69
69
  - lib/rails_admin_selectize.rb
@@ -1 +0,0 @@
1
- //= require selectize
@@ -1,3 +0,0 @@
1
-
2
- @import 'selectize';
3
- @import 'selectize.bootstrap3';