Commit 04cc3a1e authored by Roque's avatar Roque

erp5_officejs: remove adhoc add post gadget

- a generic gadget is used to add any document (based on portal type)
parent 5df13c14
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Post Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_add_any_document.js"></script>
</head>
<body>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Blob) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this, doc_id;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url')
]);
})
.push(function (result) {
var doc = {
title: "Untitled Document",
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) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
});
}(window, rJS, RSVP, Blob));
......@@ -225,7 +225,7 @@
</tuple>
<state>
<tuple>
<float>1496752479.26</float>
<float>1554834728.63</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -221,7 +221,7 @@
</tuple>
<state>
<tuple>
<float>1496752480.62</float>
<float>1554834725.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,11 +10,8 @@
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -52,11 +49,8 @@
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -202,7 +196,7 @@
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
<value> <string>hide</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
......@@ -228,7 +222,7 @@
</tuple>
<state>
<tuple>
<float>1548320422.63</float>
<float>1554830718.01</float>
<string>UTC</string>
</tuple>
</state>
......@@ -237,7 +231,7 @@
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
<value> <string>hidden</string> </value>
</item>
</dictionary>
</list>
......@@ -273,7 +267,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.13052.24734.46370</string> </value>
<value> <string>974.60330.38139.58094</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +285,7 @@
</tuple>
<state>
<tuple>
<float>1548320944.13</float>
<float>1554830097.21</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,11 +10,8 @@
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -52,11 +49,8 @@
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
......@@ -198,7 +192,7 @@
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
<value> <string>hide</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
......@@ -224,7 +218,7 @@
</tuple>
<state>
<tuple>
<float>1549566213.89</float>
<float>1554830725.59</float>
<string>UTC</string>
</tuple>
</state>
......@@ -233,7 +227,7 @@
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
<value> <string>hidden</string> </value>
</item>
</dictionary>
</list>
......
......@@ -53,7 +53,7 @@
},
action: "Base_edit",
update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "ojs_add_post", my_source_reference: fake_thread_uid} }
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "ojs_add_any_document", my_source_reference: fake_thread_uid} }
},
form_json = {
erp5_document: {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60320.21280.62788</string> </value>
<value> <string>974.60338.53030.59904</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1554829461.22</float>
<float>1554834814.11</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