mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 20:33:38 +08:00
Add ability to specify custom font awesome icon for badges.
This commit is contained in:
parent
7fa972676a
commit
e0fd1f6f5e
|
@ -23,7 +23,7 @@
|
|||
<form class="form-horizontal">
|
||||
<div>
|
||||
<label for="name">{{i18n admin.badges.name}}</label>
|
||||
{{input type="text" name="name" value=name disabled=readOnly}}
|
||||
{{input type="text" name="name" value=name disabled=readonly}}
|
||||
</div>
|
||||
|
||||
{{#if showDisplayName}}
|
||||
|
@ -33,6 +33,11 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div>
|
||||
<label for="name">{{i18n admin.badges.icon}}</label>
|
||||
{{input type="text" name="name" value=icon disabled=readonly}}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="badge_type_id">{{i18n admin.badges.badge_type}}</label>
|
||||
{{view Ember.Select name="badge_type_id" value=badge_type_id
|
||||
|
|
|
@ -7,5 +7,9 @@ export default Ember.Component.extend({
|
|||
|
||||
showGrantCount: function() {
|
||||
return this.get('count') && this.get('count') > 1;
|
||||
}.property('count')
|
||||
}.property('count'),
|
||||
|
||||
isIcon: function() {
|
||||
return this.get('badge.icon').match(/^fa-/);
|
||||
}.property('badge.icon')
|
||||
});
|
||||
|
|
|
@ -116,7 +116,8 @@ Discourse.Badge = Discourse.Model.extend({
|
|||
description: this.get('description'),
|
||||
badge_type_id: this.get('badge_type_id'),
|
||||
allow_title: !!this.get('allow_title'),
|
||||
multiple_grant: !!this.get('multiple_grant')
|
||||
multiple_grant: !!this.get('multiple_grant'),
|
||||
icon: this.get('icon')
|
||||
}
|
||||
}).then(function(json) {
|
||||
self.updateFromJson(json);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{{#link-to 'badges.show' badge}}
|
||||
<span {{bind-attr class=":user-badge badgeTypeClassName" data-badge-name="badge.name" title="badge.displayDescription"}}>
|
||||
<i class='fa fa-certificate'></i>
|
||||
{{#if isIcon}}
|
||||
<i {{bind-attr class=":fa badge.icon"}}></i>
|
||||
{{/if}}
|
||||
{{badge.displayName}}
|
||||
{{#if showGrantCount}}
|
||||
<span class="count">(× {{count}})</span>
|
||||
|
|
|
@ -36,6 +36,7 @@ class Admin::BadgesController < Admin::AdminController
|
|||
badge.badge_type = BadgeType.find(params[:badge_type_id])
|
||||
badge.allow_title = params[:allow_title]
|
||||
badge.multiple_grant = params[:multiple_grant]
|
||||
badge.icon = params[:icon]
|
||||
badge
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class BadgeSerializer < ApplicationSerializer
|
||||
attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant
|
||||
attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant, :icon
|
||||
|
||||
has_one :badge_type
|
||||
end
|
||||
|
|
|
@ -1856,6 +1856,7 @@ en:
|
|||
no_badges: There are no badges that can be granted.
|
||||
allow_title: Allow badge to be used as a title
|
||||
multiple_grant: Can be granted multiple times
|
||||
icon: Icon
|
||||
|
||||
lightbox:
|
||||
download: "download"
|
||||
|
|
5
db/migrate/20140610012833_add_icon_to_badges.rb
Normal file
5
db/migrate/20140610012833_add_icon_to_badges.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddIconToBadges < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :badges, :icon, :string, default: "fa-certificate"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user