Commit 9ba0bebd authored by Boris Kocherov's avatar Boris Kocherov

not use json.parse json.stringify for generation button action

parent d13dae53
......@@ -119,11 +119,14 @@
div_input.appendChild(input);
input = document.createElement("button");
input.value = btoa(JSON.stringify(json_field.patternProperties['.*']));
input.setAttribute("class", "add-sub-form");
input.type = "button";
input.name = path;
input.textContent = "Add";
gadget.props.add_buttons.push({
element: input,
schema_part: json_field.patternProperties['.*']
});
div_input.appendChild(input);
div.appendChild(div_input);
......@@ -274,8 +277,9 @@
return gadget.processValidation(json_url);
}
function addSubForm(g, element) {
var subform_json = JSON.parse(atob(element.value)),
function addSubForm(g, options) {
var element = options.element,
subform_json = options.schema_part,
input_text = element.parentNode.querySelector("input[type='text']"),
div = document.createElement("div"),
label;
......@@ -301,7 +305,7 @@
function loadEventList(gadget) {
var g = gadget,
field_list = g.props.inputs,
button_list = g.element.querySelectorAll('button.add-sub-form'),
button_list = g.props.add_buttons,
label_list = g.element.querySelectorAll('label.slapos-parameter-dict-key'),
i,
promise_list = [];
......@@ -317,7 +321,7 @@
for (i = 0; i < button_list.length; i = i + 1) {
promise_list.push(loopEventListener(
button_list[i],
button_list[i].element,
'click',
false,
addSubForm.bind(g, g, button_list[i])
......@@ -401,7 +405,8 @@
.declareMethod('renderParameterForm', function (schema, default_dict) {
var g = this,
parent_element = document.createDocumentFragment();
g.params.inputs = [];
g.props.inputs = [];
g.props.add_buttons = [];
render_subform(g, schema, default_dict, parent_element);
while (g.element.firstChild) {
g.element.removeChild(g.element.firstChild);
......
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