administrate-field-jsonb 0.4.0 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f063b7cfbb398bbce63a6be7cb36600c9eb1855b
4
- data.tar.gz: 4d6546c1ad1d4fa2b044143af2718b401543d3d2
2
+ SHA256:
3
+ metadata.gz: 4d1b00158b771122554eee9bf66a5ea9be2531a154a39599824cca08b2580736
4
+ data.tar.gz: c189cf1d7a7c7599af35a9935c057a6e6a3064cb8bb13c422031b86ad3ad2151
5
5
  SHA512:
6
- metadata.gz: 82b867137242cdcc301d81e95b23f7341db12ed53aaf1340e7547fd8f87dbc05523726fee627c4bf5c677a6636dc56d951e9f7ef7a45b606a2589aad35ea1bab
7
- data.tar.gz: 91b0ed65ecc649447841b0727fb021d811dc9c44d8c4b5e70c0e24c96f561d201e80a1d8fee8a5b447e5db2977f9b766b2ed2873b2107317ed35f3de942f4b9c
6
+ metadata.gz: ef54adbd97f8dfd9151af88e419eb26dd78c88fee1c4b7eebe790c6d4514f24c363f732c348c12789ef268c24b596e96b025717db46829fe9a3a128d535bcb45
7
+ data.tar.gz: 9c2d9180b29c40f42f98b0c73de7b9efa8998cfdd3aeb3b54f8039fd165b761c6bc60c245e11ff1792512a182de6dd6fe646aa9ae658307d10fe29e93ff11788
data/README.md CHANGED
@@ -18,6 +18,15 @@ And then execute:
18
18
  bundle
19
19
  ```
20
20
 
21
+ If you are using asset pipeline, add the following lines to your `manifest.js`:
22
+
23
+ ```js
24
+ //= link administrate-field-jsonb/application.css
25
+ //= link administrate-field-jsonb/application.js
26
+ ```
27
+
28
+ The manifest file is at `app/assets/config` by default.
29
+
21
30
  ## Usage
22
31
 
23
32
  ```ruby
@@ -58,7 +67,18 @@ ATTRIBUTE_TYPES = {
58
67
  }.freeze
59
68
  ```
60
69
 
61
- NOTE: don't define `advanced_view` option if you want to display you JSON with the [jsoneditor](https://github.com/josdejong/jsoneditor).
70
+ NOTE: don't define `advanced_view` option if you want to display JSON with the [jsoneditor](https://github.com/josdejong/jsoneditor).
71
+
72
+ To customize what to display if you have an empty value, use `blank_sign` option, by default it's `-`.
73
+
74
+ ```ruby
75
+ ATTRIBUTE_TYPES = {
76
+ # ...
77
+ details: Field::JSONB.with_options(
78
+ blank_sign: 'oops, missed'
79
+ )
80
+ }.freeze
81
+ ```
62
82
 
63
83
  ## How it looks like
64
84
 
@@ -2,7 +2,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'administrate-field-jsonb'
5
- gem.version = '0.4.0'
5
+ gem.version = '0.4.4'
6
6
  gem.authors = ['Sergey Volkov', 'Codica']
7
7
  gem.email = ['sergvolkov.codica@gmail.com']
8
8
  gem.homepage = 'https://github.com/codica2/administrate-field-jsonb'
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
 
17
17
  gem.add_runtime_dependency 'administrate', '< 1.0.0'
18
- gem.add_runtime_dependency 'rails', '>= 4.2', '< 7'
18
+ gem.add_runtime_dependency 'rails', '>= 4.2'
19
19
 
20
20
  gem.add_development_dependency 'rspec', '~> 3.7'
21
21
  end
@@ -1,5 +1,5 @@
1
- $(function () {
2
- $(".administrate-field-jsonb-accordion").each(function () {
1
+ $(document).on(typeof Turbolinks === 'undefined' ? 'ready' : 'turbolinks:load', function() {
2
+ $(".administrate-field-jsonb-accordion").each(function() {
3
3
  $(this).click(function() {
4
4
  $(this).toggleClass("administrate-field-jsonb-active").next().toggle();
5
5
  });
@@ -1,6 +1,6 @@
1
- $(function () {
1
+ $(document).on(typeof Turbolinks === 'undefined' ? 'ready' : 'turbolinks:load', function() {
2
2
  let editor, updatedJson;
3
- $('.administrate-jsoneditor').each(function (index) {
3
+ $('.administrate-jsoneditor').each(function(index) {
4
4
 
5
5
  let $current = $(this).find("textarea");
6
6
 
@@ -14,7 +14,7 @@ $(function () {
14
14
 
15
15
  $current.val(JSON.stringify(updatedJson));
16
16
  },
17
- onError: function (err) {
17
+ onError: function(err) {
18
18
  alert(err.toString());
19
19
  },
20
20
  navigationBar: false,
@@ -1,4 +1,4 @@
1
- $(function () {
1
+ $(document).on(typeof Turbolinks === 'undefined' ? 'ready' : 'turbolinks:load', function() {
2
2
  let viewer;
3
3
  $('.administrate-jsoneditor-viewer').each(function (index) {
4
4
 
@@ -1,5 +1,5 @@
1
1
  /*
2
2
  *= require_self
3
- *= require jsoneditor.min
3
+ *= require jsoneditor
4
4
  *= require_tree .
5
5
  */
@@ -1,5 +1,5 @@
1
1
  <% if field.transform.blank? %>
2
- <%= render field.to_partial_path('field'), type: ::Administrate::Field::String, key: field.attribute, value: '' %>
2
+ <%= field.blank_sign %>
3
3
  <% elsif field.advanced_view? %>
4
4
  <dl class='administrate-field-jsonb-wrapper'>
5
5
  <% if field.array? %>
@@ -35,6 +35,10 @@ module Administrate
35
35
  "/fields/jsonb/#{partial}"
36
36
  end
37
37
 
38
+ def blank_sign
39
+ options[:blank_sign] || '-'
40
+ end
41
+
38
42
  class Engine < ::Rails::Engine
39
43
 
40
44
  Administrate::Engine.add_javascript 'administrate-field-jsonb/application'