discourse/app/assets/javascripts/admin/controllers/admin-dashboard-next-reports.js.es6
Joffrey JAFFEUX e655e1863f
UX: Adding reports dashboard tab, new layout, report descriptions (#6790)
Co-Authored-By: Kris  <shout@k-ris.com>
2018-12-19 14:44:43 +01:00

31 lines
728 B
JavaScript

import computed from "ember-addons/ember-computed-decorators";
const { get } = Ember;
export default Ember.Controller.extend({
filter: null,
@computed("model.[]", "filter")
filterReports(reports, filter) {
if (filter) {
filter = filter.toLowerCase();
return reports.filter(report => {
return (
(get(report, "title") || "").toLowerCase().indexOf(filter) > -1 ||
(get(report, "description") || "").toLowerCase().indexOf(filter) > -1
);
});
}
return reports;
},
actions: {
filterReports(filter) {
Ember.run.debounce(this, this._performFiltering, filter, 250);
}
},
_performFiltering(filter) {
this.set("filter", filter);
}
});