rails_admin_json_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.
- checksums.yaml +4 -4
- data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor.html.erb +3 -3
- data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_component.html.erb +0 -0
- data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_dropdown.html.erb +0 -0
- data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_picker.html.erb +0 -0
- data/lib/rails_admin_json_editor.rb +89 -1
- data/lib/rails_admin_json_editor/version.rb +1 -1
- metadata +5 -6
- data/config/initializers/rails_admin_json_editor.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01c93bdbdbf58e5bf96c69ffcc97b8b2f9c2d958
|
4
|
+
data.tar.gz: 2f6d605a53538e835f1be27a06b08969ef3b652b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7e795801be80e52cd528e5a314a53a2bb3e5e0e5fa8c461d08d51e5b6f75b4a5b81f2c1f59053e448c3dd50d59dd0b8c5bd7795ceeaa97ce307d6a6d6c47ae3
|
7
|
+
data.tar.gz: e19f1d088d5d274da9232c98ce32149f62f7ac26e814df1df1f97bfebdf2c271d1c91f0f8cf9e6ec07bedd0699bad2654af5f9b7ff45c3156f3e001f5c920820
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<div ref="components_json" class="components_json">
|
7
7
|
<div v-repeat="components" class="component">
|
8
8
|
<% field.components.each do |component| %>
|
9
|
-
<%= render 'form_json_editor_component', locals: { component: component } %>
|
9
|
+
<%= render 'rails_admin_json_editor/main/form_json_editor_component', locals: { component: component } %>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
12
12
|
|
13
|
-
<%= render 'form_json_editor_dropdown', locals: { components: field.components } %>
|
13
|
+
<%= render 'rails_admin_json_editor/main/form_json_editor_dropdown', locals: { components: field.components } %>
|
14
14
|
|
15
15
|
<%= form.text_area field.name, 'v-model' => 'components', cols:50, rows:10, style: 'margin-top:40px' %>
|
16
16
|
</div>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
.flatten
|
21
21
|
.select { |f| f.picker_records != nil }
|
22
22
|
.each do |f| %>
|
23
|
-
<%= render 'form_json_editor_picker', locals: { field:f } %>
|
23
|
+
<%= render 'rails_admin_json_editor/main/form_json_editor_picker', locals: { field:f } %>
|
24
24
|
<% end %>
|
25
25
|
|
26
26
|
<script type="text/javascript">
|
data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_component.html.erb
RENAMED
File without changes
|
data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_dropdown.html.erb
RENAMED
File without changes
|
data/app/views/{rails_admin → rails_admin_json_editor}/main/_form_json_editor_picker.html.erb
RENAMED
File without changes
|
@@ -1,5 +1,93 @@
|
|
1
1
|
require "rails_admin_json_editor/version"
|
2
2
|
|
3
3
|
module RailsAdminJsonEditor
|
4
|
-
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rails_admin/config/fields/types/text'
|
9
|
+
|
10
|
+
module RailsAdmin
|
11
|
+
module Config
|
12
|
+
module Fields
|
13
|
+
module Types
|
14
|
+
class JsonEditor < RailsAdmin::Config::Fields::Types::Text
|
15
|
+
# Register field type for the type loader
|
16
|
+
RailsAdmin::Config::Fields::Types.register(self)
|
17
|
+
|
18
|
+
register_instance_option :render do
|
19
|
+
bindings[:view].render partial: "rails_admin_json_editor/main/form_json_editor", locals: {field: self, form: bindings[:form]}
|
20
|
+
end
|
21
|
+
|
22
|
+
register_instance_option :components do
|
23
|
+
@components
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup
|
27
|
+
@components = []
|
28
|
+
yield if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def component(type)
|
32
|
+
component = Component.new(type)
|
33
|
+
|
34
|
+
yield(component) if block_given?
|
35
|
+
|
36
|
+
@components << component
|
37
|
+
end
|
38
|
+
|
39
|
+
class Component
|
40
|
+
attr_accessor :type, :fields
|
41
|
+
attr_accessor :label, :help
|
42
|
+
|
43
|
+
def initialize(type)
|
44
|
+
@type = type
|
45
|
+
@fields = []
|
46
|
+
@label = type
|
47
|
+
end
|
48
|
+
|
49
|
+
def field(name, type)
|
50
|
+
field = Field.new(name, type)
|
51
|
+
|
52
|
+
yield(field) if block_given?
|
53
|
+
|
54
|
+
@fields << field
|
55
|
+
end
|
56
|
+
|
57
|
+
def label(s = nil)
|
58
|
+
if s.nil? then return @label else @label = s end
|
59
|
+
end
|
60
|
+
|
61
|
+
def help(s = nil)
|
62
|
+
if s.nil? then return @help else @help = s end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Field
|
67
|
+
attr_accessor :name, :type
|
68
|
+
attr_accessor :label, :help
|
69
|
+
attr_accessor :picker_records
|
70
|
+
|
71
|
+
def initialize(name, type)
|
72
|
+
@name = name
|
73
|
+
@type = type
|
74
|
+
@label = name
|
75
|
+
end
|
76
|
+
|
77
|
+
def label(s = nil)
|
78
|
+
if s.nil? then return @label else @label = s end
|
79
|
+
end
|
80
|
+
|
81
|
+
def help(s = nil)
|
82
|
+
if s.nil? then return @help else @help = s end
|
83
|
+
end
|
84
|
+
|
85
|
+
def picker_records(a = nil)
|
86
|
+
if a.nil? then return @picker_records else @picker_records = a end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
5
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_json_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jasper Haggenburg
|
@@ -65,11 +65,10 @@ files:
|
|
65
65
|
- LICENSE.txt
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
|
-
- app/views/
|
69
|
-
- app/views/
|
70
|
-
- app/views/
|
71
|
-
- app/views/
|
72
|
-
- config/initializers/rails_admin_json_editor.rb
|
68
|
+
- app/views/rails_admin_json_editor/main/_form_json_editor.html.erb
|
69
|
+
- app/views/rails_admin_json_editor/main/_form_json_editor_component.html.erb
|
70
|
+
- app/views/rails_admin_json_editor/main/_form_json_editor_dropdown.html.erb
|
71
|
+
- app/views/rails_admin_json_editor/main/_form_json_editor_picker.html.erb
|
73
72
|
- lib/rails_admin_json_editor.rb
|
74
73
|
- lib/rails_admin_json_editor/version.rb
|
75
74
|
- rails_admin_json_editor.gemspec
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'rails_admin/config/fields/types/text'
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Config
|
5
|
-
module Fields
|
6
|
-
module Types
|
7
|
-
class JsonEditor < RailsAdmin::Config::Fields::Types::Text
|
8
|
-
# Register field type for the type loader
|
9
|
-
RailsAdmin::Config::Fields::Types.register(self)
|
10
|
-
|
11
|
-
register_instance_option :partial do
|
12
|
-
:form_json_editor
|
13
|
-
end
|
14
|
-
|
15
|
-
register_instance_option :components do
|
16
|
-
@components
|
17
|
-
end
|
18
|
-
|
19
|
-
def setup
|
20
|
-
@components = []
|
21
|
-
yield if block_given?
|
22
|
-
end
|
23
|
-
|
24
|
-
def component(type)
|
25
|
-
component = Component.new(type)
|
26
|
-
|
27
|
-
yield(component) if block_given?
|
28
|
-
|
29
|
-
@components << component
|
30
|
-
end
|
31
|
-
|
32
|
-
class Component
|
33
|
-
attr_accessor :type, :fields
|
34
|
-
attr_accessor :label, :help
|
35
|
-
|
36
|
-
def initialize(type)
|
37
|
-
@type = type
|
38
|
-
@fields = []
|
39
|
-
@label = type
|
40
|
-
end
|
41
|
-
|
42
|
-
def field(name, type)
|
43
|
-
field = Field.new(name, type)
|
44
|
-
|
45
|
-
yield(field) if block_given?
|
46
|
-
|
47
|
-
@fields << field
|
48
|
-
end
|
49
|
-
|
50
|
-
def label(s = nil)
|
51
|
-
if s.nil? then return @label else @label = s end
|
52
|
-
end
|
53
|
-
|
54
|
-
def help(s = nil)
|
55
|
-
if s.nil? then return @help else @help = s end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class Field
|
60
|
-
attr_accessor :name, :type
|
61
|
-
attr_accessor :label, :help
|
62
|
-
attr_accessor :picker_records
|
63
|
-
|
64
|
-
def initialize(name, type)
|
65
|
-
@name = name
|
66
|
-
@type = type
|
67
|
-
@label = name
|
68
|
-
end
|
69
|
-
|
70
|
-
def label(s = nil)
|
71
|
-
if s.nil? then return @label else @label = s end
|
72
|
-
end
|
73
|
-
|
74
|
-
def help(s = nil)
|
75
|
-
if s.nil? then return @help else @help = s end
|
76
|
-
end
|
77
|
-
|
78
|
-
def picker_records(a = nil)
|
79
|
-
if a.nil? then return @picker_records else @picker_records = a end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|