mirror of
https://github.com/discourse/discourse.git
synced 2025-02-01 08:30:46 +08:00
UX: Always show the current user at the top of the directory
This commit is contained in:
parent
b18dfa7ca0
commit
1931850151
|
@ -0,0 +1,3 @@
|
|||
export default Ember.Controller.extend({
|
||||
me: Discourse.computed.propertyEqual('model.user.id', 'currentUser.id')
|
||||
});
|
|
@ -20,16 +20,16 @@
|
|||
{{/if}}
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each item in model}}
|
||||
<tr>
|
||||
<td>{{user-small user=item.user}}</td>
|
||||
<td>{{number item.likes_received}}</td>
|
||||
<td>{{number item.likes_given}}</td>
|
||||
<td>{{number item.topic_count}}</td>
|
||||
<td>{{number item.post_count}}</td>
|
||||
<td>{{number item.topics_entered}}</td>
|
||||
{{#each item in model itemController="directory-item"}}
|
||||
<tr {{bind-attr class="item.me"}}>
|
||||
<td>{{user-small user=item.model.user}}</td>
|
||||
<td>{{number item.model.likes_received}}</td>
|
||||
<td>{{number item.model.likes_given}}</td>
|
||||
<td>{{number item.model.topic_count}}</td>
|
||||
<td>{{number item.model.post_count}}</td>
|
||||
<td>{{number item.model.topics_entered}}</td>
|
||||
{{#if showTimeRead}}
|
||||
<td>{{unbound item.time_read}}</td>
|
||||
<td>{{unbound item.model.time_read}}</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
vertical-align: top;
|
||||
}
|
||||
|
||||
tr.me {
|
||||
td {
|
||||
background-color: scale-color($highlight, $lightness: 50%);
|
||||
}
|
||||
}
|
||||
|
||||
th.sortable {
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
|
|
|
@ -8,6 +8,10 @@ class DirectoryItemsController < ApplicationController
|
|||
|
||||
result = DirectoryItem.where(period_type: period_type).includes(:user)
|
||||
|
||||
if current_user.present?
|
||||
result = result.order("CASE WHEN users.id = #{current_user.id.to_i} THEN 0 ELSE 1 END")
|
||||
end
|
||||
|
||||
order = params[:order] || DirectoryItem.headings.first
|
||||
if DirectoryItem.headings.include?(order.to_sym)
|
||||
dir = params[:asc] ? 'ASC' : 'DESC'
|
||||
|
@ -18,6 +22,8 @@ class DirectoryItemsController < ApplicationController
|
|||
result = result.includes(:user_stat)
|
||||
end
|
||||
page = params[:page].to_i
|
||||
|
||||
|
||||
result = result.order('users.username')
|
||||
result_count = result.dup.count
|
||||
result = result.limit(PAGE_SIZE).offset(PAGE_SIZE * page)
|
||||
|
|
Loading…
Reference in New Issue
Block a user