administrate-field-list 0.0.1 → 0.0.6

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
- SHA1:
3
- metadata.gz: 303f3e89962aeef52297980acdc98f7e1259ddfa
4
- data.tar.gz: 2bedd7501b0e88ff3a82bfb4b1030aaebcef80b5
2
+ SHA256:
3
+ metadata.gz: bdf42933191292d2a3bd8444f4a1b8104e837161fd74672ad7f823ff7ccd40e9
4
+ data.tar.gz: 6e3350968ff3f043392d131996549fb700e204fb54943a05c019bfb4df5275dd
5
5
  SHA512:
6
- metadata.gz: 8d8b1b66699bcd20417194093632da30a75857b46d13230ef88610e1c6d97501c76d5ed237c01f2e442890d69a8744527e2bdc23685909f566ad4b5ba3df38eb
7
- data.tar.gz: 6dc7fb41fc123298e29a0ecb851e22e46f4d88524eee5f28fa7b2415a4611177604181384aa4d793e7dadff03b3e47c7be02ac4488dcbc557eecc0c02be3bed2
6
+ metadata.gz: c83345cd07efe08068e7bc4aac4014807b0bd4d48016a0781e8bbb4be161aa882523684ac9ea0798c77264ad0a6073d8a9680cb56479110e10d3e4889c2cbef7
7
+ data.tar.gz: 139c062738f1b038879a3495a3eba8980c2c4964ff4360b66b97b3649ebac9785a29fd034a16cf94fd84027786e38758990082b81ea2ade21863f5d3b61f50be
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
+ [![Gem Version](https://badge.fury.io/rb/administrate-field-list.svg)](https://badge.fury.io/rb/administrate-field-list)
2
+
1
3
  # Administrate::Field::List
2
4
 
3
5
  simple plugin in order to be able to view and edit serialized list within Administrate
4
6
 
5
7
  ![screenshot](screenshot/screenshot_1.png "screenshot_1")
6
8
 
7
- support serialization type
9
+ supported serialization type
8
10
  - JSON
9
11
 
10
12
  ```ruby
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "administrate-field-list"
6
- spec.version = "0.0.1"
6
+ spec.version = "0.0.6"
7
7
  spec.authors = ["potato2003"]
8
8
  spec.email = ["potato2003@gmail.com"]
9
9
 
@@ -20,9 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_runtime_dependency 'administrate'
23
- spec.add_runtime_dependency 'rails', '>= 5.0', '< 6.0'
23
+ spec.add_runtime_dependency 'rails', '>= 5.0'
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.16"
26
25
  spec.add_development_dependency "rake", "~> 10.0"
27
26
  spec.add_development_dependency "rspec", "~> 3.0"
28
27
  end
@@ -2,14 +2,14 @@
2
2
  <%= f.label field.attribute %>
3
3
  </div>
4
4
  <div class="field-unit__field">
5
- <%= f.hidden_field field.attribute %>
6
5
 
7
6
  <% _group_id = "gid_#{SecureRandom.alphanumeric}" %>
8
- <% field.values.each do |v| %>
9
7
 
8
+ <% field.values.each do |v| %>
10
9
  <%= text_field_tag(
11
10
  nil,
12
11
  v,
12
+ name: "#{f.object_name}[#{field.attribute}][]",
13
13
  class: _group_id,
14
14
  )
15
15
  %>
@@ -19,6 +19,7 @@
19
19
  <%= text_field_tag(
20
20
  nil,
21
21
  '',
22
+ name: "#{f.object_name}[#{field.attribute}][]",
22
23
  class: _group_id,
23
24
  )
24
25
  %>
@@ -31,20 +32,17 @@
31
32
 
32
33
  <script>
33
34
  (function() {
34
- var hiddens = document.querySelectorAll('input[type=hidden]');
35
- var hidden = hiddens[hiddens.length - 1];
36
35
  var group_selector = '.<%= _group_id %>'
37
36
 
38
37
  document.addEventListener("DOMContentLoaded", function(evt) {
39
38
 
40
- var $f = $(hidden).parents('form');
41
- $f.on('submit', function() {
42
- var vals = $(group_selector).map(function() {
43
- return $(this).val();
44
- }).toArray();
45
- vals = vals.filter(function(v) { return v !== '' && v != null });
39
+ var $f = $(group_selector).parents('form');
46
40
 
47
- $(hidden).val(JSON.stringify(vals));
41
+ $f.on('submit', function() {
42
+ // Filter empty fileds before submit
43
+ $(group_selector).filter(function() {
44
+ return !this.value;
45
+ }).removeAttr('name');
48
46
  });
49
47
  });
50
48
  })()
@@ -4,6 +4,10 @@ require 'rails'
4
4
  module Administrate
5
5
  module Field
6
6
  class List < Administrate::Field::Base
7
+ def self.permitted_attribute(attr, _options = nil)
8
+ {attr => []}
9
+ end
10
+
7
11
  def to_s
8
12
  return '-' unless data
9
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - potato2003
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -31,9 +31,6 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '6.0'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -41,23 +38,6 @@ dependencies:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
40
  version: '5.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '6.0'
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.16'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.16'
61
41
  - !ruby/object:Gem::Dependency
62
42
  name: rake
63
43
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
107
  version: '0'
128
108
  requirements: []
129
109
  rubyforge_project:
130
- rubygems_version: 2.6.11
110
+ rubygems_version: 2.7.6
131
111
  signing_key:
132
112
  specification_version: 4
133
113
  summary: simple plugin in order to be able to view and edit serialized list within