FIX: Clicking from one user badge to another was not updating badge

This commit is contained in:
Robin Ward 2015-03-30 12:47:00 -04:00
parent f8080c0138
commit 5f8bd16e7e
3 changed files with 10 additions and 13 deletions

View File

@ -1,20 +1,17 @@
import registerUnbound from 'discourse/helpers/register-unbound';
import { iconHTML } from 'discourse/helpers/fa-icon';
const Safe = Handlebars.SafeString;
registerUnbound('user-status', function(user) {
export default Ember.Handlebars.makeBoundHelper(function(user, args) {
if (!user) { return; }
var name = Handlebars.Utils.escapeExpression(user.get('name'));
const name = Handlebars.Utils.escapeExpression(user.get('name'));
const currentUser = args.hash.currentUser;
if(Discourse.User.currentProp("admin") || Discourse.User.currentProp("moderator")) {
if(user.get('admin')) {
var adminDesc = I18n.t('user.admin', {user: name});
return new Safe('<i class="fa fa-shield" title="' + adminDesc + '" alt="' + adminDesc + '"></i>');
}
if (currentUser && user.get('admin') && currentUser.get('staff')) {
return new Safe(iconHTML('shield', { label: I18n.t('user.admin', { user: name }) }));
}
if(user.get('moderator')){
var modDesc = I18n.t('user.moderator', {user: name});
return new Safe('<i class="fa fa-shield" title="' + modDesc + '" alt="' + modDesc + '"></i>');
if (user.get('moderator')) {
return new Safe(iconHTML('shield', { label: I18n.t('user.moderator', { user: name }) }));
}
});

View File

@ -5,7 +5,7 @@
<div class="names">
<span>
<h1 {{bind-attr class="staff new_user"}}>
{{#link-to 'user' user}}{{username}} {{user-status user}}{{/link-to}}
{{#link-to 'user' user}}{{username}} {{user-status user currentUser=currentUser}}{{/link-to}}
</h1>
{{#if user.name}}

View File

@ -61,7 +61,7 @@
</section>
<div class="primary-textual">
<h1>{{username}} {{user-status model}}</h1>
<h1>{{username}} {{user-status model currentUser=currentUser}}</h1>
<h2>{{name}}</h2>
{{#if title}}
<h3>{{title}}</h3>