frappe.pages["leaderboard"].on_page_load = function (wrapper) { frappe.leaderboard = new frappe.Leaderboard(wrapper); } frappe.Leaderboard = Class.extend({ init: function (parent) { frappe.ui.make_app_page({ parent: parent, title: "Leaderboard", single_column: false }); this.parent = parent; this.page = this.parent.page; this.page.sidebar.html(`
`); this.$sidebar_list = this.page.sidebar.find('ul'); // const list of doctypes this.doctypes = ["Customer", "Item", "Supplier", "Sales Partner"]; this.timespans = ["Week", "Month", "Quarter", "Year"]; this.desc_fields = ["total_amount", "total_request", "annual_billing", "commission_rate"]; this.filters = { "Customer": ["total_amount", "total_item_purchased"], "Item": ["total_request", "total_purchase", "avg_price"], "Supplier": ["annual_billing", "total_unpaid"], "Sales Partner": ["commission_rate", "target_qty", "target_amount"], }; // for saving current selected filters // TODO: revert to 0 index for doctype and timespan, and remove preset down const _initial_doctype = this.doctypes[0]; const _initial_timespan = this.timespans[0]; const _initial_filter = this.filters[_initial_doctype]; this.options = { selected_doctype: _initial_doctype, selected_filter: _initial_filter, selected_filter_item: _initial_filter[0], selected_timespan: _initial_timespan, }; this.message = null; this.make(); }, make: function () { var me = this; var $container = $(`No Item found