Commit e0244605 authored by Roque's avatar Roque

erp5_officejs: generic add document (WIP)

- todo: get form definition from a create doc action
parent a29cbd5e
......@@ -137,6 +137,10 @@
form_definition = form_result.form_definition;
form_definition.action_type = action_type;
form_definition.title = action_title;
return gadget.jio_get("portal_types/" + portal_type);
})
.push(function (portal_type_definition) {
form_definition.allowed_sub_types_list = portal_type_definition.type_allowed_content_type_list;
return gadget.checkMoreActions(portal_type, action_type);
})
.push(function (has_more_dict) {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.61005.40376.25702</string> </value>
<value> <string>976.1341.45833.19848</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1558716356.0</float>
<float>1559144323.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -61,19 +61,6 @@
})
.push(function (result) {
form_definition = result;
//TODO: solve add button (header add button - '+' icon)
//solved: add elements must be done via actions
/*if (form_definition.action_type === "object_list") {
form_definition._links.action_object_new_content_action = {
page: "handle_action",
title: "New Post",
action: "new_html_post",
reference: "new_html_post",
action_type: "object_jio_js_script",
parent_portal_type: "Post Module",
source_reference: "for-future-thread-id"
};
}*/
return gadget_utils.getFormInfo(form_definition);
})
.push(function (form_info) {
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.65241.3775.53845</string> </value>
<value> <string>976.1354.15427.27101</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1558970472.88</float>
<float>1559069474.12</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -231,6 +231,12 @@ gadget_erp5_page_handle_action.html\n
gadget_erp5_page_handle_action.js\n
gadget_officejs_common_utils.html\n
gadget_officejs_common_utils.js\n
gadget_erp5_page_create_document.html\n
gadget_erp5_page_create_document.js\n
gadget_erp5_page_add_element.html\n
gadget_erp5_page_add_element.js\n
\n
#app routers\n
gadget_officejs_discussion_tool_router.html\n
gadget_officejs_text_editor_router.html\n
\n
......@@ -262,17 +268,21 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_o
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewReplyDialog&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_post%2FPostModule_newHTMLPost&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FPostModule_viewHTMLPostListAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F3&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F3&view=view&appcache=1\n
\n
#text editor\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module%2F4&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module%2F5&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPageModule_viewWebPageListAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%2F9&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPage_viewAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPageModule_newWebPage&view=jio_view&appcache=1\n
......@@ -760,7 +770,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.65264.897.7441</string> </value>
<value> <string>976.2798.32101.13585</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -778,7 +788,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1558984889.91</float>
<float>1559156188.36</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -120,17 +120,21 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_o
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewReplyDialog&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_post%2FPostModule_newHTMLPost&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FPostModule_viewHTMLPostListAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F3&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F3&view=view&appcache=1\n
\n
#text editor\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module%2F4&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%20Module%2F5&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPageModule_viewWebPageListAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FWeb%20Page%2F9&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPage_viewAsJio&view=jio_view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FWebPageModule_newWebPage&view=jio_view&appcache=1\n
......@@ -279,7 +283,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.51184.57710.25634</string> </value>
<value> <string>976.2544.1534.5939</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -297,7 +301,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1558539242.12</float>
<float>1559155949.19</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -148,11 +148,10 @@
page_title = options.doc.title;
}
erp5_document = form_json.erp5_document;
//add elements must be done via actions, so no 'add' button
/*if (erp5_document._links && erp5_document._links.action_object_new_content_action) {
url_for_parameter_list.push({command: 'change', options: erp5_document._links.action_object_new_content_action});
if (form_json.form_definition.allowed_sub_types_list.length > 0) {
url_for_parameter_list.push({command: 'change', options: {page: "create_document", jio_key: options.jio_key, portal_type: options.portal_type, allowed_sub_types_list: form_json.form_definition.allowed_sub_types_list}});
add_url = true;
}*/
}
return RSVP.all([
this_gadget.getUrlForList(url_for_parameter_list),
this_gadget.isDesktopMedia(),
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.61035.13847.33843</string> </value>
<value> <string>976.2523.47706.38553</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1558718116.94</float>
<float>1559144299.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.60908.26814.32921</string> </value>
<value> <string>976.1065.27522.55654</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1558970764.45</float>
<float>1559053759.99</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Workflows
data-i18n=Actions
data-i18n=Clone
data-i18n=Delete
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Officejs Page Action</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_create_document.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each document_list}}
<li><a data-i18n="{{title}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
function renderLinkList(gadget, title, icon, erp5_link_list) {
// prepare links for template (replace @href for RJS link)
return gadget.translateHtml(
table_template({
"definition_i18n": title,
"definition_title": title,
"definition_icon": icon,
"document_list": erp5_link_list.map(function (erp5_link, index) {
return {
"title": erp5_link.title,
"i18n": erp5_link.title,
"link": erp5_link_list[index].href
};
})
})
);
}
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("getHTMLElementList", function (portal_type_list, jio_key, parent_portal_type) {
var gadget = this,
i = 0,
portal_type_info_list = [],
portal_type,
url_for_parameter_list = [],
x;
for (x = 0; x < portal_type_list.length; x += 1) {
portal_type = portal_type_list[x];
url_for_parameter_list.push({ command: 'change', options: {page: "add_element", jio_key: jio_key, portal_type: portal_type, parent_portal_type: parent_portal_type} });
portal_type_info_list[i] = { reference: portal_type, title: portal_type};
i += 1;
}
return gadget.getUrlForList(url_for_parameter_list)
.push(function (url_list) {
var html_element_list = [], j, element;
for (j = 0; j < url_list.length; j += 1) {
element = { href: url_list[j],
icon: null,
name: portal_type_info_list[j].reference,
title: portal_type_info_list[j].title };
html_element_list.push(element);
}
return html_element_list;
});
})
.declareMethod("render", function (options) {
var gadget = this,
allowed_sub_types_list = options.allowed_sub_types_list.split(","),
document_title;
return gadget.jio_get(options.jio_key)
.push(function (document) {
document_title = document.title;
return document.portal_type;
}, function () {
document_title = options.portal_type;
return options.portal_type;
})
// TODO: this gadget must load the form dialog to select the type of document
// somehow (a generic action?) get the path string:${object_url}/Base_viewNewContentDialog
// get corresponding form definition (only contains a select field)
// fill select field with allowed_sub_types_list
.push(function (portal_type) {
return gadget.getHTMLElementList(allowed_sub_types_list, options.jio_key, portal_type);
})
.push(function (all_html_elements) {
return RSVP.all([
renderLinkList(gadget, "Create Document", "file", all_html_elements)
]);
})
.push(function (translated_html_link_list) {
gadget.element.innerHTML = translated_html_link_list.join("\n");
return gadget.getUrlFor({command: 'change', options: {page: undefined}});
})
.push(function (back_url) {
return gadget.updateHeader({
page_title: document_title,
back_url: back_url
});
});
})
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1558720717.67</float>
<float>1559051938.53</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