mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 21:43:49 +08:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import discourseComputed from "discourse-common/utils/decorators";
|
|
import { debounce } from "@ember/runloop";
|
|
import Controller from "@ember/controller";
|
|
import { INPUT_DELAY } from "discourse-common/config/environment";
|
|
|
|
const { get } = Ember;
|
|
|
|
export default Controller.extend({
|
|
filter: null,
|
|
|
|
@discourseComputed(
|
|
"model.[]",
|
|
"filter",
|
|
"siteSettings.dashboard_hidden_reports"
|
|
)
|
|
filterReports(reports, filter) {
|
|
if (filter) {
|
|
filter = filter.toLowerCase();
|
|
reports = reports.filter(report => {
|
|
return (
|
|
(get(report, "title") || "").toLowerCase().indexOf(filter) > -1 ||
|
|
(get(report, "description") || "").toLowerCase().indexOf(filter) > -1
|
|
);
|
|
});
|
|
}
|
|
|
|
const hiddenReports = (this.siteSettings.dashboard_hidden_reports || "")
|
|
.split("|")
|
|
.filter(Boolean);
|
|
reports = reports.filter(report => !hiddenReports.includes(report.type));
|
|
|
|
return reports;
|
|
},
|
|
|
|
actions: {
|
|
filterReports(filter) {
|
|
debounce(this, this._performFiltering, filter, INPUT_DELAY);
|
|
}
|
|
},
|
|
|
|
_performFiltering(filter) {
|
|
this.set("filter", filter);
|
|
}
|
|
});
|