mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 20:26:28 +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">
|
<form class="form-horizontal">
|
||||||
<div>
|
<div>
|
||||||
<label for="name">{{i18n admin.badges.name}}</label>
|
<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>
|
</div>
|
||||||
|
|
||||||
{{#if showDisplayName}}
|
{{#if showDisplayName}}
|
||||||
|
@ -33,6 +33,11 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="name">{{i18n admin.badges.icon}}</label>
|
||||||
|
{{input type="text" name="name" value=icon disabled=readonly}}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="badge_type_id">{{i18n admin.badges.badge_type}}</label>
|
<label for="badge_type_id">{{i18n admin.badges.badge_type}}</label>
|
||||||
{{view Ember.Select name="badge_type_id" value=badge_type_id
|
{{view Ember.Select name="badge_type_id" value=badge_type_id
|
||||||
|
|
|
@ -7,5 +7,9 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
showGrantCount: function() {
|
showGrantCount: function() {
|
||||||
return this.get('count') && this.get('count') > 1;
|
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'),
|
description: this.get('description'),
|
||||||
badge_type_id: this.get('badge_type_id'),
|
badge_type_id: this.get('badge_type_id'),
|
||||||
allow_title: !!this.get('allow_title'),
|
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) {
|
}).then(function(json) {
|
||||||
self.updateFromJson(json);
|
self.updateFromJson(json);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{{#link-to 'badges.show' badge}}
|
{{#link-to 'badges.show' badge}}
|
||||||
<span {{bind-attr class=":user-badge badgeTypeClassName" data-badge-name="badge.name" title="badge.displayDescription"}}>
|
<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}}
|
{{badge.displayName}}
|
||||||
{{#if showGrantCount}}
|
{{#if showGrantCount}}
|
||||||
<span class="count">(× {{count}})</span>
|
<span class="count">(× {{count}})</span>
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Admin::BadgesController < Admin::AdminController
|
||||||
badge.badge_type = BadgeType.find(params[:badge_type_id])
|
badge.badge_type = BadgeType.find(params[:badge_type_id])
|
||||||
badge.allow_title = params[:allow_title]
|
badge.allow_title = params[:allow_title]
|
||||||
badge.multiple_grant = params[:multiple_grant]
|
badge.multiple_grant = params[:multiple_grant]
|
||||||
|
badge.icon = params[:icon]
|
||||||
badge
|
badge
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class BadgeSerializer < ApplicationSerializer
|
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
|
has_one :badge_type
|
||||||
end
|
end
|
||||||
|
|
|
@ -1856,6 +1856,7 @@ en:
|
||||||
no_badges: There are no badges that can be granted.
|
no_badges: There are no badges that can be granted.
|
||||||
allow_title: Allow badge to be used as a title
|
allow_title: Allow badge to be used as a title
|
||||||
multiple_grant: Can be granted multiple times
|
multiple_grant: Can be granted multiple times
|
||||||
|
icon: Icon
|
||||||
|
|
||||||
lightbox:
|
lightbox:
|
||||||
download: "download"
|
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