This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/badge-title.js.es6
Bianca Nenciu ac8bc04ad7 Set user title from the badge view (#5049)
* title info under notification

* create badge-title as component

* display available titles, close button

* remove visual feedback when grant new badge

* Made changes after review.

* Some minor fixes.
2017-08-17 16:32:37 -04:00

29 lines
752 B
JavaScript

import { ajax } from 'discourse/lib/ajax';
import BadgeSelectController from 'discourse/mixins/badge-select-controller';
export default Ember.Component.extend(BadgeSelectController, {
classNames: ["badge-title"],
saved: false,
saving: false,
actions: {
save() {
this.setProperties({ saved: false, saving: true });
ajax(this.get('user.path') + "/preferences/badge_title", {
type: "PUT",
data: { user_badge_id: this.get('selectedUserBadgeId') }
}).then(() => {
this.setProperties({
saved: true,
saving: false,
"user.title": this.get('selectedUserBadge.badge.name')
});
}, () => {
bootbox.alert(I18n.t('generic_error'));
});
}
}
});