Commit 6430fd31 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: improve code to every change in select, display the graphic related to it

parent 5f52ed3a
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</head> </head>
<body> <body>
<div class="document_table"> <div class="graphic_section"></div>
</div> <div class="document_table"></div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>993.55171.44758.6877</string> </value> <value> <string>994.9738.18277.17732</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1628545474.29</float> <float>1629923258.92</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -1182,49 +1182,54 @@ ...@@ -1182,49 +1182,54 @@
}) })
); );
} }
gadget.element.insertBefore( domsugar(gadget.element.querySelector(".graphic_section"), [
domsugar("select", sub_element_list), domsugar("select", sub_element_list),
gadget.element.firstChild domsugar("div", {"class": "graphic_area"})
); ]);
}); });
}); });
} else if (modification_dict.hasOwnProperty("graphic_type") && } else if (modification_dict.hasOwnProperty("graphic_type") &&
modification_dict.graphic_type !== "") { modification_dict.graphic_type !== "") {
return result_queue return result_queue
.push(function () { .push(function () {
var div = domsugar("div", {"class": "graphic-section"}), return gadget.declareGadget('gadget_graphic.html', {
gadget_list = [],
domain_list = JSON.parse(gadget.state.domain_list_json);
gadget.element.insertBefore(div, gadget.element.firstChild);
gadget_list.push(
gadget.declareGadget('gadget_graphic.html', {
scope: 'gadget_graphic', scope: 'gadget_graphic',
element: div element: gadget.element.querySelector(".graphic_area")
})
);
for (i = 0; i < domain_list.length; i += 1) {
div = domsugar("div", {
"class": "graphic-section " + domain_list[i][0]
}); });
gadget.element.insertBefore(div, gadget.element.firstChild);
gadget_list.push(
gadget.declareGadget('gadget_graphic.html', {
scope: 'gadget_graphic_' + domain_list[i][0],
element: div
})
);
}
return RSVP.all(gadget_list);
}) })
.push(function (gadget_list) { .push(function (graphic_gadget) {
var default_param_list = JSON.parse(gadget.state.column_list_json), var group_by,
group_by_title,
column_list_json = JSON.parse(gadget.state.column_list_json),
domain_dict = JSON.parse(gadget.state.domain_dict_json), domain_dict = JSON.parse(gadget.state.domain_dict_json),
domain_list = [], domain_list = [],
queue_list = [],
group_by,
group_by_title,
domain_id, domain_id,
domain; domain;
for (i = 0; i < column_list_json.length; i += 1) {
if (column_list_json[i][0] === modification_dict.graphic_type) {
group_by = column_list_json[i][0];
group_by_title = column_list_json[i][1];
return graphic_gadget.render({
group_by: group_by,
query_by: {},
title: group_by_title,
list_method_template: gadget.state.list_method_template,
list_method: gadget.state.list_method,
layout: {
x: {
"title": group_by_title,
"key": group_by
},
y: {
"title": "Quantity"
}
}
});
}
}
for (domain_id in domain_dict) { for (domain_id in domain_dict) {
if (domain_dict.hasOwnProperty(domain_id)) { if (domain_dict.hasOwnProperty(domain_id)) {
domain = { domain = {
...@@ -1239,31 +1244,15 @@ ...@@ -1239,31 +1244,15 @@
domain_list.push(domain); domain_list.push(domain);
} }
} }
for (i = 0; i < default_param_list.length; i += 1) { for (i = 0; i < column_list_json.length; i += 1) {
if (default_param_list[i][0].indexOf("_state") !== -1) { if (column_list_json[i][0].indexOf("_state") !== -1) {
group_by = default_param_list[i][0]; group_by = column_list_json[i][0];
group_by_title = default_param_list[i][1]; group_by_title = column_list_json[i][1];
} }
} }
if (gadget_list) {
queue_list.push(gadget_list[0].render({
group_by: group_by,
query_by: {},
title: gadget.state.title,
list_method_template: gadget.state.list_method_template,
list_method: gadget.state.list_method,
layout: {
x: {
"title": group_by_title,
"key": group_by
},
y: {
"title": "Quantity"
}
}
}));
for (i = 0; i < domain_list.length; i += 1) { for (i = 0; i < domain_list.length; i += 1) {
queue_list.push(gadget_list[i + 1].render({ if (domain_list[i].domain_id === modification_dict.graphic_type) {
return graphic_gadget.render({
group_by: group_by, group_by: group_by,
query_by: {}, query_by: {},
title: gadget.state.title, title: gadget.state.title,
...@@ -1281,9 +1270,8 @@ ...@@ -1281,9 +1270,8 @@
"title": "Quantity" "title": "Quantity"
} }
} }
})); });
} }
return RSVP.all(queue_list);
} }
}); });
} }
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>994.21596.49508.22784</string> </value> <value> <string>994.22782.45811.61201</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1629853271.24</float> <float>1629924514.44</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -24,8 +24,5 @@ ...@@ -24,8 +24,5 @@
<div class="wrap"></div> <div class="wrap"></div>
</div> </div>
</div> </div>
<!--div class="bottom">
<input type="submit" class="ui-disabled" data-i18n="[value]Reset Filter" value="Reset Filter" disabled />
</div-->
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>994.1231.55372.30208</string> </value> <value> <string>994.15023.5523.52002</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1628710935.39</float> <float>1629926033.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global document, window, Option, rJS, RSVP, console, Array, SimpleQuery, Query, /*global document, window, Option, rJS, RSVP, console, Array, SimpleQuery, Query,
ComplexQuery, loopEventListener */ ComplexQuery, loopEventListener, domsugar */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Array, SimpleQuery, Query, ComplexQuery, (function (window, rJS, RSVP, Array, SimpleQuery, Query, ComplexQuery,
loopEventListener) { loopEventListener, domsugar) {
"use strict"; "use strict";
var color_list = ["#CCA08D", "#58ADC4", "#F9B39B", "#B75937", var color_list = ["#CCA08D", "#58ADC4", "#F9B39B", "#B75937",
...@@ -257,6 +257,7 @@ ...@@ -257,6 +257,7 @@
} }
return new RSVP.Queue(RSVP.all(queue_list)) return new RSVP.Queue(RSVP.all(queue_list))
.push(function (result_list) { .push(function (result_list) {
console.log(result_list);
var bar_chart = gadget.element.querySelector(".wrap"), var bar_chart = gadget.element.querySelector(".wrap"),
loader = gadget.element.querySelector(".graph-spinner"), loader = gadget.element.querySelector(".graph-spinner"),
graph_gadget = result_list[0], graph_gadget = result_list[0],
...@@ -375,7 +376,13 @@ ...@@ -375,7 +376,13 @@
}); });
} }
} }
console.log(data_list); if (data_list.length === 0) {
console.log("I am here");
return domsugar(gadget.element, [
domsugar("p", {"text": "No data"})
]);
}
console.log(data_list, data_list.length);
return graph_gadget.render({ return graph_gadget.render({
value: { value: {
data: data_list, data: data_list,
...@@ -395,4 +402,4 @@ ...@@ -395,4 +402,4 @@
}); });
}(window, rJS, RSVP, Array, SimpleQuery, Query, ComplexQuery, }(window, rJS, RSVP, Array, SimpleQuery, Query, ComplexQuery,
rJS.loopEventListener)); rJS.loopEventListener, domsugar));
\ No newline at end of file \ No newline at end of file
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>994.4064.4979.38536</string> </value> <value> <string>994.22799.44674.238</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1628808066.07</float> <float>1629926042.93</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