From 54ef1cee1d25ce823531cd3e3571a6b3b847d1ea Mon Sep 17 00:00:00 2001 From: Deiwin Sarjas Date: Tue, 2 Dec 2014 16:55:52 +0200 Subject: [PATCH] add full name to found users' list --- public/js/app.js | 9 ++++++++- public/ng/js/gogs.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 2a7cf08bae..23b629e3e1 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -303,6 +303,9 @@ var Gogits = {}; // api working Gogits.getUsers = function (val, $target) { + var notEmpty = function (str) { + return str && str.length > 0; + } $.ajax({ url: '/api/v1/users/search?q=' + val, dataType: "json", @@ -310,7 +313,11 @@ var Gogits = {}; if (json.ok && json.data.length) { var html = ''; $.each(json.data, function (i, item) { - html += '
  • ' + item.username + '
  • '; + html += '
  • ' + item.username; + if (notEmpty(item.full_name)) { + html += ' (' + item.full_name + ')'; + } + html += '
  • '; }); $target.toggleShow(); $target.find('ul').html(html); diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 3578cd7cb9..1d5a113eeb 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -203,6 +203,9 @@ var Gogs = {}; // Search users by keyword. Gogs.searchUsers = function (val, $target) { + var notEmpty = function (str) { + return str && str.length > 0; + } $.ajax({ url: Gogs.AppSubUrl + '/api/v1/users/search?q=' + val, dataType: "json", @@ -210,7 +213,11 @@ var Gogs = {}; if (json.ok && json.data.length) { var html = ''; $.each(json.data, function (i, item) { - html += '
  • ' + item.username + '
  • '; + html += '
  • ' + item.username; + if (notEmpty(item.full_name)) { + html += ' (' + item.full_name + ')'; + } + html += '
  • '; }); $target.html(html); $target.toggleShow();