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