Commit 9fc658c2 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Use changeState on test parameter gadget

   Also include header link to return
parent 790d3b22
...@@ -69,10 +69,17 @@ ...@@ -69,10 +69,17 @@
}) })
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this;
if (options.url_string === undefined) { if (options.url_string === undefined) {
options.url_string = ""; options.url_string = "";
} }
return this.changeState({
"url_string": options.url_string,
"parameter_output": options.parameter_output
})
})
.onStateChange(function onStateChange() {
var gadget = this;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
...@@ -85,19 +92,19 @@ ...@@ -85,19 +92,19 @@
parameter_dict, parameter_dict,
default_url; default_url;
if (options.url_string === "") { if (gadget.state.url_string === "") {
default_url = result[1] + "sample-software-schema/simpledemo/software.cfg"; default_url = result[1] + "sample-software-schema/simpledemo/software.cfg";
} else { } else {
default_url = options.url_string; default_url = gadget.state.url_string;
} }
if (options.parameter_output === undefined) { if (gadget.state.parameter_output === undefined) {
parameter_hash = btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>'); parameter_hash = btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>');
} else { } else {
parameter_hash = btoa(options.parameter_output); parameter_hash = btoa(gadget.state.parameter_output);
} }
parameter_dict = { parameter_dict = {
'parameter' : { 'parameter' : {
'json_url': options.url_string.split('?')[0] + ".json", 'json_url': gadget.state.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash, 'parameter_hash': parameter_hash,
'restricted_softwaretype': false 'restricted_softwaretype': false
} }
...@@ -111,7 +118,7 @@ ...@@ -111,7 +118,7 @@
"default": default_url, "default": default_url,
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": options.url_string === "", "editable": gadget.state.url_string === "",
"key": "url_string", "key": "url_string",
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
...@@ -122,23 +129,23 @@ ...@@ -122,23 +129,23 @@
"default": parameter_dict, "default": parameter_dict,
"css_class": "", "css_class": "",
"required": 1, "required": 1,
"editable": options.url_string !== "", "editable": gadget.state.url_string !== "",
"url": "gadget_erp5_page_slap_parameter_form.html", "url": "gadget_erp5_page_slap_parameter_form.html",
"sandbox": "", "sandbox": "",
"key": "text_content", "key": "text_content",
"hidden": options.url_string === "", "hidden": gadget.state.url_string === "",
"type": "GadgetField" "type": "GadgetField"
}, },
"your_parameter_output": { "your_parameter_output": {
"description": "", "description": "",
"title": "Parameters Output", "title": "Parameters Output",
"default": options.parameter_output, "default": gadget.state.parameter_output,
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 0, "editable": 0,
"sandbox": "", "sandbox": "",
"key": "parameter_output", "key": "parameter_output",
"hidden": options.parameter_output === undefined, "hidden": gadget.state.parameter_output === undefined,
"type": "TextAreaField" "type": "TextAreaField"
} }
}}, }},
...@@ -157,8 +164,14 @@ ...@@ -157,8 +164,14 @@
} }
}) })
.push(function () { .push(function () {
return gadget.getUrlFor({"command": "change",
"options": {"url_string": undefined,
"parameter_output": undefined}});
})
.push(function (selection_url) {
return gadget.updateHeader({ return gadget.updateHeader({
page_title: "Parameter testing page", page_title: "Parameter testing page",
selection_url: selection_url,
submit_action: true submit_action: true
}); });
}); });
......
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.3592.26006.62702</string> </value> <value> <string>1003.56160.64867.20462</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1652201764.17</float> <float>1666625416.83</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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