rails_admin_selectize 2.0.2 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/views/rails_admin/main/_form_selectize.html.haml +6 -7
- data/lib/rails_admin_selectize/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc45591ce07625cb68f08522f8bb067d47dfe6718158ae9fba06bc23d3a36b91
|
4
|
+
data.tar.gz: 7e0d1f1b2c7e43736bfd336831385ca9da39f52de463c73ef65077ebb31d889f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fcac0768829bf0225f1d8e07b7bb7fb03da9359f238f78c23daa991eec519d34f5b636145cd45207b0a23432f5b9572a9ae9169baadee885da54ff5c4d0e15b
|
7
|
+
data.tar.gz: 8386e917a769900df71c19c3ae05d60a253cb0c1920f88df5304422a159e59fd35cfcd9ec7c93d75d6e648592011c2577df63d6105d33aa777c13ce13f31b746
|
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
|
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.
|
@@ -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:
|
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,17 +37,16 @@
|
|
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
|
-
|
43
|
-
if (
|
44
|
-
|
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
|
-
|
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 =
|
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);
|
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.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|