mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 04:53:54 +08:00
b4f8ea6ade
A previous refactor has moved this function in the controller instead of the route making it inaccessible to the modal. This commit is fixing this and also adding a spec.
32 lines
708 B
JavaScript
32 lines
708 B
JavaScript
import { get } from "@ember/object";
|
|
import Route from "@ember/routing/route";
|
|
import { service } from "@ember/service";
|
|
import Badge from "discourse/models/badge";
|
|
import I18n from "discourse-i18n";
|
|
|
|
export default class AdminBadgesShowRoute extends Route {
|
|
@service dialog;
|
|
|
|
serialize(m) {
|
|
return { badge_id: get(m, "id") || "new" };
|
|
}
|
|
|
|
model(params) {
|
|
if (params.badge_id === "new") {
|
|
return Badge.create({
|
|
name: I18n.t("admin.badges.new_badge"),
|
|
});
|
|
}
|
|
return this.modelFor("adminBadges").findBy(
|
|
"id",
|
|
parseInt(params.badge_id, 10)
|
|
);
|
|
}
|
|
|
|
setupController(controller) {
|
|
super.setupController(...arguments);
|
|
|
|
controller.setup();
|
|
}
|
|
}
|