activeadmin_hstore_editor 0.0.2 → 0.0.3
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.
- data/Gemfile.lock +1 -1
- data/README.md +17 -0
- data/app/assets/stylesheets/active_admin/hstore_editor.css +1 -0
- data/app/inputs/hstore_input.rb +0 -2
- data/lib/activeadmin/hstore_editor.rb +12 -0
- data/lib/activeadmin/hstore_editor/version.rb +1 -1
- data/lib/activeadmin/resource_dsl.rb +10 -2
- metadata +21 -15
- checksums.yaml +0 -7
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,6 +17,14 @@ Or install it yourself as:
|
|
17
17
|
|
18
18
|
$ gem install activeadmin_hstore_editor
|
19
19
|
|
20
|
+
Include styles in "active_admin.css.scss"
|
21
|
+
|
22
|
+
*= require active_admin/hstore_editor
|
23
|
+
|
24
|
+
Include javascripts in "active_admin.js"
|
25
|
+
|
26
|
+
//= require active_admin/hstore_editor
|
27
|
+
|
20
28
|
## Usage
|
21
29
|
|
22
30
|
This Gem provides you formtastic input called :hstore to edit hstore data and parse form data for store it
|
@@ -39,6 +47,15 @@ ActiveAdmin.register User do
|
|
39
47
|
end
|
40
48
|
```
|
41
49
|
|
50
|
+
If you add validation for hstore keys and want to see validation error in active admin
|
51
|
+
```ruby
|
52
|
+
form do |f|
|
53
|
+
f.semantic_errors *f.object.errors.keys
|
54
|
+
f.inputs
|
55
|
+
f.actions
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
42
59
|
## Contributing
|
43
60
|
|
44
61
|
1. Fork it ( http://github.com/wild-ex/activeadmin_hstore_editor/fork )
|
data/app/inputs/hstore_input.rb
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
class HstoreInput < Formtastic::Inputs::TextInput
|
4
4
|
def to_html
|
5
5
|
html = '<div class="jsoneditor-wrap">'
|
6
|
-
Rails.logger.error '#' * 10
|
7
|
-
Rails.logger.error method
|
8
6
|
current_value = @object.public_send method
|
9
7
|
html << builder.text_area(method, input_html_options.merge(
|
10
8
|
value: (current_value.respond_to?(:to_json) ? current_value.to_json : '')))
|
@@ -5,6 +5,18 @@ require "activeadmin/resource_dsl"
|
|
5
5
|
module ActiveAdmin
|
6
6
|
module HstoreEditor
|
7
7
|
class Engine < ::Rails::Engine
|
8
|
+
config.assets.precompile += %w[img/jsoneditor-icons.png]
|
9
|
+
|
10
|
+
rake_tasks do
|
11
|
+
task 'assets:precompile' do
|
12
|
+
fingerprint = /\-[0-9a-f]{32}\./
|
13
|
+
Dir['public/assets/img/jsoneditor-icons-*'].each do |file|
|
14
|
+
next unless file =~ fingerprint
|
15
|
+
nondigest = file.sub fingerprint, '.'
|
16
|
+
FileUtils.cp file, nondigest, verbose: true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
8
20
|
end
|
9
21
|
end
|
10
22
|
end
|
@@ -5,10 +5,18 @@ module ActiveAdmin
|
|
5
5
|
class ResourceDSL
|
6
6
|
def hstore_editor
|
7
7
|
before_save do |object,args|
|
8
|
-
request_namespace = object.class.name.underscore
|
8
|
+
request_namespace = object.class.name.underscore.gsub('/', '_')
|
9
9
|
if params.key? request_namespace
|
10
10
|
object.class.columns_hash.select {|key,attr| attr.type == :hstore}.keys.each do |key|
|
11
|
-
|
11
|
+
if params[request_namespace].key? key
|
12
|
+
json_data = params[request_namespace][key]
|
13
|
+
data = if json_data == 'null' or json_data.blank?
|
14
|
+
{}
|
15
|
+
else
|
16
|
+
JSON.parse(json_data)
|
17
|
+
end
|
18
|
+
object.attributes = {key => data}
|
19
|
+
end
|
12
20
|
end
|
13
21
|
else
|
14
22
|
raise ActionController::ParameterMissing, request_namespace
|
metadata
CHANGED
@@ -1,51 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_hstore_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- wild
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.5'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.5'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: railties
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '3.0'
|
34
|
-
- -
|
38
|
+
- - <
|
35
39
|
- !ruby/object:Gem::Version
|
36
40
|
version: '5.0'
|
37
41
|
type: :runtime
|
38
42
|
prerelease: false
|
39
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
40
45
|
requirements:
|
41
|
-
- -
|
46
|
+
- - ! '>='
|
42
47
|
- !ruby/object:Gem::Version
|
43
48
|
version: '3.0'
|
44
|
-
- -
|
49
|
+
- - <
|
45
50
|
- !ruby/object:Gem::Version
|
46
51
|
version: '5.0'
|
47
|
-
description: '"hstore_input" field allow to edit hstore value as json array with
|
48
|
-
jsoneditor.js from http://jsoneditoronline.org'
|
52
|
+
description: ! '"hstore_input" field allow to edit hstore value as json array with
|
53
|
+
using jsoneditor.js from http://jsoneditoronline.org'
|
49
54
|
email:
|
50
55
|
- wild.exe@gmail.com
|
51
56
|
executables: []
|
@@ -85,26 +90,27 @@ files:
|
|
85
90
|
homepage: https://github.com/wild-r/activeadmin_hstore_editor
|
86
91
|
licenses:
|
87
92
|
- MIT
|
88
|
-
metadata: {}
|
89
93
|
post_install_message:
|
90
94
|
rdoc_options: []
|
91
95
|
require_paths:
|
92
96
|
- lib
|
93
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
94
99
|
requirements:
|
95
|
-
- -
|
100
|
+
- - ! '>='
|
96
101
|
- !ruby/object:Gem::Version
|
97
102
|
version: '0'
|
98
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
99
105
|
requirements:
|
100
|
-
- -
|
106
|
+
- - ! '>='
|
101
107
|
- !ruby/object:Gem::Version
|
102
108
|
version: 1.3.6
|
103
109
|
requirements: []
|
104
110
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
111
|
+
rubygems_version: 1.8.23
|
106
112
|
signing_key:
|
107
|
-
specification_version:
|
113
|
+
specification_version: 3
|
108
114
|
summary: add "hstore_input" field type to active_admin that allow to edit Postgresql
|
109
115
|
hstore values
|
110
116
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: c4cf588dd0226a11a0ce97df2cb2c7707eb0186b
|
4
|
-
data.tar.gz: 782ccf06eebbef748c29eb981bc3499d703cab1f
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 66b2dd78c1cce77d4b8b407a3195f2baeb7cab2420f6f4bc9f4de7f36c29c4825bc02f15b3792a254e6a4a133b419f060da7af5d85086e1bb4562b1ea17dd723
|
7
|
-
data.tar.gz: 58cb56ea9bc3992e9fea9dddf54329c4da49e6d50cfa752f338dcff3e037150b36c3fe4527af4853fab6ecefc63b93de6bcc23fae86fefef44d42efcb30901dd
|