2019-09-11 10:09:41 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2020-05-12 14:41:26 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2019-09-11 10:09:41 -04:00
|
|
|
|
2020-05-12 14:41:26 -04:00
|
|
|
export default DiscourseRoute.extend({
|
2019-09-11 10:09:41 -04:00
|
|
|
controllerName: "group-reports-show",
|
|
|
|
|
|
|
|
model(params) {
|
|
|
|
const group = this.modelFor("group");
|
|
|
|
return ajax(`/g/${group.name}/reports/${params.query_id}`)
|
2020-09-04 07:23:11 -04:00
|
|
|
.then((response) => {
|
2020-06-05 12:56:53 -04:00
|
|
|
const queryParamInfo = response.query.param_info;
|
|
|
|
const queryParams = queryParamInfo.reduce((acc, param) => {
|
|
|
|
acc[param.identifier] = param.default;
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
|
2019-09-11 10:09:41 -04:00
|
|
|
return {
|
2020-06-05 12:56:53 -04:00
|
|
|
model: Object.assign({ params: queryParams }, response.query),
|
2020-09-04 07:23:11 -04:00
|
|
|
group,
|
2019-09-11 10:09:41 -04:00
|
|
|
};
|
|
|
|
})
|
2019-09-11 11:30:39 -04:00
|
|
|
.catch(() => {
|
2019-09-11 10:09:41 -04:00
|
|
|
this.transitionTo("group.members", group);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
controller.setProperties(model);
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
refreshModel() {
|
|
|
|
this.refresh();
|
|
|
|
return false;
|
2020-09-04 07:23:11 -04:00
|
|
|
},
|
|
|
|
},
|
2019-09-11 10:09:41 -04:00
|
|
|
});
|