From 14cac0bc62f4eb3d24bf74e2f08d125a1f263e47 Mon Sep 17 00:00:00 2001 From: Boxiang Sun <boxiang.sun@nexedi.com> Date: Tue, 12 Sep 2017 15:59:27 +0000 Subject: [PATCH] erp5_officejs_support_request_ui: Fix the listbox always loading problem. When the homepage refreshed with "field_listbox_begin_from", the listbox always on loading state. We should not call child gadget's "changeState" directly. Instead, we need to call child(listbox) render in parent render. Which can let the child listbox aware of the parameter change in the parent gadget. --- .../gadget_supportrequest_homepage_js.js | 39 +++++++------------ .../gadget_supportrequest_homepage_js.xml | 4 +- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.js b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.js index 2aeaf07647..716f4231c9 100644 --- a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.js +++ b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.js @@ -88,12 +88,13 @@ render: true }) .push(function () { - return gadget.getUrlParameter('field_listbox_begin_from'); - }) - .push(function (field_listbox_begin_from) { - return gadget.changeState({ - field_listbox_begin_from: field_listbox_begin_from - }); + return gadget.getDeclaredGadget("last") + .push(function (listbox) { + return listbox.render({ + jio_key: gadget.property_dict.option_dict.listbox_jio_key, + view: gadget.property_dict.option_dict.listbox_gadget + }); + }); }) .push(function () { return gadget.updateHeader({ @@ -250,21 +251,6 @@ return erp5_form.changeState({erp5_form: JSON.stringify(tmp)}); }); } - if (modification_dict.hasOwnProperty("field_listbox_begin_from")) { - // render the erp5 form - queue - .push(function () { - return gadget.getDeclaredGadget("last"); - }) - .push(function (result_list) { - var erp5_form = result_list, - tmp; - - tmp = JSON.parse(erp5_form.state.erp5_form); - tmp.field_listbox_begin_from = modification_dict.field_listbox_begin_from; - return erp5_form.changeState({erp5_form: JSON.stringify(tmp)}); - }); - } if (modification_dict.hasOwnProperty("render")) { queue .push(function () { @@ -292,12 +278,13 @@ if (last_href === undefined) { throw new Error('Cant find the list document view'); } - gadget.property_dict.option_dict = {graph_gadget: "unsafe/gadget_field_graph_echarts.html"}; + gadget.property_dict.option_dict = { + graph_gadget: "unsafe/gadget_field_graph_echarts.html", + listbox_gadget: last_href, + listbox_jio_key: "support_request_module" + }; + return RSVP.all([ - result_list[1].render({ - jio_key: "support_request_module", - view: last_href - }), gadget.renderGraph() //Launched as service, not blocking ]); }); diff --git a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.xml b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.xml index 87100fe11a..e35c20053f 100644 --- a/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.xml +++ b/bt5/erp5_officejs_support_request_ui/PathTemplateItem/web_page_module/gadget_supportrequest_homepage_js.xml @@ -236,7 +236,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>962.1258.50557.40021</string> </value> + <value> <string>962.5582.22272.14165</string> </value> </item> <item> <key> <string>state</string> </key> @@ -254,7 +254,7 @@ </tuple> <state> <tuple> - <float>1505136885.5</float> + <float>1505396121.35</float> <string>UTC</string> </tuple> </state> -- 2.30.9