Commit b20eb74a authored by Roque's avatar Roque

erp5_officejs_connector: gadget for reply post action

parent 438ff676
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
</item> </item>
<item> <item>
<key> <string>gadget_url</string> </key> <key> <string>gadget_url</string> </key>
<value> <string>python: field.restrictedTraverse(\'gadget_reply.html\').absolute_url()</string> </value> <value> <string>gadget_field_reply_action_js_script.html</string> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="gadget_reply.js"></script> <script src="gadget_field_reply_action_js_script.js"></script>
</head> </head>
<body> <body>
GADGET FIELD HTML! Reply Action GADGET FIELD HTML!
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
<value> <string>gadget_reply.html</string> </value> <value> <string>gadget_field_reply_action_js_script.html</string> </value>
</item> </item>
<item> <item>
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
......
/*global window, rJS */ /*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) { (function (window, rJS, RSVP) {
"use strict"; "use strict";
var default_view = "jio_view", var gadget_utils;
gadget_utils;
rJS(window) rJS(window)
...@@ -13,13 +12,8 @@ ...@@ -13,13 +12,8 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put") .declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod('getUrlParameter', 'getUrlParameter') .declareAcquiredMethod('getUrlParameter', 'getUrlParameter')
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
...@@ -31,49 +25,65 @@ ...@@ -31,49 +25,65 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
console.log("GADGET FIELD RENDER METHOD!!!"); console.log("GADGET FIELD RENDER METHOD!!!");
return; return;
var gadget = this, })
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
jio_document; .declareMethod("handleRender", function (gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition) {
console.log("GADGET FIELD handleRender METHOD!!!");
var erp5_storage = jIO.createJIO({ var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';\
type: "erp5", return gadget.jio_get(options.jio_key)
url: "https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/hateoas/", .push(function (result) {
default_view_reference: "jio_view" parent_document = result;
var title = parent_document.title;
if (!title.startsWith('Re: ')) { title = 'Re: ' + parent_document.title; }
return gadget.changeState({
doc: {title: title},
submit_code: submit_code,
parent_document: parent_document,
child_gadget_url: child_gadget_url,
form_definition: form_definition,
view: action_reference,
editable: true,
has_more_views: false,
has_more_actions: false,
is_form_list: false
});
}); });
console.log("JIO-GETTING action_result.action: portal_skins/erp5_post/PostModule_newHTMLPost"); })
console.log(erp5_storage.get("portal_skins/erp5_post/PostModule_newHTMLPost"));
.declareMethod("handleSubmit", function (gadget, gadget_utils, jio_key, content_dict) {
console.log("GADGET FIELD handleSubmit METHOD!!!");
return gadget.declareGadget("gadget_officejs_form_view.html") var document = {
.push(function (result) { my_title: gadget.state.doc.title,
gadget_utils = result; portal_type: gadget.state.parent_document.portal_type,
return gadget.jio_get(options.jio_key); parent_relative_url: gadget.state.parent_document.parent_relative_url,
}) my_source_reference: gadget.state.parent_document.source_reference
.push(function (result) { }, property;
jio_document = result; for (property in content_dict) {
if (jio_document.portal_type === undefined) { if (content_dict.hasOwnProperty(property)) {
throw new Error('Can not display document: ' + options.jio_key); document['my_' + property] = content_dict[property];
}
}
return gadget_utils.createDocument(document)
.push(function (id) {
jio_key = id;
return gadget.notifySubmitting();
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
})
.push(function () {
return gadget.redirect({
command: 'display',
options: {
jio_key: jio_key,
editable: true
} }
return gadget_utils.getFormDefinition(jio_document.portal_type, default_view);
})
.push(function (form_definition) {
return gadget.changeState({
jio_key: options.jio_key,
doc: jio_document,
child_gadget_url: child_gadget_url,
form_definition: form_definition,
editable: false,
view: options.view,
//HARDCODED: following fields should be indicated by the configuration
has_more_views: false,
has_more_actions: options.view === "view",
is_form_list: false
});
}); });
}) });
});
.onStateChange(function () { /*.onStateChange(function () {
return gadget_utils.renderGadget(this); return gadget_utils.renderGadget(this);
}); });*/
}(window, rJS)); }(window, rJS, RSVP));
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
<value> <string>gadget_reply.js</string> </value> <value> <string>gadget_field_reply_action_js_script.js</string> </value>
</item> </item>
<item> <item>
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
......
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