Commit 38476d1b authored by Roque's avatar Roque

erp5_officejs: -discussion tool- moving form definition to erp5 form

parent ce37ac0a
/*global document, window, rJS, RSVP */
/*global document, window, rJS, RSVP, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (document, window, rJS, RSVP) {
(function (document, window, rJS, RSVP, jIO) {
"use strict";
rJS(window)
......@@ -11,6 +11,7 @@
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
......@@ -20,6 +21,27 @@
/////////////////////////////////////////////////////////////////
.declareMethod("getFormDefinition", function () {
//preparing a less hardcoded version, moving form definition to erp5 side
/*var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting('hateoas_url'),
gadget.getSetting('default_view_reference')
]);
})
.push(function (setting_list) {
var jio_options = {
type: "erp5",
url: setting_list[0],
default_view_reference: setting_list[1]
},
jio_storage = jIO.createJIO(jio_options);
return jio_storage.get('portal_skins/erp5_officejs_jio_connector/HTMLPost_viewAsJio')
.push(function (result) {
return result.form_definition;
});
});*/
//somehow the form_definition should come from the erp5-doc/form (jio?)
//for now, hardcoded form_definition for POST VIEW
return {
......@@ -74,6 +96,8 @@
my_element = fields[j][0];
if (my_element.startsWith("my_")) {
element_id = my_element.replace("my_", "");
} else if (my_element.startsWith("your_")) {
element_id = my_element.replace("your_", "");
}
field_info = form_definition.field_info_dict[my_element];
if (document && document.hasOwnProperty(element_id)) {
......@@ -161,7 +185,6 @@
} else {
throw new Error('Can not display document: ' + options.jio_key);
}
//somehow the form_definition should come from the erp5-doc/form (jio?)
return gadget.getFormDefinition(options.jio_key)
.push(function (form_definition) {
return gadget.changeState({
......@@ -199,4 +222,4 @@
});
});
}(document, window, rJS, RSVP));
\ No newline at end of file
}(document, window, rJS, RSVP, jIO));
\ No newline at end of file
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.33799.59117.25480</string> </value>
<value> <string>973.43856.29209.60757</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1549565293.34</float>
<float>1550168687.51</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -226,8 +226,6 @@ 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_officejs_jio_html_post_view.html\n
#gadget_officejs_jio_html_post_view.js\n
gadget_erp5_page_ojs_add_post.html\n
gadget_erp5_page_ojs_add_post.js\n
\n
......@@ -714,7 +712,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.33828.18786.32665</string> </value>
<value> <string>973.42204.3106.62924</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -732,7 +730,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1549567442.36</float>
<float>1550168931.13</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