administrate-field-list 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 303f3e89962aeef52297980acdc98f7e1259ddfa
4
- data.tar.gz: 2bedd7501b0e88ff3a82bfb4b1030aaebcef80b5
3
+ metadata.gz: 8ff45d82552535f70bf04829c462a66d76b9318f
4
+ data.tar.gz: 86f6895c7ff9534925fc78d14f736962dab4dd57
5
5
  SHA512:
6
- metadata.gz: 8d8b1b66699bcd20417194093632da30a75857b46d13230ef88610e1c6d97501c76d5ed237c01f2e442890d69a8744527e2bdc23685909f566ad4b5ba3df38eb
7
- data.tar.gz: 6dc7fb41fc123298e29a0ecb851e22e46f4d88524eee5f28fa7b2415a4611177604181384aa4d793e7dadff03b3e47c7be02ac4488dcbc557eecc0c02be3bed2
6
+ metadata.gz: 4c26cf0dad9ea3604b306ca7111b64c2a9004bf6429d1e1e275408a93fc70b21cc547092111453317d1338951ae0510f3392c7ab059605ec4383f42740e79a7e
7
+ data.tar.gz: 681a0f9f589774807e78c645d2831d24f25c4dd1e729eb70187293f4433c4a23fccc1ff33b2d127851125b8adaef4c6a9e402ad92bac140f9ebc88feb7795a9f
data/README.md CHANGED
@@ -4,7 +4,7 @@ simple plugin in order to be able to view and edit serialized list within Admini
4
4
 
5
5
  ![screenshot](screenshot/screenshot_1.png "screenshot_1")
6
6
 
7
- support serialization type
7
+ supported serialization type
8
8
  - JSON
9
9
 
10
10
  ```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.2"
7
7
  spec.authors = ["potato2003"]
8
8
  spec.email = ["potato2003@gmail.com"]
9
9
 
@@ -2,23 +2,24 @@
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
  %>
16
16
 
17
17
  <% end %>
18
18
 
19
- <%= text_field_tag(
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,16 @@
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 %>'
36
+ var $f = $(group_selector).parents('form');
37
37
 
38
38
  document.addEventListener("DOMContentLoaded", function(evt) {
39
39
 
40
- var $f = $(hidden).parents('form');
41
40
  $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 });
46
-
47
- $(hidden).val(JSON.stringify(vals));
41
+ // Filter empty fileds before submit
42
+ $(group_selector).filter(function() {
43
+ return !this.value;
44
+ }).removeAttr('name');
48
45
  });
49
46
  });
50
47
  })()
@@ -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.2
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: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate