Commit eb3a5942 authored by Roque's avatar Roque

erp5_officejs: fix form_view gadget render parameters

parent 3de2bb25
/*global window, rJS */
/*global window, rJS, document */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
(function (window, rJS, document) {
"use strict";
rJS(window)
......@@ -61,11 +61,18 @@
})
.onStateChange(function () {
var gadget = this;
return gadget.declareGadget("gadget_officejs_form_view.html")
var fragment = document.createElement('div'),
gadget = this,
options;
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.renderGadget(gadget);
return form_view_gadget.render(gadget.state);
});
});
}(window, rJS));
\ No newline at end of file
}(window, rJS, document));
\ No newline at end of file
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.23887.3080.29184</string> </value>
<value> <string>975.29197.45196.34952</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -243,7 +243,7 @@
</tuple>
<state>
<tuple>
<float>1556575627.18</float>
<float>1556807970.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -95,40 +95,40 @@
return form_json;
})
.declareMethod("renderGadget", function (target_gadget) {
.declareMethod("render", function (options) {
var fragment = document.createElement('div'),
gadget = this,
form_json;
return gadget.renderForm(target_gadget.state.form_definition, target_gadget.state.doc)
return gadget.renderForm(options.form_definition, options.doc)
.push(function (json) {
form_json = json;
while (target_gadget.element.firstChild) {
target_gadget.element.removeChild(target_gadget.element.firstChild);
while (gadget.element.firstChild) {
gadget.element.removeChild(gadget.element.firstChild);
}
target_gadget.element.appendChild(fragment);
return target_gadget.declareGadget(target_gadget.state.child_gadget_url, {element: fragment, scope: 'fg'});
gadget.element.appendChild(fragment);
return gadget.declareGadget(options.child_gadget_url, {element: fragment, scope: 'fg'});
})
.push(function (form_gadget) {
return gadget.renderSubGadget(target_gadget, form_gadget, form_json);
return gadget.renderSubGadget(options, form_gadget, form_json);
});
})
.declareMethod("renderSubGadget", function (gadget, subgadget, form_json) {
.declareMethod("renderSubGadget", function (options, subgadget, form_json) {
var this_gadget = this, erp5_document = form_json.erp5_document;
return subgadget.render({
jio_key: gadget.state.jio_key,
doc: gadget.state.doc,
jio_key: options.jio_key,
doc: options.doc,
erp5_document: form_json.erp5_document,
form_definition: form_json.form_definition,
editable: gadget.state.editable,
view: gadget.state.view,
editable: options.editable,
view: options.view,
form_json: form_json
})
// render the header
.push(function () {
var url_for_parameter_list = [
{command: 'change', options: {page: "tab"}},
{command: 'change', options: {page: "action_offline", jio_key: gadget.state.jio_key}},
{command: 'change', options: {page: "action_offline", jio_key: options.jio_key}},
{command: 'history_previous'},
{command: 'selection_previous'},
{command: 'selection_next'},
......@@ -148,14 +148,14 @@
})
.push(function (result_list) {
var url_list = result_list[0], header_dict;
if (gadget.state.form_type === 'dialog') {
if (options.form_type === 'dialog') {
header_dict = {
page_title: gadget.state.doc.title,
page_title: options.doc.title,
//TODO: find correct url
cancel_url: url_list[6]
};
} else {
if (gadget.state.form_type === 'list') {
if (options.form_type === 'list') {
header_dict = {
panel_action: true,
jump_url: "",
......@@ -169,21 +169,20 @@
selection_url: url_list[2],
previous_url: url_list[3],
next_url: url_list[4],
page_title: gadget.state.doc.title
page_title: options.doc.title
};
if (gadget.state.has_more_views) {
if (options.has_more_views) {
header_dict.tab_url = url_list[0];
}
if (gadget.state.editable) {
if (options.editable) {
header_dict.save_action = true;
}
}
if (gadget.state.has_more_actions) {
if (options.has_more_actions) {
header_dict.actions_url = url_list[1];
}
//TODO: fix index (must be last index, not a number)
if (url_list[7]) {
header_dict.add_url = url_list[7];
if (url_list[url_list.length - 1]) {
header_dict.add_url = url_list[url_list.length - 1];
}
if (result_list[1]) {
header_dict.export_url = (
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.23842.17340.49459</string> </value>
<value> <string>975.29199.21743.1211</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1556637363.69</float>
<float>1556807969.14</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -92,10 +92,17 @@
})
.onStateChange(function () {
var gadget = this;
return gadget.declareGadget("gadget_officejs_form_view.html")
var fragment = document.createElement('div'),
gadget = this,
options;
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.renderGadget(gadget);
return form_view_gadget.render(gadget.state);
});
})
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.25263.50685.65109</string> </value>
<value> <string>975.29197.38946.55620</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1556658280.76</float>
<float>1556807973.08</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