Commit 5df13c14 authored by Roque's avatar Roque

erp5_officejs: add post gadget becomes generic

- wip: change name to add document
parent a5397a63
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("render", function () { .declareMethod("render", function (options) {
var gadget = this, doc_id; var gadget = this, doc_id;
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
...@@ -28,11 +28,17 @@ ...@@ -28,11 +28,17 @@
.push(function (result) { .push(function (result) {
var doc = { var doc = {
title: "Untitled Document", title: "Untitled Document",
//TODO: this must be the parent thread reference (or 'base' post ref?)
source_reference: "some-fake-thread-id",
portal_type: result[0], portal_type: result[0],
parent_relative_url: result[1] parent_relative_url: result[1]
}; }, key, doc_key;
for (key in options) {
if (options.hasOwnProperty(key)) {
if (key.startsWith("my_")) {
doc_key = key.replace("my_", "");
doc[doc_key] = options[key];
}
}
}
return gadget.jio_post(doc); return gadget.jio_post(doc);
}) })
.push(function (id) { .push(function (id) {
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.53018.33015.55893</string> </value> <value> <string>974.60313.36900.21043</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1554392914.44</float> <float>1554829075.96</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("generateJsonRenderForm", function (gadget) { .declareMethod("generateJsonRenderForm", function (gadget) {
//this will be the id of the thread that contains this post list
var fake_thread_uid = "thread-" + ("0000" + ((Math.random() * Math.pow(36, 4)) | 0).toString(36)).slice(-4),
//hardcoded form_definition (this should come from erp5 form) //hardcoded form_definition (this should come from erp5 form)
var form_definition = { form_definition = {
_debug: "traverse", _debug: "traverse",
pt: "form_view", pt: "form_view",
title: "Post", title: "Post",
...@@ -51,7 +53,7 @@ ...@@ -51,7 +53,7 @@
}, },
action: "Base_edit", action: "Base_edit",
update_action: "", update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {"page": "ojs_add_post"} } _links: { "type": { name: "" }, "action_object_new_content_action": {page: "ojs_add_post", my_source_reference: fake_thread_uid} }
}, },
form_json = { form_json = {
erp5_document: { erp5_document: {
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.59028.6381.42171</string> </value> <value> <string>974.60320.21280.62788</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1554752043.96</float> <float>1554829461.22</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