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 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function () {
.declareMethod("render", function (options) {
var gadget = this, doc_id;
return RSVP.Queue()
.push(function () {
......@@ -28,11 +28,17 @@
.push(function (result) {
var doc = {
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],
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);
})
.push(function (id) {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.53018.33015.55893</string> </value>
<value> <string>974.60313.36900.21043</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1554392914.44</float>
<float>1554829075.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -18,48 +18,50 @@
/////////////////////////////////////////////////////////////////
.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)
var form_definition = {
_debug: "traverse",
pt: "form_view",
title: "Post",
group_list: [[
"bottom",
[["my_listbox"]]
]],
//this field_info is totally made up, but somewhere in the definition there must be
//information about the fields. So, foreach field: key->info
field_info_dict: {
"my_listbox": {
"column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
// is this correct? the query should come from the form definition, right?
"query": "urn:jio:allDocs?query=portal_type%3A%22HTML Post%22",
"portal_type": [],
"search_column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"sort_column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"sort": [['modification_date', 'descending']],
"title": "Posts",
"type": "ListBox"
}
},
action: "Base_edit",
update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {"page": "ojs_add_post"} }
},
form_json = {
erp5_document: {
"_embedded": {"_view": {}},
"_links": {}
form_definition = {
_debug: "traverse",
pt: "form_view",
title: "Post",
group_list: [[
"bottom",
[["my_listbox"]]
]],
//this field_info is totally made up, but somewhere in the definition there must be
//information about the fields. So, foreach field: key->info
field_info_dict: {
"my_listbox": {
"column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
// is this correct? the query should come from the form definition, right?
"query": "urn:jio:allDocs?query=portal_type%3A%22HTML Post%22",
"portal_type": [],
"search_column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"sort_column_list": [['title', 'Title'], ['modification_date', 'Modification Date']],
"sort": [['modification_date', 'descending']],
"title": "Posts",
"type": "ListBox"
}
},
action: "Base_edit",
update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "ojs_add_post", my_source_reference: fake_thread_uid} }
},
form_definition: form_definition
};
form_json = {
erp5_document: {
"_embedded": {"_view": {}},
"_links": {}
},
form_definition: form_definition
};
for (var i = 0; i < form_definition.group_list.length; i++) {
var fields = form_definition.group_list[i][1];
for (var j = 0; j < fields.length; j++) {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.59028.6381.42171</string> </value>
<value> <string>974.60320.21280.62788</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1554752043.96</float>
<float>1554829461.22</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