FIX: fix select badge as user title on badge page (#7682)

This commit is contained in:
Maja Komel 2019-06-04 10:19:30 +02:00 committed by Sam
parent 5819e446dd
commit 2863e7c181
3 changed files with 9 additions and 6 deletions

View File

@ -13,16 +13,19 @@ export default Ember.Component.extend(BadgeSelectController, {
const badge_id = this.selectedUserBadgeId || 0;
ajax(this.get("user.path") + "/preferences/badge_title", {
ajax(this.currentUser.path + "/preferences/badge_title", {
type: "PUT",
data: { user_badge_id: badge_id }
}).then(
() => {
this.setProperties({
saved: true,
saving: false,
"user.title": this.get("selectedUserBadge.badge.name")
saving: false
});
this.currentUser.set(
"title",
this.get("selectedUserBadge.badge.name")
);
},
() => {
bootbox.alert(I18n.t("generic_error"));

View File

@ -30,15 +30,16 @@ export default Discourse.Route.extend({
},
afterModel(model, transition) {
const username =
const usernameFromParams =
transition.to.queryParams && transition.to.queryParams.username;
const userBadgesGrant = UserBadge.findByBadgeId(model.get("id"), {
username
username: usernameFromParams
}).then(userBadges => {
this.userBadgesGrant = userBadges;
});
const username = this.currentUser && this.currentUser.username_lower;
const userBadgesAll = UserBadge.findByUsername(username).then(
userBadges => {
this.userBadgesAll = userBadges;

View File

@ -8,7 +8,6 @@
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
{{combo-box
value=selectedUserBadgeId