Commit 3f27c163 authored by Jérome Perrin's avatar Jérome Perrin

Input_viewDebugJson: Allow to edit invalid JSON

Too easy to save invalid JSON
parent 2fadb4a4
......@@ -42,9 +42,8 @@
"_attachment": "body.json"
})
.push(function (result_json) {
var jsonTextArea = gadget.props.element.querySelector(".json"),
document = JSON.parse(result_json);
jsonTextArea.textContent = JSON.stringify(document, undefined, " ");
var jsonTextArea = gadget.props.element.querySelector(".json");
jsonTextArea.textContent = result_json;
gadget.props.codemirror = CodeMirror.fromTextArea(jsonTextArea, {
lineNumbers: true,
mode: {name: 'javascript', json: true},
......
......@@ -365,7 +365,22 @@
.push(function(result) {
var data;
if (result) {
data = JSON.parse(result);
try {
data = JSON.parse(result);
} catch (error) {
portal_type = "Input";
options.action = "debug";
portal_types.Input = {
"debug": {
"gadget": "Input_viewDebugJson",
"type": "object_view",
"title": "Emergency Mode, JSON cannot be parsed"
}
};
return gadget.declareGadget(
"Input_viewDebugJson.html"
);
}
gadget.props.data = data;
portal_types.Input = data.application_configuration.input;
portal_types.Output = data.application_configuration.output;
......
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