2022-12-13 08:53:08 +08:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
export default class AdminWebHooksEditRoute extends DiscourseRoute {
|
2022-12-13 08:53:08 +08:00
|
|
|
serialize(model) {
|
|
|
|
return { web_hook_id: model.id || "new" };
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2022-12-13 08:53:08 +08:00
|
|
|
|
|
|
|
model(params) {
|
|
|
|
if (params.web_hook_id === "new") {
|
|
|
|
return this.store.createRecord("web-hook");
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.store.find("web-hook", params.web_hook_id);
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2022-12-13 08:53:08 +08:00
|
|
|
|
|
|
|
setupController(controller, model) {
|
2023-03-15 21:17:51 +08:00
|
|
|
super.setupController(...arguments);
|
2022-12-13 08:53:08 +08:00
|
|
|
|
|
|
|
if (model.get("isNew")) {
|
|
|
|
model.set(
|
|
|
|
"web_hook_event_types",
|
|
|
|
this.controllerFor("adminWebHooks").defaultEventTypes
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.set("saved", false);
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
|
|
|
}
|