refactor(analytics report): linting

This commit is contained in:
hasnain2808@gmail.com 2020-12-25 16:34:43 +05:30
parent 61b92b312a
commit 46d5f4c7f1
2 changed files with 21 additions and 20 deletions

View File

@ -87,12 +87,18 @@ frappe.query_reports["Purchase Analytics"] = {
row_name = data[2].content;
length = data.length;
if (tree_type == "Supplier" || tree_type == "Item") {
if (tree_type == "Supplier") {
row_values = data
.slice(4, length - 1)
.map(function (column) {
return column.content;
});
} else if (tree_type == "Item") {
row_values = data
.slice(5, length - 1)
.map(function (column) {
return column.content;
});
} else {
row_values = data
.slice(3, length - 1)
@ -109,17 +115,15 @@ frappe.query_reports["Purchase Analytics"] = {
let raw_data = frappe.query_report.chart.data;
let new_datasets = raw_data.datasets;
let found = false;
for (let i = 0; i < new_datasets.length; i++) {
if (new_datasets[i].name == row_name) {
found = true;
new_datasets.splice(i, 1);
break;
let element_found = new_datasets.some((element, index, array)=>{
if(element.name == row_name){
array.splice(index, 1)
return true
}
}
return false
})
if (!found) {
if (!element_found) {
new_datasets.push(entry);
}
let new_data = {

View File

@ -76,7 +76,6 @@ frappe.query_reports["Sales Analytics"] = {
events: {
onCheckRow: function (data) {
if (!data) return;
const data_doctype = $(
data[2].html
)[0].attributes.getNamedItem("data-doctype").value;
@ -114,17 +113,15 @@ frappe.query_reports["Sales Analytics"] = {
let raw_data = frappe.query_report.chart.data;
let new_datasets = raw_data.datasets;
let found = false;
for (let i = 0; i < new_datasets.length; i++) {
if (new_datasets[i].name == row_name) {
found = true;
new_datasets.splice(i, 1);
break;
let element_found = new_datasets.some((element, index, array)=>{
if(element.name == row_name){
array.splice(index, 1)
return true
}
}
return false
})
if (!found) {
if (!element_found) {
new_datasets.push(entry);
}