Commit d97ff654 authored by Roque's avatar Roque

erp5_officejs: get rid of add post gadget

- use action instead
parent d31e8c3a
......@@ -232,8 +232,8 @@ gadget_erp5_page_ojs_controller.html\n
gadget_erp5_page_ojs_controller.js\n
gadget_erp5_page_ojs_post_list.html\n
gadget_erp5_page_ojs_post_list.js\n
gadget_erp5_page_ojs_add_any_document.html\n
gadget_erp5_page_ojs_add_any_document.js\n
#gadget_erp5_page_ojs_add_any_document.html\n
#gadget_erp5_page_ojs_add_any_document.js\n
\n
#needed for appcachestorage sync\n
/\n
......@@ -740,7 +740,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60349.22499.1160</string> </value>
<value> <string>974.60462.54910.65109</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -758,7 +758,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1554837914.89</float>
<float>1554905710.65</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Blob) {
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
......@@ -51,4 +51,4 @@
});
});
});
}(window, rJS, RSVP, Blob));
}(window, rJS, RSVP));
......@@ -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>1554830683.98</float>
<float>1554903150.06</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>
......@@ -269,7 +263,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60334.56052.51848</string> </value>
<value> <string>974.60340.48045.57105</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +281,7 @@
</tuple>
<state>
<tuple>
<float>1554830395.26</float>
<float>1554836734.22</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -53,7 +53,8 @@
},
action: "Base_edit",
update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "ojs_add_any_document", my_source_reference: fake_thread_uid} }
//hardcoded action for new post. TODO: create corresponding configuration
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "handle_action", action: "new_post", my_source_reference: fake_thread_uid} }
},
form_json = {
erp5_document: {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60338.53030.59904</string> </value>
<value> <string>974.61547.62474.32904</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1554834814.11</float>
<float>1554903652.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60153.5925.35891</string> </value>
<value> <string>974.61546.47138.31283</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554819442.65</float>
<float>1554903359.26</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,51 +19,77 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("handleAction", function (jio_key) {
var gadget = this, action_reference;
return gadget.getUrlParameter("action")
.push(function (action_parameter) {
action_reference = action_parameter;
return gadget.jio_get(jio_key);
})
.push(function (document) {
// This is the custom code to handle this specific reply action
if (action_reference == "reply") {
var doc, title = document.title;
if (!title.startsWith("Re: ")) {
title = "Re: " + document.title;
}
doc = {
title: title,
//thread parent: same as base post
source_reference: document.source_reference,
portal_type: document.portal_type,
parent_relative_url: document.parent_relative_url
};
return gadget.jio_post(doc)
.push(function (id) {
return [id, action_reference];
});
}
return [jio_key, action_reference];
});
})
.declareMethod("render", function (options) {
var gadget = this;
var gadget = this,
action_reference;
return RSVP.Queue()
.push(function () {
return gadget.handleAction(options.jio_key);
return RSVP.all([
gadget.getUrlParameter("action"),
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url')
]);
})
.push(function (action_result) {
return gadget.redirect({
command: 'change',
options: {
page: undefined,
jio_key: action_result[0],
view: action_result[1]
.push(function (result) {
action_reference = result[0];
// This is the custom code to handle each specific action
// TODO: move to specific gadgets by name? e.g. page: "action_" + portal_type + action_ref
if (action_reference === "new_post") {
//TODO refactor doc creation to be reused by other actions (e.g. reply action)
// move to a js script?
var doc = {
title: "Untitled Document",
portal_type: result[1],
parent_relative_url: result[2]
}, 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
}
});
});
}
if (action_reference == "reply") {
return gadget.jio_get(options.jio_key)
.push(function (document) {
var doc, title = document.title;
if (!title.startsWith("Re: ")) {
title = "Re: " + document.title;
}
doc = {
title: title,
//thread parent: same as base post
source_reference: document.source_reference,
portal_type: document.portal_type,
parent_relative_url: document.parent_relative_url
};
return gadget.jio_post(doc)
.push(function (id) {
return gadget.redirect({
command: "change",
options: {
page: undefined,
jio_key: id,
view: action_reference
}
});
});
});
} else {
throw "Action " + action_reference + " not implemented yet";
}
});
});
});
}(window, rJS, RSVP));
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.60145.32757.53879</string> </value>
<value> <string>974.61589.61140.4744</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1554818976.22</float>
<float>1554905840.94</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