Commit b20eb74a authored by Roque's avatar Roque

erp5_officejs_connector: gadget for reply post action

parent 438ff676
......@@ -209,7 +209,7 @@
</item>
<item>
<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>
<key> <string>hidden</string> </key>
......
......@@ -9,11 +9,11 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_reply.js"></script>
<script src="gadget_field_reply_action_js_script.js"></script>
</head>
<body>
GADGET FIELD HTML!
Reply Action GADGET FIELD HTML!
</body>
</html>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<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>
<key> <string>content_type</string> </key>
......
/*global window, rJS */
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
(function (window, rJS, RSVP) {
"use strict";
var default_view = "jio_view",
gadget_utils;
var gadget_utils;
rJS(window)
......@@ -13,13 +12,8 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod('getUrlParameter', 'getUrlParameter')
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("redirect", "redirect")
......@@ -31,49 +25,65 @@
.declareMethod("render", function (options) {
console.log("GADGET FIELD RENDER METHOD!!!");
return;
var gadget = this,
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
jio_document;
var erp5_storage = jIO.createJIO({
type: "erp5",
url: "https://softinst112382.host.vifib.net/erp5/web_site_module/officejs_discussion_tool/hateoas/",
default_view_reference: "jio_view"
})
.declareMethod("handleRender", function (gadget, gadget_utils, options, action_reference, parent_portal_type, form_definition) {
console.log("GADGET FIELD handleRender METHOD!!!");
var child_gadget_url = 'gadget_erp5_pt_form_view_editable.html';\
return gadget.jio_get(options.jio_key)
.push(function (result) {
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"));
return gadget.declareGadget("gadget_officejs_form_view.html")
.push(function (result) {
gadget_utils = result;
return gadget.jio_get(options.jio_key);
})
.push(function (result) {
jio_document = result;
if (jio_document.portal_type === undefined) {
throw new Error('Can not display document: ' + options.jio_key);
})
.declareMethod("handleSubmit", function (gadget, gadget_utils, jio_key, content_dict) {
console.log("GADGET FIELD handleSubmit METHOD!!!");
var document = {
my_title: gadget.state.doc.title,
portal_type: gadget.state.parent_document.portal_type,
parent_relative_url: gadget.state.parent_document.parent_relative_url,
my_source_reference: gadget.state.parent_document.source_reference
}, property;
for (property in content_dict) {
if (content_dict.hasOwnProperty(property)) {
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);
});
});*/
}(window, rJS));
\ No newline at end of file
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<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>
<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