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