Commit ba81cad6 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Rerender the existing form if possible

parent 0ce2a779
......@@ -67,25 +67,45 @@
/////////////////////////////////////////////////////////////////
.declareMethod('render', function (options) {
var group_list = options.form_definition.group_list,
rendered_form = options.erp5_document._embedded._view,
i,
j,
hash = "";
// Check the list of field to render
// If the list is different, DOM content will be dropped
// and recreated
for (i = 0; i < group_list.length; i += 1) {
hash += group_list[i][0];
for (j = 0; j < group_list[i][1].length; j += 1) {
if (rendered_form.hasOwnProperty(group_list[i][1][j][0])) {
hash += group_list[i][1][j][0];
}
}
}
return this.changeState({
erp5_document: options.erp5_document,
form_definition: options.form_definition,
hash: hash,
view: options.view
});
})
.declareMethod('updateDOM', function (modification_dict) {
var i,
erp5_document = options.erp5_document,
form_definition = options.form_definition,
erp5_document = this.state.erp5_document,
form_definition = this.state.form_definition,
rendered_form = erp5_document._embedded._view,
group_list = form_definition.group_list,
queue = new RSVP.Queue(),
form_gadget = this,
suboption_dict = {},
parent_element = document.createElement("div");
form_gadget.state_parameter_dict = options.form_gadget || {};
// XXX Hardcoded for searchfield - remove later!
if (form_definition.extended_search) {
suboption_dict.extended_search = form_definition.extended_search;
}
// XXX Hardcoded for listbox's hide functionality
suboption_dict.hide_enabled = form_definition.hide_enabled;
if (modification_dict.hasOwnProperty('hash')) {
form_gadget.props.gadget_list = [];
}
function addGroup(group) {
queue
......@@ -104,11 +124,20 @@
sandbox = "public",
field_element = document.createElement("div"),
renderered_field = rendered_form[field[0]],
suboptions = options[renderered_field.key] || suboption_dict;
// suboptions = options[renderered_field.key] || suboption_dict;
suboptions = {};
// XXX Hardcoded for searchfield - remove later!
if (form_definition.extended_search) {
suboptions.extended_search = form_definition.extended_search;
}
// XXX Hardcoded for listbox's hide functionality
suboptions.hide_enabled = form_definition.hide_enabled;
suboptions.field_url = getFieldTypeGadgetUrl(renderered_field.type);
suboptions.label = false;
suboptions.field_json = renderered_field;
suboptions.field_json.view = options.view;
suboptions.field_json.view = form_gadget.state.view;
if (group[0] !== "bottom") {
suboptions.label = true;
......@@ -116,13 +145,18 @@
return field_queue
.push(function () {
if (modification_dict.hasOwnProperty('hash')) {
return form_gadget.declareGadget('gadget_erp5_label_field.html', {
scope: renderered_field.key,
element: field_element,
sandbox: sandbox
});
}
return form_gadget.getDeclaredGadget(renderered_field.key);
})
.push(function (label_gadget) {
if (modification_dict.hasOwnProperty('hash')) {
//XXXXX Hardcoded to get one listbox gadget
//pt form list gadget will get this listbox's info
//then pass to search field gadget
......@@ -130,6 +164,7 @@
form_gadget.props.listbox_gadget = label_gadget;
}
form_gadget.props.gadget_list.push(label_gadget);
}
return label_gadget.render(suboptions);
})
.push(function () {
......@@ -155,19 +190,17 @@
return queue
.push(function () {
if (modification_dict.hasOwnProperty('hash')) {
var dom_element = form_gadget.element
.querySelector(".field_container");
while (dom_element.firstChild) {
dom_element.removeChild(dom_element.firstChild);
}
dom_element.appendChild(parent_element);
// return $(parent_element).trigger("create");
}
});
})
.declareMethod("getListboxInfo", function () {
//XXXXX get listbox gadget's info
var gadget = this;
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>954.24492.61471.3703</string> </value>
<value> <string>954.27320.12986.51029</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1475681076.93</float>
<float>1475762090.29</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