How to overide stander js class like NumberCardWidget

export default class NumberCardWidget extends Widget {
constructor(opts) {
opts.shadow = true;
super(opts);
}

get_config() {
return {
name: this.name,
number_card_name: this.number_card_name,
label: this.label,
color: this.color,
hidden: this.hidden,
};
}a

i wnat to overide

setbody furnction

i tried somthing like that in my cutom app but not worked


import NumberCardWidget from "../../../../frappe/frappe/public/js/frappe/widgets/number_card_widget";

NumberCardWidget.prototype.set_body = function () {
  console.log("set_body custom ๐ŸŽ‰-------------------------------------");
  this.widget.addClass("number-widget-box");
  this.make_card();
};

and still the app call origibnal method set_body

Reference:

1 Like

many thanks pro for your help
i can overide the stander method only if it accessible through js namespace like

frappe.ui.form.CustomerQuickEntryForm = PartyQuickEntryForm;
frappe.ui.form.SupplierQuickEntryForm = PartyQuickEntryForm;

and its working ok

but i wnat to overide for class not linked with namesapece like the โ€œNumberCardWidgetโ€

import Widget from "./base_widget.js";

frappe.provide("frappe.utils");

export default class NumberCardWidget extends Widget {
	constructor(opts) {
		opts.shadow = true;
		super(opts);
	}

	get_config() {
		return {
			name: this.name,
			number_card_name: this.number_card_name,
			label: this.label,
			color: this.color,
			hidden: this.hidden,
		};
	}

and to acess it you have to acess through the file path also :disappointed_relieved:

this code will work if i but it in any frappe js stander js file โ€œfrappe/public/jsโ€


import NumberCardWidget from "../../../../../frappe/frappe/public/js/frappe/widgets/number_card_widget";

NumberCardWidget.prototype.set_body = function () {
	console.log(
		"set_body custom ๐ŸŽ‰-----------s---from inside---zzzzzddzzzzszz--------------------"
	);
	this.widget.addClass("number-widget-box");
	this.make_card();
};

but the issue that my cutom app will have seprate bundle so i think this the reson its not working :disappointed_relieved: