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
2 changed files with 24 additions and 10 deletions

View File

@ -37,10 +37,18 @@
{{#if this.canSelectTitle}} {{#if this.canSelectTitle}}
<div class="badge-set-title {{if this.hiddenSetTitle 'hidden' ''}}"> <div class="badge-set-title {{if this.hiddenSetTitle 'hidden' ''}}">
<BadgeTitle <PluginOutlet
@selectableUserBadges={{this.selectableUserBadges}} @name="selectable-user-badges"
@closeAction={{this.toggleSetUserTitle}} @outletArgs={{hash
/> selectableUserBadges=this.selectableUserBadges
closeAction=this.toggleSetUserTitle
}}
>
<BadgeTitle
@selectableUserBadges={{this.selectableUserBadges}}
@closeAction={{this.toggleSetUserTitle}}
/>
</PluginOutlet>
</div> </div>
{{/if}} {{/if}}
</div> </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, const title = attrs.user_title,
titleIsGroup = attrs.title_is_group; titleIsGroup = attrs.title_is_group;
if (title && title.length) { if (title && title.length) {
contents.push( contents.push(
this.attach("poster-name-title", { 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) { addUserStatus(contents, attrs) {