FEATURE: support "unlisted" badges.
This commit is contained in:
parent
db34b534e6
commit
6bbb083d47
|
@ -70,6 +70,13 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>
|
||||||
|
{{input type="checkbox" checked=listable disabled=readOnly}}
|
||||||
|
{{i18n admin.badges.listable}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#unless readOnly}}
|
{{#unless readOnly}}
|
||||||
<div class='buttons'>
|
<div class='buttons'>
|
||||||
<button {{action save}} {{bind-attr disabled=controller.disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>
|
<button {{action save}} {{bind-attr disabled=controller.disableSave}} class='btn btn-primary'>{{i18n admin.badges.save}}</button>
|
||||||
|
|
|
@ -117,6 +117,7 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
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'),
|
||||||
|
listable: !!this.get('listable'),
|
||||||
icon: this.get('icon')
|
icon: this.get('icon')
|
||||||
}
|
}
|
||||||
}).then(function(json) {
|
}).then(function(json) {
|
||||||
|
|
|
@ -30,13 +30,14 @@ class Admin::BadgesController < Admin::AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_badge_from_params(badge)
|
def update_badge_from_params(badge)
|
||||||
params.permit(:name, :description, :badge_type_id, :allow_title, :multiple_grant)
|
params.permit(:name, :description, :badge_type_id, :allow_title, :multiple_grant, :listable)
|
||||||
badge.name = params[:name]
|
badge.name = params[:name]
|
||||||
badge.description = params[:description]
|
badge.description = params[:description]
|
||||||
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.icon = params[:icon]
|
||||||
|
badge.listable = params[:listable]
|
||||||
badge
|
badge
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ class BadgesController < ApplicationController
|
||||||
skip_before_filter :check_xhr, only: [:index, :show]
|
skip_before_filter :check_xhr, only: [:index, :show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
badges = Badge.all.to_a
|
badges = Badge.where(listable: true).all.to_a
|
||||||
serialized = MultiJson.dump(serialize_data(badges, BadgeSerializer, root: "badges"))
|
serialized = MultiJson.dump(serialize_data(badges, BadgeSerializer, root: "badges"))
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class BadgeSerializer < ApplicationSerializer
|
class BadgeSerializer < ApplicationSerializer
|
||||||
attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant, :icon
|
attributes :id, :name, :description, :grant_count, :allow_title, :multiple_grant, :icon, :listable
|
||||||
|
|
||||||
has_one :badge_type
|
has_one :badge_type
|
||||||
end
|
end
|
||||||
|
|
|
@ -1873,6 +1873,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
|
||||||
|
listable: Show badge on the public badges page
|
||||||
icon: Icon
|
icon: Icon
|
||||||
|
|
||||||
lightbox:
|
lightbox:
|
||||||
|
|
Loading…
Reference in New Issue