Commit 17066fa5 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: JSON Editor receives a string rather them a json

parent e10a0e3c
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"use strict"; "use strict";
var DISPLAY_JSON_FORM = 'display_json_form', var DISPLAY_JSON_FORM = 'display_json_form',
DISPLAY_RAW_XML = 'display_raw_xml'; DISPLAY_RAW_XML = 'display_raw_xml',
PARAMETER_KEY = 'parameter_key';
////////////////////////////////////////// //////////////////////////////////////////
// ParserError // ParserError
...@@ -130,6 +131,12 @@ ...@@ -130,6 +131,12 @@
.push(function (gadget) { .push(function (gadget) {
return gadget.getContent(); return gadget.getContent();
}) })
.push(function (json_dict) {
if (json_dict && (json_dict[PARAMETER_KEY] !== undefined)) {
return JSON.parse(json_dict[PARAMETER_KEY]);
}
return {};
})
.push(function (json_dict) { .push(function (json_dict) {
var parameter_hash_input = g.element.querySelectorAll('.parameter_hash_output')[0], var parameter_hash_input = g.element.querySelectorAll('.parameter_hash_output')[0],
serialisation_type = getSerialisationTypeFromForm(g.element), serialisation_type = getSerialisationTypeFromForm(g.element),
...@@ -442,13 +449,14 @@ ...@@ -442,13 +449,14 @@
prefix = json_url.split(json_url_uri.path())[0] + prefix.join("/"); prefix = json_url.split(json_url_uri.path())[0] + prefix.join("/");
parameter_json_schema_url = prefix + "/" + parameter_json_schema_url; parameter_json_schema_url = prefix + "/" + parameter_json_schema_url;
} }
// loadJSONSchema is there to ensure that the JSON from a proper serialisation
//
return gadget.loadJSONSchema(parameter_json_schema_url, serialisation) return gadget.loadJSONSchema(parameter_json_schema_url, serialisation)
.push(function (json) { .push(function () {
// Reset failover text area // Reset failover text area
domsugar(gadget.element.querySelector('div.failover-textarea')); domsugar(gadget.element.querySelector('div.failover-textarea'));
return gadget.renderSubForm( return gadget.renderSubForm(
parameter_json_schema_url, parameter_json_schema_url,
json,
parameter_dict, parameter_dict,
editable editable
); );
...@@ -489,13 +497,14 @@ ...@@ -489,13 +497,14 @@
}); });
}) })
.declareMethod("renderSubForm", function (parameter_json_schema_url, json_field, default_dict, editable) { .declareMethod("renderSubForm", function (parameter_json_schema_url, default_dict, editable) {
return this.getDeclaredGadget('json_form') return this.getDeclaredGadget('json_form')
.push(function (gadget) { .push(function (gadget) {
return gadget.render({ return gadget.render({
schema_url: parameter_json_schema_url, schema_url: parameter_json_schema_url,
json_field: json_field, key: PARAMETER_KEY,
default_dict: default_dict, // value is always string
value: JSON.stringify(default_dict),
editable: editable editable: editable
}); });
}); });
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>ref-parser.min.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment