rails_admin_json_editor 0.0.16 → 0.0.17
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a65e389aa60332a5985918b3fb5040de6a5a2ba
|
4
|
+
data.tar.gz: d5584fdb8db1f3282f81c3aecda24162388343f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca7928ee6aa1187e33a4eaa230836f7bcec8214907d4dd7cc491a1a8203af76dd8dfde2efd19e0da0302292fe3cc4cc50f5a9e6f6ecdda645c7585c56d2223d
|
7
|
+
data.tar.gz: f0f7ba3f72432334cd8284923c125eb5069487107e7cb3b33a07383293942704ed0f24afad8faa7e88e7408b48a444c11550d86383e26add997bc6c4dd406702
|
@@ -14,6 +14,7 @@ $(document).on('rails_admin.dom_ready', function() {
|
|
14
14
|
// Get data
|
15
15
|
var jsonResult = $('[ref=json-editor]').data('json-result');
|
16
16
|
var jsonScheme = $('[ref=json-editor]').data('json-scheme');
|
17
|
+
var enableGuids = $('[ref=json-editor]').data('enable-guids');
|
17
18
|
|
18
19
|
if(!jsonResult) {
|
19
20
|
jsonResult = { components: [] };
|
@@ -79,6 +80,10 @@ $(document).on('rails_admin.dom_ready', function() {
|
|
79
80
|
properties: {}
|
80
81
|
};
|
81
82
|
|
83
|
+
if(enableGuids) {
|
84
|
+
obj.guid = guid();
|
85
|
+
}
|
86
|
+
|
82
87
|
clonedproperties[target].push(obj);
|
83
88
|
this.parentComponents[this.parentIndex].properties = clonedproperties;
|
84
89
|
},
|
@@ -124,6 +129,11 @@ $(document).on('rails_admin.dom_ready', function() {
|
|
124
129
|
properties: {}
|
125
130
|
};
|
126
131
|
|
132
|
+
console.log('enableGuids', enableGuids);
|
133
|
+
if(enableGuids) {
|
134
|
+
obj.guid = guid();
|
135
|
+
}
|
136
|
+
|
127
137
|
this.components.push(obj);
|
128
138
|
}
|
129
139
|
},
|
@@ -135,3 +145,13 @@ $(document).on('rails_admin.dom_ready', function() {
|
|
135
145
|
components: components
|
136
146
|
});
|
137
147
|
});
|
148
|
+
|
149
|
+
function guid() {
|
150
|
+
'use strict';
|
151
|
+
function s4() {
|
152
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
153
|
+
.toString(16)
|
154
|
+
.substring(1);
|
155
|
+
}
|
156
|
+
return s4() + s4();
|
157
|
+
}
|
@@ -4,22 +4,26 @@
|
|
4
4
|
<div ref="json-editor"
|
5
5
|
class="json-editor"
|
6
6
|
data-json-result='<%= field.value.blank? ? '{ "components":[] }' : field.value %>'
|
7
|
-
data-json-scheme='{ "models":<%= raw field.models.to_json %> }'
|
7
|
+
data-json-scheme='{ "models":<%= raw field.models.to_json %> }'
|
8
|
+
data-enable-guids="<%= field.guids ? 'true' : 'false' %>" >
|
8
9
|
|
9
10
|
<% field.models.each do |model| %>
|
10
11
|
<script type="text/x-template" id="template-fields-for-<%= model.name %>">
|
11
12
|
<div class="component">
|
12
13
|
<legend>
|
13
14
|
<%= model.label %>
|
15
|
+
{{ component.guid ? ' - ' + component.guid : null }}
|
14
16
|
|
15
17
|
<div class="btn-group btn-group-sm pull-right">
|
16
|
-
|
17
|
-
<
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
<
|
22
|
-
|
18
|
+
<% if field.orderable %>
|
19
|
+
<button v-on="click: moveUp" type="button" class="btn btn-default {{ moveUpEnabled ? '' : 'disabled' }}">
|
20
|
+
<i class="icon-circle-arrow-up"></i>
|
21
|
+
</button>
|
22
|
+
|
23
|
+
<button v-on="click: moveDown" type="button" class="btn btn-default {{ moveDownEnabled ? '' : 'disabled' }}">
|
24
|
+
<i class="icon-circle-arrow-down"></i>
|
25
|
+
</button>
|
26
|
+
<% end %>
|
23
27
|
|
24
28
|
<button v-on="click: expanded = !expanded" type="button" class="btn btn-default">
|
25
29
|
<i class="{{ expanded ? 'icon-resize-small' : 'icon-resize-full' }}"></i>
|
@@ -28,6 +28,14 @@ module RailsAdmin
|
|
28
28
|
yield if block_given?
|
29
29
|
end
|
30
30
|
|
31
|
+
def orderable(o = nil)
|
32
|
+
if o.nil? then return @orderable else @orderable = o end
|
33
|
+
end
|
34
|
+
|
35
|
+
def guids(o = nil)
|
36
|
+
if o.nil? then return @guids else @guids = o end
|
37
|
+
end
|
38
|
+
|
31
39
|
def model(m)
|
32
40
|
model = Model.new(m)
|
33
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jasper Haggenburg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|