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