mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 06:02:47 +08:00
FIX: allow selection of no title
This commit is contained in:
parent
192e286b15
commit
4a2cc269ab
|
@ -18,7 +18,13 @@ export default Ember.ArrayController.extend({
|
|||
}
|
||||
}.property('saving'),
|
||||
|
||||
selectableUserBadges: Em.computed.filterBy('model', 'badge.allow_title', true),
|
||||
selectableUserBadges: function() {
|
||||
var items = this.get('model').filterBy('badge.allow_title', true);
|
||||
items.unshiftObject(Em.Object.create({
|
||||
badge: Discourse.Badge.create({name: I18n.t('badges.no_title')})
|
||||
}));
|
||||
return items;
|
||||
}.property('model'),
|
||||
|
||||
selectedUserBadge: function() {
|
||||
var selectedUserBadgeId = parseInt(this.get('selectedUserBadgeId'));
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{i18n badges.title}}</label>
|
||||
<label class="control-label"></label>
|
||||
<div class="controls">
|
||||
{{combo-box valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.name" content=selectableUserBadges}}
|
||||
{{combo-box valueAttribute="id" value=selectedUserBadgeId nameProperty="badge.displayName" content=selectableUserBadges}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -67,10 +67,13 @@ class UsersController < ApplicationController
|
|||
user = fetch_user_from_params
|
||||
guardian.ensure_can_edit!(user)
|
||||
|
||||
user_badge = UserBadge.find(params[:user_badge_id])
|
||||
if user_badge.user == user && user_badge.badge.allow_title?
|
||||
user_badge = UserBadge.find_by(id: params[:user_badge_id])
|
||||
if user_badge && user_badge.user == user && user_badge.badge.allow_title?
|
||||
user.title = user_badge.badge.name
|
||||
user.save!
|
||||
else
|
||||
user.title = ''
|
||||
user.save!
|
||||
end
|
||||
|
||||
render nothing: true
|
||||
|
|
|
@ -1953,6 +1953,7 @@ en:
|
|||
one: "1 granted"
|
||||
other: "%{count} granted"
|
||||
select_badge_for_title: Select a badge to use as your title
|
||||
no_title: "<no title>"
|
||||
badge:
|
||||
editor:
|
||||
name: Editor
|
||||
|
|
Loading…
Reference in New Issue
Block a user