diff --git a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js index 76cd13c24a3..dc7d5735b26 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js @@ -27,6 +27,7 @@ const FORM_FIELDS = [ "badge_grouping_id", "trigger", "badge_type_id", + "show_in_post_header", ]; export default class AdminBadgesShowController extends Controller { @@ -40,8 +41,6 @@ export default class AdminBadgesShowController extends Controller { @tracked model; @tracked previewLoading = false; @tracked selectedGraphicType = null; - @tracked userBadges; - @tracked userBadgesAll; @cached get formData() { @@ -80,6 +79,17 @@ export default class AdminBadgesShowController extends Controller { return this.model.system; } + @action + postHeaderDescription(data) { + return this.disableBadgeOnPosts(data) && !data.system; + } + + @action + disableBadgeOnPosts(data) { + const { listable, show_posts } = data; + return !listable || !show_posts; + } + setup() { // this is needed because the model doesnt have default values // Using `set` here isn't ideal, but we don't know that tracking is set up on the model yet. diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs index 67735c6bf64..1548b18feae 100644 --- a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs +++ b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs @@ -245,7 +245,7 @@ - + + + + + + + {{#if (this.postHeaderDescription data)}} + {{i18n "admin.badges.show_in_post_header_disabled"}} + {{/if}} + + diff --git a/app/assets/javascripts/discourse/app/components/badge-button.gjs b/app/assets/javascripts/discourse/app/components/badge-button.gjs index 2abddb36646..c5d22a5bca5 100644 --- a/app/assets/javascripts/discourse/app/components/badge-button.gjs +++ b/app/assets/javascripts/discourse/app/components/badge-button.gjs @@ -10,6 +10,10 @@ export default class BadgeButton extends Component { } } + get showName() { + return this.args.showName ?? true; + } + diff --git a/app/assets/javascripts/discourse/app/components/user-badge.gjs b/app/assets/javascripts/discourse/app/components/user-badge.gjs index a16286d6faf..0c2f3b0056d 100644 --- a/app/assets/javascripts/discourse/app/components/user-badge.gjs +++ b/app/assets/javascripts/discourse/app/components/user-badge.gjs @@ -15,7 +15,7 @@ export default class UserBadge extends Component {