Add link to badge reason on badge details page.

This commit is contained in:
Sam 2014-07-02 09:46:28 +10:00
parent 60d93a62f6
commit a4b7b561dc
4 changed files with 55 additions and 12 deletions

View File

@ -7,6 +7,15 @@
@module Discourse
**/
export default Discourse.ObjectController.extend({
layoutClass: function(){
var ub = this.get("userBadges");
if(ub && ub[0] && ub[0].post_id){
return "user-badge-with-posts";
} else {
return "user-badge-no-posts";
}
}.property("userBadges"),
grantDates: Em.computed.mapBy('userBadges', 'grantedAt'),
minGrantedAt: Em.computed.min('grantDates'),

View File

@ -16,18 +16,21 @@
</table>
{{#if userBadges}}
<div>
<div class={{unbound layoutClass}}>
{{#each userBadges}}
{{#link-to 'user' user}}
<div class="badge-user">
{{avatar user imageSize="large"}}
<div class="details">
<span class="username">{{user.username}}</span>
{{date granted_at}}
</div>
</div>
{{/link-to}}
<!-- <a href="{{unbound topic.url}}/{{unbound post_number}}"><span class="post-number">#{{post_number}}</span> {{topic.title}}</a> -->
<div class="badge-user">
{{#link-to 'user' user classNames="badge-info"}}
{{avatar user imageSize="large"}}
<div class="details">
<span class="username">{{user.username}}</span>
{{date granted_at}}
</div>
{{/link-to}}
{{#if post_number}}
<a class="post-link" href="{{unbound topic.url}}/{{unbound post_number}}"><span class="post-number">#{{post_number}}</span> {{topic.title}}</a>
{{/if}}
</div>
{{/each}}
</div>
{{#if canLoadMore}}

View File

@ -96,11 +96,11 @@ table.badges-listing {
/* /badges/:id/:slug page styling. */
.show-badge {
.badge-user {
display: inline-block;
text-align: center;
width: 100px;
padding: 5px 10px;
margin-bottom: 10px;
display: inline-block;
.details {
margin: 0 10px;
@ -115,3 +115,22 @@ table.badges-listing {
}
}
}
.show-badge .user-badge-with-posts .badge-user {
width: 400px;
.badge-info {
width: 100px;
display: block;
float: left;
}
.post-link {
width: 250px;
display: block;
float: left;
margin-top: 67px;
margin-left: 18px;
text-align: left;
}
}

View File

@ -0,0 +1,12 @@
module Jobs
class BadgeGrant < Jobs::Scheduled
every 1.day
def execute(args)
BadgeGranter.backfill_like_badges
end
end
end