From 43671b1fdac10817b89b4f2c8c96cf29c6dbf5d1 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 4 Jan 2017 11:39:21 +0800 Subject: [PATCH] UX: Display group fullname in mention autocomplete. --- .../discourse/helpers/max-usernames.js.es6 | 10 ---------- .../user-selector-autocomplete.raw.hbs | 12 ++++++------ app/assets/stylesheets/common/base/compose.scss | 17 +++++++++-------- app/controllers/users_controller.rb | 4 ++-- 4 files changed, 17 insertions(+), 26 deletions(-) delete mode 100644 app/assets/javascripts/discourse/helpers/max-usernames.js.es6 diff --git a/app/assets/javascripts/discourse/helpers/max-usernames.js.es6 b/app/assets/javascripts/discourse/helpers/max-usernames.js.es6 deleted file mode 100644 index 68d002db8fe..00000000000 --- a/app/assets/javascripts/discourse/helpers/max-usernames.js.es6 +++ /dev/null @@ -1,10 +0,0 @@ -import { registerUnbound } from 'discourse-common/lib/helpers'; - -registerUnbound('max-usernames', function(usernames, params) { - var maxLength = parseInt(params.max) || 3; - if (usernames.length > maxLength){ - return usernames.slice(0, maxLength).join(", ") + ", +" + (usernames.length - maxLength); - } else { - return usernames.join(", "); - } -}); diff --git a/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs b/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs index 28d76c43ccb..793e4f3aa34 100644 --- a/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs +++ b/app/assets/javascripts/discourse/templates/user-selector-autocomplete.raw.hbs @@ -1,8 +1,8 @@ -
+
    {{#each options.users as |user|}} -
  • - +
  • + {{avatar user imageSize="tiny"}} {{user.username}} {{user.name}} @@ -11,11 +11,11 @@ {{/each}} {{#if options.groups}} {{#each options.groups as |group|}} -
  • - +
  • + {{group.name}} - {{max-usernames group.usernames max="3"}} + {{group.full_name}}
  • {{/each}} diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scss index 4e53da0fc26..57cbd7d9510 100644 --- a/app/assets/stylesheets/common/base/compose.scss +++ b/app/assets/stylesheets/common/base/compose.scss @@ -8,26 +8,27 @@ list-style: none; padding: 0; margin: 0; - li { + + .user-selector-item { .fa-users { color: lighten($primary, 40%); padding: 0 2px; } + border-bottom: 1px solid dark-light-diff($primary, $secondary, 90%, -60%); - a[href] { + + a { padding: 5px; display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + span.username { color: darken($primary, 40%); - display: inline-block; } span.name { font-size: 11px; - display: inline-block; - width: 90px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; vertical-align: middle; } &.selected { diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 153dae27d39..a61541aa1ab 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -568,7 +568,7 @@ class UsersController < ApplicationController if params[:include_groups] == "true" to_render[:groups] = Group.search_group(term).map do |m| - {name: m.name, usernames: []} + { name: m.name, full_name: m.full_name } end end @@ -576,7 +576,7 @@ class UsersController < ApplicationController to_render[:groups] = Group.mentionable(current_user) .where("name ILIKE :term_like", term_like: "#{term}%") .map do |m| - {name: m.name, usernames: []} + { name: m.name, full_name: m.full_name } end end