UX: add href to badge title
This commit is contained in:
parent
b3761653b3
commit
f0778c50bf
|
@ -1,37 +1,14 @@
|
||||||
import computed from 'ember-addons/ember-computed-decorators';
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
import DiscourseURL from 'discourse/lib/url';
|
|
||||||
import { sanitize, emojiUnescape } from 'discourse/lib/text';
|
import { sanitize, emojiUnescape } from 'discourse/lib/text';
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
classNameBindings: [':badge-card', 'size', 'badge.slug', 'navigateOnClick:hyperlink'],
|
classNameBindings: [':badge-card', 'size', 'badge.slug'],
|
||||||
|
|
||||||
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;
|
|
||||||
},
|
|
||||||
|
|
||||||
@computed('count', 'badge.grant_count')
|
@computed('count', 'badge.grant_count')
|
||||||
displayCount(count, grantCount) {
|
displayCount(count, grantCount) {
|
||||||
if (count == null) {
|
if (count == null) { return grantCount; }
|
||||||
return grantCount;
|
if (count > 1) { return count; }
|
||||||
}
|
|
||||||
if (count > 1) {
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed('size')
|
@computed('size')
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#each bg.badges as |b|}}
|
{{#each bg.badges as |b|}}
|
||||||
{{badge-card badge=b navigateOnClick="true"}}
|
{{badge-card badge=b}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class='badge-info'>
|
<div class='badge-info'>
|
||||||
<div class='badge-info-item'>
|
<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 class='badge-summary'>{{{summary}}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{#d-section pageClass="user-badges" class="user-content user-badges-list"}}
|
{{#d-section pageClass="user-badges" class="user-content user-badges-list"}}
|
||||||
{{#each sortedBadges as |ub|}}
|
{{#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}}
|
{{/each}}
|
||||||
{{/d-section}}
|
{{/d-section}}
|
||||||
|
|
|
@ -179,7 +179,7 @@
|
||||||
<div class='top-section badges-section'>
|
<div class='top-section badges-section'>
|
||||||
<h3 class='stats-title'>{{i18n "user.summary.top_badges"}}</h3>
|
<h3 class='stats-title'>{{i18n "user.summary.top_badges"}}</h3>
|
||||||
{{#each model.badges as |badge|}}
|
{{#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}}
|
{{else}}
|
||||||
<p>{{i18n "user.summary.no_badges"}}</p>
|
<p>{{i18n "user.summary.no_badges"}}</p>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
Loading…
Reference in New Issue