Commit f0bbda2f authored by Roque's avatar Roque

erp5_officejs: fill document type list field in create document gadget

parent 8488d7b7
...@@ -262,6 +262,7 @@ officejs_logo.png\n ...@@ -262,6 +262,7 @@ officejs_logo.png\n
jio_appcachestorage.js\n jio_appcachestorage.js\n
\n \n
#configuration resources\n #configuration resources\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_hal_json_style%2FBase_viewNewContentDialog&view=jio_view&appcache=1\n
\n \n
#discussion tool\n #discussion tool\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view&appcache=1\n hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view&appcache=1\n
...@@ -770,7 +771,7 @@ NETWORK:\n ...@@ -770,7 +771,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.2798.32101.13585</string> </value> <value> <string>976.5449.107.50432</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -788,7 +789,7 @@ NETWORK:\n ...@@ -788,7 +789,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1559156188.36</float> <float>1559327609.48</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -115,6 +115,8 @@ CACHE MANIFEST\n ...@@ -115,6 +115,8 @@ CACHE MANIFEST\n
# generated on Thu, 14 Jan 2019 11:55:33 +0000\n # generated on Thu, 14 Jan 2019 11:55:33 +0000\n
CACHE:\n CACHE:\n
\n \n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_hal_json_style%2FBase_viewNewContentDialog&view=jio_view&appcache=1\n
\n
#discussion tool\n #discussion tool\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view&appcache=1\n hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_officejs_jio_connector%2FHTMLPost_viewAsJio&view=jio_view&appcache=1\n
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_officejs_jio_connector%2FHTMLPost_viewReplyDialog&view=jio_view&appcache=1\n
...@@ -301,7 +303,7 @@ NETWORK:\n ...@@ -301,7 +303,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1559155949.19</float> <float>1559314986.76</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global document, window, rJS, RSVP */ /*global document, window, rJS, RSVP, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (document, window, rJS, RSVP) { (function (document, window, rJS, RSVP, ensureArray) {
"use strict"; "use strict";
function renderField(field_id, field_definition, document) { function renderField(field_id, field_definition, document) {
...@@ -36,7 +36,15 @@ ...@@ -36,7 +36,15 @@
result.type = field_definition.type; result.type = field_definition.type;
result.key = field_id; result.key = field_id;
if (document && document.hasOwnProperty(field_id)) { if (document && document.hasOwnProperty(field_id)) {
result["default"] = document[field_id]; if (field_definition.type === "ListField") {
var item_list = ensureArray(document[field_id]).map(function (item) {
if (Array.isArray(item)) {return item; }
return [item, item];
});
result.items = item_list;
} else {
result["default"] = document[field_id];
}
} }
return result; return result;
} }
...@@ -148,7 +156,7 @@ ...@@ -148,7 +156,7 @@
page_title = options.doc.title; page_title = options.doc.title;
} }
erp5_document = form_json.erp5_document; erp5_document = form_json.erp5_document;
if (form_json.form_definition.allowed_sub_types_list.length > 0) { if (form_json.form_definition.allowed_sub_types_list && 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}}); 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; add_url = true;
} }
...@@ -212,4 +220,4 @@ ...@@ -212,4 +220,4 @@
}); });
}); });
}(document, window, rJS, RSVP)); }(document, window, rJS, RSVP, ensureArray));
...@@ -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.2523.47706.38553</string> </value> <value> <string>976.5655.16835.17186</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>1559144299.92</float> <float>1559327478.46</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, Handlebars */ /*global window, document, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) { (function (window, document, rJS, RSVP, Handlebars) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
.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(","),
portal_type,
document_title; document_title;
return gadget.jio_get(options.jio_key) return gadget.jio_get(options.jio_key)
.push(function (document) { .push(function (document) {
...@@ -86,32 +87,45 @@ ...@@ -86,32 +87,45 @@
document_title = options.portal_type; document_title = options.portal_type;
return options.portal_type; return options.portal_type;
}) })
// TODO: this gadget must load the form dialog to select the type of document .push(function (portal_type_result) {
// somehow (a generic action?) get the path string:${object_url}/Base_viewNewContentDialog portal_type = portal_type_result;
// get corresponding form definition (only contains a select field) // TODO: somehow (a generic action?) get the path string:${object_url}/Base_viewNewContentDialog
// fill select field with allowed_sub_types_list // for now hardcoded
.push(function (portal_type) { // get corresponding form definition (only contains a select field)
return gadget.getHTMLElementList(allowed_sub_types_list, options.jio_key, portal_type); return gadget.jio_get("portal_skins/erp5_hal_json_style/Base_viewNewContentDialog");
})
.push(function (all_html_elements) {
return RSVP.all([
renderLinkList(gadget, "Create Document", "file", all_html_elements)
]);
}) })
.push(function (translated_html_link_list) { .push(function (form_result) {
gadget.element.innerHTML = translated_html_link_list.join("\n"); form_result.form_definition.title = "Create Document";
return gadget.getUrlFor({command: 'change', options: {page: undefined}}); return gadget.changeState({
}) doc: { title: document_title, portal_type: allowed_sub_types_list },
.push(function (back_url) { action_options: options,
return gadget.updateHeader({ child_gadget_url: 'gadget_erp5_pt_form_dialog.html',
page_title: document_title, form_type: 'dialog',
back_url: back_url form_definition: form_result.form_definition,
view: "view"
}); });
}); });
}) })
.declareMethod("triggerSubmit", function () { .onStateChange(function () {
return; var fragment = document.createElement('div'),
gadget = this;
while (this.element.firstChild) {
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
})
.declareMethod('triggerSubmit', function () {
return this.getDeclaredGadget('fg')
.push(function (gadget) {
return gadget.triggerSubmit();
});
}); });
}(window, rJS, RSVP, Handlebars)); }(window, document, rJS, RSVP, Handlebars));
\ 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.2629.49630.20326</string> </value> <value> <string>976.5677.14251.21606</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>1559147821.67</float> <float>1559329004.84</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