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

slapos_jio: use changeState rather them render directly

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