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

This commit is contained in:
Joffrey JAFFEUX 2021-10-20 14:28:49 +02:00 committed by GitHub
parent ae45c5efb5
commit adb302f801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
},
});