]> source.dussan.org Git - gitea.git/commitdiff
add full name to found users' list
authorDeiwin Sarjas <deiwin.sarjas@gmail.com>
Tue, 2 Dec 2014 14:55:52 +0000 (16:55 +0200)
committerDeiwin Sarjas <deiwin.sarjas@gmail.com>
Tue, 2 Dec 2014 14:55:52 +0000 (16:55 +0200)
public/js/app.js
public/ng/js/gogs.js

index 2a7cf08bae46092baf6562f275a44be96a3fd140..23b629e3e15cfb1141b03b58655314d723e44ecc 100644 (file)
@@ -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 += '<li><img src="' + item.avatar + '">' + item.username + '</li>';
+                        html += '<li><img src="' + item.avatar + '">' + item.username;
+                        if (notEmpty(item.full_name)) {
+                          html += ' (' + item.full_name + ')';
+                        }
+                        html += '</li>';
                     });
                     $target.toggleShow();
                     $target.find('ul').html(html);
index 3578cd7cb976ba7108c502231fc7523de49faba7..1d5a113eeb2a5ce9b8b92e159293bdd21a2180c9 100644 (file)
@@ -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 += '<li><a><img src="' + item.avatar_url + '">' + item.username + '</a></li>';
+                        html += '<li><a><img src="' + item.avatar_url + '">' + item.username;
+                        if (notEmpty(item.full_name)) {
+                          html += ' (' + item.full_name + ')';
+                        }
+                        html += '</a></li>';
                     });
                     $target.html(html);
                     $target.toggleShow();