create searchResultUserSerializer, display name next to username in search results

This commit is contained in:
giorgia 2017-02-13 16:10:28 +01:00
parent b20b568039
commit d308638a18
4 changed files with 9 additions and 2 deletions

View File

@ -46,7 +46,7 @@ function postResult(result, link, term) {
}
createSearchResult('user', 'path', function(u) {
return [ avatarImg('small', { template: u.avatar_template, username: u.username }), ' ', u.username ];
return [ avatarImg('small', { template: u.avatar_template, username: u.username }), ' ', h('span.user-results', h('b', u.username)), ' ', h('span.user-results', u.name ? u.name : '') ];
});
createSearchResult('topic', 'url', function(result, term) {

View File

@ -184,6 +184,10 @@
display: block;
padding: 5px;
transition: all linear .15s;
.user-results {
color: dark-light-choose(scale-color($primary, $lightness: 30%), scale-color($secondary, $lightness: 70%));
}
}
&:hover a:not(.badge-notification) {

View File

@ -1,6 +1,6 @@
class GroupedSearchResultSerializer < ApplicationSerializer
has_many :posts, serializer: SearchPostSerializer
has_many :users, serializer: BasicUserSerializer
has_many :users, serializer: SearchResultUserSerializer
has_many :categories, serializer: BasicCategorySerializer
attributes :more_posts, :more_users, :more_categories
end

View File

@ -0,0 +1,3 @@
class SearchResultUserSerializer < BasicUserSerializer
attributes :name
end