discourse-data-explorer/assets/javascripts/discourse/routes/group-reports-index.js.es6

39 lines
831 B
Plaintext
Raw Normal View History

import { ajax } from "discourse/lib/ajax";
2020-05-12 14:41:26 -04:00
import DiscourseRoute from "discourse/routes/discourse";
2020-05-12 14:41:26 -04:00
export default DiscourseRoute.extend({
controllerName: "group-reports-index",
model() {
const group = this.modelFor("group");
return ajax(`/g/${group.name}/reports`)
2020-09-04 07:23:11 -04:00
.then((queries) => {
return {
model: queries,
2020-09-04 07:23:11 -04:00
group,
};
})
2019-09-11 11:52:40 -04:00
.catch(() => this.transitionTo("group.members", group));
},
2019-09-11 11:30:39 -04:00
afterModel(model) {
if (
!model.group.get("is_group_user") &&
!(this.currentUser && this.currentUser.admin)
) {
2019-09-11 11:30:39 -04:00
this.transitionTo("group.members", model.group);
}
},
setupController(controller, model) {
controller.setProperties(model);
},
actions: {
refreshModel() {
this.refresh();
return false;
2020-09-04 07:23:11 -04:00
},
},
});