UX: add href to badge title

This commit is contained in:
Régis Hanol 2017-04-10 21:39:19 +02:00
parent b3761653b3
commit f0778c50bf
5 changed files with 7 additions and 30 deletions

View File

@ -1,37 +1,14 @@
import computed from 'ember-addons/ember-computed-decorators';
import DiscourseURL from 'discourse/lib/url';
import { sanitize, emojiUnescape } from 'discourse/lib/text';
export default Ember.Component.extend({
size: 'medium',
classNameBindings: [':badge-card', 'size', 'badge.slug', 'navigateOnClick:hyperlink'],
click(e){
if (e.target && e.target.nodeName === "A") {
return true;
}
if (!this.get('navigateOnClick')) {
return false;
}
var url = this.get('badge.url');
const username = this.get('username');
if (username) {
url = url + "?username=" + encodeURIComponent(username);
}
DiscourseURL.routeTo(url);
return true;
},
classNameBindings: [':badge-card', 'size', 'badge.slug'],
@computed('count', 'badge.grant_count')
displayCount(count, grantCount) {
if (count == null) {
return grantCount;
}
if (count > 1) {
return count;
}
if (count == null) { return grantCount; }
if (count > 1) { return count; }
},
@computed('size')

View File

@ -10,7 +10,7 @@
</div>
{{#each bg.badges as |b|}}
{{badge-card badge=b navigateOnClick="true"}}
{{badge-card badge=b}}
{{/each}}
</div>
{{/each}}

View File

@ -10,7 +10,7 @@
</div>
<div class='badge-info'>
<div class='badge-info-item'>
<h3>{{badge.name}}</h3>
<h3><a href={{badge.url}}>{{badge.name}}</a></h3>
<div class='badge-summary'>{{{summary}}}</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
{{#d-section pageClass="user-badges" class="user-content user-badges-list"}}
{{#each sortedBadges as |ub|}}
{{badge-card badge=ub.badge count=ub.count navigateOnClick="true" username=username}}
{{badge-card badge=ub.badge count=ub.count username=username}}
{{/each}}
{{/d-section}}

View File

@ -179,7 +179,7 @@
<div class='top-section badges-section'>
<h3 class='stats-title'>{{i18n "user.summary.top_badges"}}</h3>
{{#each model.badges as |badge|}}
{{badge-card badge=badge count=badge.count navigateOnClick="true" username=user.username_lower}}
{{badge-card badge=badge count=badge.count username=user.username_lower}}
{{else}}
<p>{{i18n "user.summary.no_badges"}}</p>
{{/each}}