2019-10-31 16:28:10 -04:00
|
|
|
import { get } from "@ember/object";
|
2019-10-31 13:37:24 -04:00
|
|
|
import { isEmpty } from "@ember/utils";
|
2019-10-22 09:46:10 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
|
|
|
|
export default DiscourseRoute.extend({
|
2016-06-15 13:49:57 -04:00
|
|
|
serialize(model) {
|
2018-06-15 11:03:24 -04:00
|
|
|
return { web_hook_id: model.get("id") || "new" };
|
2016-06-15 13:49:57 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
model(params) {
|
2018-06-15 11:03:24 -04:00
|
|
|
if (params.web_hook_id === "new") {
|
|
|
|
return this.store.createRecord("web-hook");
|
2016-06-15 13:49:57 -04:00
|
|
|
}
|
2019-10-31 16:28:10 -04:00
|
|
|
return this.store.find("web-hook", get(params, "web_hook_id"));
|
2016-06-15 13:49:57 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2019-11-01 13:57:22 -04:00
|
|
|
if (model.get("isNew") || isEmpty(model.get("web_hook_event_types"))) {
|
2018-06-15 11:03:24 -04:00
|
|
|
model.set("web_hook_event_types", controller.get("defaultEventTypes"));
|
2016-06-15 13:49:57 -04:00
|
|
|
}
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
model.set("category_ids", model.get("category_ids"));
|
2018-12-05 04:14:06 -05:00
|
|
|
model.set("tag_names", model.get("tag_names"));
|
2018-06-15 11:03:24 -04:00
|
|
|
model.set("group_ids", model.get("group_ids"));
|
2016-06-15 13:49:57 -04:00
|
|
|
controller.setProperties({ model, saved: false });
|
|
|
|
},
|
|
|
|
|
|
|
|
renderTemplate() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.render("admin/templates/web-hooks-show", { into: "adminApi" });
|
2016-06-15 13:49:57 -04:00
|
|
|
}
|
|
|
|
});
|