Commit 3317acb9 authored by Roque's avatar Roque

erp5_officejs: generic create document page

- add element gadget removed, combined into create document
parent f0bbda2f
...@@ -219,8 +219,12 @@ gadget_erp5_pt_form_view_editable.html\n ...@@ -219,8 +219,12 @@ gadget_erp5_pt_form_view_editable.html\n
gadget_erp5_pt_form_view_editable.js\n gadget_erp5_pt_form_view_editable.js\n
gadget_erp5_pt_form_dialog.html\n gadget_erp5_pt_form_dialog.html\n
gadget_erp5_pt_form_dialog.js\n gadget_erp5_pt_form_dialog.js\n
gadget_erp5_field_list.html\n
gadget_erp5_field_list.js\n
gadget_erp5_field_listbox.html\n gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n gadget_erp5_field_listbox.js\n
gadget_html5_select.html\n
gadget_html5_select.js\n
gadget_erp5_page_action_officejs.html\n gadget_erp5_page_action_officejs.html\n
gadget_erp5_page_action_officejs.js\n gadget_erp5_page_action_officejs.js\n
gadget_erp5_page_ojs_local_controller.html\n gadget_erp5_page_ojs_local_controller.html\n
...@@ -233,8 +237,6 @@ gadget_officejs_common_utils.html\n ...@@ -233,8 +237,6 @@ gadget_officejs_common_utils.html\n
gadget_officejs_common_utils.js\n gadget_officejs_common_utils.js\n
gadget_erp5_page_create_document.html\n gadget_erp5_page_create_document.html\n
gadget_erp5_page_create_document.js\n gadget_erp5_page_create_document.js\n
gadget_erp5_page_add_element.html\n
gadget_erp5_page_add_element.js\n
\n \n
#app routers\n #app routers\n
gadget_officejs_discussion_tool_router.html\n gadget_officejs_discussion_tool_router.html\n
...@@ -771,7 +773,7 @@ NETWORK:\n ...@@ -771,7 +773,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.5449.107.50432</string> </value> <value> <string>976.15394.28099.44458</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -789,7 +791,7 @@ NETWORK:\n ...@@ -789,7 +791,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1559327609.48</float> <float>1559912942.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.5655.16835.17186</string> </value> <value> <string>976.15215.11185.17510</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>1559327478.46</float> <float>1559901212.98</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Element</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_add_element.js"></script>
</head>
<body>
</body>
</html>
/*global window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this,
doc = {
title: "Untitled Document",
portal_type: options.portal_type,
parent_relative_url: options.parent_portal_type.replace(/ /g, '_').toLowerCase()
};
return gadget.jio_post(doc)
.push(function (id) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
});
});
}(window, rJS));
/*global window, document, rJS, RSVP, Handlebars */ /*global window, document, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, document, rJS, RSVP, Handlebars) { (function (window, document, rJS, RSVP) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// rJS(window)
// 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 // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -42,41 +15,17 @@ ...@@ -42,41 +15,17 @@
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // 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) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
allowed_sub_types_list = options.allowed_sub_types_list.split(","), allowed_sub_types_list = options.allowed_sub_types_list.split(","),
parent_portal_type = options.portal_type,
portal_type, portal_type,
document_title; document_title;
return gadget.jio_get(options.jio_key) return gadget.jio_get(options.jio_key)
...@@ -98,6 +47,7 @@ ...@@ -98,6 +47,7 @@
form_result.form_definition.title = "Create Document"; form_result.form_definition.title = "Create Document";
return gadget.changeState({ return gadget.changeState({
doc: { title: document_title, portal_type: allowed_sub_types_list }, doc: { title: document_title, portal_type: allowed_sub_types_list },
parent_portal_type: parent_portal_type,
action_options: options, action_options: options,
child_gadget_url: 'gadget_erp5_pt_form_dialog.html', child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
form_type: 'dialog', form_type: 'dialog',
...@@ -121,11 +71,24 @@ ...@@ -121,11 +71,24 @@
}); });
}) })
.declareMethod('triggerSubmit', function () { .allowPublicAcquisition('submitContent', function (options) {
return this.getDeclaredGadget('fg') var gadget = this,
.push(function (gadget) { content_dict = options[2],
return gadget.triggerSubmit(); doc = {
title: "Untitled Document",
portal_type: content_dict.portal_type,
parent_relative_url: gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase()
};
return gadget.jio_post(doc)
.push(function (id) {
return gadget.redirect({
command: 'display',
options: {
jio_key: id,
editable: true
}
});
}); });
}); });
}(window, document, rJS, RSVP, Handlebars)); }(window, document, rJS, RSVP));
\ No newline at end of file \ No newline at end of file
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.5677.14251.21606</string> </value> <value> <string>976.15382.16949.153</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1559329004.84</float> <float>1559912998.35</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