DEV: Add helpers to customize poster title (#29156)

* DEV: Add helpers to customize poster title

* fix formatting issues

* Update app/assets/javascripts/discourse/app/templates/badges/show.hbs

Co-authored-by: Jarek Radosz <jradosz@gmail.com>

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Amanda Alves Branquinho 2024-10-10 21:44:35 +09:00 committed by GitHub
parent 3c03d9b1e5
commit 5b69329656
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 10 deletions

View File

@ -37,10 +37,18 @@
{{#if this.canSelectTitle}}
<div class="badge-set-title {{if this.hiddenSetTitle 'hidden' ''}}">
<BadgeTitle
@selectableUserBadges={{this.selectableUserBadges}}
@closeAction={{this.toggleSetUserTitle}}
/>
<PluginOutlet
@name="selectable-user-badges"
@outletArgs={{hash
selectableUserBadges=this.selectableUserBadges
closeAction=this.toggleSetUserTitle
}}
>
<BadgeTitle
@selectableUserBadges={{this.selectableUserBadges}}
@closeAction={{this.toggleSetUserTitle}}
/>
</PluginOutlet>
</div>
{{/if}}
</div>

View File

@ -167,8 +167,20 @@ export default createWidget("poster-name", {
);
}
this.buildTitleObject(attrs, contents);
if (this.siteSettings.enable_user_status) {
this.addUserStatus(contents, attrs);
}
return contents;
},
buildTitleObject(attrs, contents) {
const primaryGroupName = attrs.primary_group_name;
const title = attrs.user_title,
titleIsGroup = attrs.title_is_group;
if (title && title.length) {
contents.push(
this.attach("poster-name-title", {
@ -178,12 +190,6 @@ export default createWidget("poster-name", {
})
);
}
if (this.siteSettings.enable_user_status) {
this.addUserStatus(contents, attrs);
}
return contents;
},
addUserStatus(contents, attrs) {