discourse/app/assets/javascripts/admin/addon/routes/admin-user-badges.js
David Taylor 48193767bf DEV: Sort imports
Automatically generated by `eslint --fix` to satisfy the updated configuration
2023-10-10 21:46:54 +01:00

28 lines
879 B
JavaScript

import Badge from "discourse/models/badge";
import UserBadge from "discourse/models/user-badge";
import DiscourseRoute from "discourse/routes/discourse";
export default class AdminUserBadgesRoute extends DiscourseRoute {
model() {
const username = this.modelFor("adminUser").get("username");
return UserBadge.findByUsername(username);
}
setupController(controller, model) {
// Find all badges.
controller.set("loading", true);
Badge.findAll().then(function (badges) {
controller.set("badges", badges);
if (badges.length > 0) {
let grantableBadges = controller.get("availableBadges");
if (grantableBadges.length > 0) {
controller.set("selectedBadgeId", grantableBadges[0].get("id"));
}
}
controller.set("loading", false);
});
// Set the model.
controller.set("model", model);
}
}