Skip to content

A platform for community discussion. Free, open, simple.

DEV: drops jquery usage un admin-report-chart (#14661)

Joffrey JAFFEUXadb302f8011e
diff --git a/app/assets/javascripts/admin/addon/components/admin-report-chart.js b/app/assets/javascripts/admin/addon/components/admin-report-chart.js
index 7711ca8d3dc..1c4ad1caa3a 100644
--- a/app/assets/javascripts/admin/addon/components/admin-report-chart.js
+++ b/app/assets/javascripts/admin/addon/components/admin-report-chart.js
@@ -5,6 +5,7 @@ import loadScript from "discourse/lib/load-script";
import { makeArray } from "discourse-common/lib/helpers";
import { number } from "discourse/lib/formatter";
import { schedule } from "@ember/runloop";
+import { bind } from "discourse-common/utils/decorators";
export default Component.extend({
classNames: ["admin-report-chart"],
@@ -12,23 +13,16 @@ export default Component.extend({
total: 0,
options: null,
- init() {
- this._super(...arguments);
-
- this.resizeHandler = () =>
- discourseDebounce(this, this._scheduleChartRendering, 500);
- },
-
didInsertElement() {
this._super(...arguments);
- $(window).on("resize.chart", this.resizeHandler);
+ window.addEventListener("resize", this._resizeHandler);
},
willDestroyElement() {
this._super(...arguments);
- $(window).off("resize.chart", this.resizeHandler);
+ window.removeEventListener("resize", this._resizeHandler);
this._resetChart();
},
@@ -179,4 +173,9 @@ export default Component.extend({
_applyChartGrouping(model, data, options) {
return Report.collapse(model, data, options.chartGrouping);
},
+
+ @bind
+ _resizeHandler() {
+ discourseDebounce(this, this._scheduleChartRendering, 500);
+ },
});