mirror of
https://github.com/discourse/discourse.git
synced 2025-02-03 16:43:00 +08:00
45 lines
990 B
JavaScript
45 lines
990 B
JavaScript
import debounce from 'discourse/lib/debounce';
|
|
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
|
|
|
export default Ember.Controller.extend({
|
|
application: Ember.inject.controller(),
|
|
queryParams: ["order", "asc", "filter", "type"],
|
|
order: null,
|
|
asc: null,
|
|
filter: "",
|
|
type: null,
|
|
|
|
@computed("model.extras.type_filters")
|
|
types(typeFilters) {
|
|
const types = [];
|
|
|
|
if (typeFilters) {
|
|
typeFilters.forEach(type => {
|
|
types.push({ id: type, name: I18n.t(`groups.index.${type}_groups`) });
|
|
});
|
|
}
|
|
|
|
return types;
|
|
},
|
|
|
|
@observes("filterInput")
|
|
_setFilter: debounce(function() {
|
|
this.set("filter", this.get("filterInput"));
|
|
}, 500),
|
|
|
|
@observes("model.canLoadMore")
|
|
_showFooter() {
|
|
this.set("application.showFooter", !this.get("model.canLoadMore"));
|
|
},
|
|
|
|
actions: {
|
|
loadMore() {
|
|
this.get('model').loadMore();
|
|
},
|
|
|
|
new() {
|
|
this.transitionToRoute("groups.new");
|
|
}
|
|
}
|
|
});
|