refactor: Replace Class.extend with native class

This commit is contained in:
Faris Ansari
2021-04-23 08:04:00 +05:30
parent 5e1cb5e4bc
commit 1fe891b287
44 changed files with 1200 additions and 1196 deletions

View File

@@ -2,8 +2,8 @@
// License: GNU General Public License v3. See license.txt
erpnext.StockAnalytics = erpnext.StockGridReport.extend({
init: function(wrapper, opts) {
erpnext.StockAnalytics = class StockAnalytics extends erpnext.StockGridReport {
constructor(wrapper, opts) {
var args = {
title: __("Stock Analytics"),
parent: $(wrapper).find('.layout-main'),
@@ -30,9 +30,9 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
if(opts) $.extend(args, opts);
this._super(args);
},
setup_columns: function() {
super(args);
}
setup_columns() {
var std_columns = [
{id: "name", name: __("Item"), field: "name", width: 300},
{id: "brand", name: __("Brand"), field: "brand", width: 100},
@@ -43,8 +43,9 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
this.make_date_range_columns();
this.columns = std_columns.concat(this.columns);
},
filters: [
}
filters = [
{fieldtype:"Select", label: __("Value or Qty"), fieldname: "value_or_qty",
options:[{label:__("Value"), value:"Value"}, {label:__("Quantity"), value:"Quantity"}],
filter: function(val, item, opts, me) {
@@ -66,20 +67,21 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
{label:__("Quarterly"), value:"Quarterly"},
{label:__("Yearly"), value:"Yearly"},
]}
],
setup_filters: function() {
]
setup_filters() {
var me = this;
this._super();
super.setup_filters();
this.trigger_refresh_on_change(["value_or_qty", "brand", "warehouse", "range"]);
this.show_zero_check();
},
init_filter_values: function() {
this._super();
}
init_filter_values() {
super.init_filter_values();
this.filter_inputs.range && this.filter_inputs.range.val('Monthly');
},
prepare_data: function() {
}
prepare_data() {
var me = this;
if(!this.data) {
@@ -112,8 +114,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
this.prepare_balances();
this.update_groups();
},
prepare_balances: function() {
}
prepare_balances() {
var me = this;
var from_date = frappe.datetime.str_to_obj(this.from_date);
var to_date = frappe.datetime.str_to_obj(this.to_date);
@@ -164,8 +166,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
item.closing_qty_value += diff;
}
}
},
update_groups: function() {
}
update_groups() {
var me = this;
$.each(this.data, function(i, item) {
// update groups
@@ -192,8 +194,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
}
}
});
},
show_stock_ledger: function(item_code) {
}
show_stock_ledger(item_code) {
frappe.route_options = {
item_code: item_code,
from_date: this.from_date,
@@ -201,5 +203,5 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
};
frappe.set_route("query-report", "Stock Ledger");
}
});
};