Commit 332b5582 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: use changeState rather them render directly

parent 304a9133
......@@ -7,17 +7,19 @@
data-i18n=Your Certificate
data-i18n=Your Key
data-i18n=Request New Certificate
data-i18n=Title
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<title>Request New Certificate</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_person_request_certificate.js"></script>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_person_request_certificate.js" type="text/javascript"></script>
</head>
......
......@@ -287,7 +287,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.32516.46874.3959</string> </value>
<value> <string>1010.21499.31843.44083</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -307,7 +307,7 @@
</tuple>
<state>
<tuple>
<float>1584350630.01</float>
<float>1691552889.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -11,6 +11,8 @@
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
......@@ -50,7 +52,12 @@
.push(function () {
// Workaround, find a way to open document without break gadget.
result.jio_key = doc.relative_url;
return gadget.render(result);
return gadget.changeState({
jio_key: doc.relative_url,
certificate: result.certificate,
key: result.key,
title: doc.title
});
});
});
});
......@@ -61,6 +68,24 @@
})
.declareMethod("render", function (options) {
var gadget = this,
jio_key;
return new RSVP.Queue()
.push(function () {
jio_key = options.jio_key;
return gadget.jio_get(jio_key);
})
.push(function (doc) {
return gadget.changeState({
jio_key: jio_key,
doc: doc,
editable: 1
});
});
})
.onStateChange(function () {
var gadget = this,
page_title_translation,
translation_list = [
......@@ -69,7 +94,8 @@
"Parent Relative Url",
"Your Certificate",
"Your Key",
"Request New Certificate"
"Request New Certificate",
"Title"
];
return new RSVP.Queue()
.push(function () {
......@@ -82,13 +108,16 @@
gadget.msg1_translation = result[1][0];
gadget.msg2_translation = result[1][1];
page_title_translation = result[1][5];
if (gadget.state.title === undefined) {
gadget.state.title = gadget.state.doc.first_name + " " + gadget.state.doc.last_name;
}
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_relative_url": {
"description": "",
"title": result[1][2],
"default": options.jio_key,
"default": gadget.state.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
......@@ -96,26 +125,37 @@
"hidden": 1,
"type": "StringField"
},
"my_title": {
"description": "",
"title": result[1][6],
"default": gadget.state.title,
"css_class": "",
"required": 0,
"editable": 0,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_certificate": {
"description": "",
"title": result[1][3],
"default": options.certificate,
"default": gadget.state.certificate,
"css_class": "",
"required": 1,
"editable": 1,
"key": "certificate",
"hidden": (options.certificate === undefined) ? 1 : 0,
"hidden": (gadget.state.certificate === undefined) ? 1 : 0,
"type": "TextAreaField"
},
"my_key": {
"description": "",
"title": result[1][4],
"default": options.key,
"default": gadget.state.key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "key",
"hidden": (options.key === undefined) ? 1 : 0,
"hidden": (gadget.state.key === undefined) ? 1 : 0,
"type": "TextAreaField"
}
}},
......@@ -128,9 +168,13 @@
},
form_definition: {
group_list: [[
"center",
[["my_key"], ["my_certificate"], ["my_relative_url"]]
]]
"left",
[["my_title"]]
],
[
"center",
[["my_key"], ["my_certificate"], ["my_relative_url"]]
]]
}
});
})
......@@ -149,7 +193,7 @@
page_title: page_title_translation,
selection_url: url_list[0]
};
if (options.key === undefined) {
if (gadget.state.key === undefined) {
header_dict.submit_action = true;
}
......
......@@ -283,7 +283,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1010.19575.46252.59357</string> </value>
<value> <string>1010.21512.39856.6519</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -303,7 +303,7 @@
</tuple>
<state>
<tuple>
<float>1691436974.71</float>
<float>1691553296.49</float>
<string>UTC</string>
</tuple>
</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