[PATCH 4 of 4] autocomplete: consistently show 'username (Full Name)'
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Jun 23 16:00:00 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1435088059 -7200
# Tue Jun 23 21:34:19 2015 +0200
# Node ID 08fff816a576b4a6a70499d2d40e8ee516db83d4
# Parent b609779e357e262092c323bc63eebd569e9e1f36
autocomplete: consistently show 'username (Full Name)'
There are three user-related autocompletion paths: members (when editing
permissions), mentions (in comments), reviewers (in pull requests).
The pop-ups shown when autocompleting would show
'Full Name (username)'
unlike the way Kallithea normally handles such strings:
'username (Full Name)'
Hence, line up the autocomplete code to use the same format.
Note: there is a lot of duplication in this autocomplete code, to be
refactored.
diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js
--- a/kallithea/public/js/base.js
+++ b/kallithea/public/js/base.js
@@ -1225,7 +1225,7 @@ var _MembersAutoComplete = function (div
var fnameMatchIndex = fname.toLowerCase().indexOf(query),
lnameMatchIndex = lname.toLowerCase().indexOf(query),
nnameMatchIndex = nname.toLowerCase().indexOf(query),
- displayfname, displaylname, displaynname;
+ displayfname, displaylname, displaynname, displayname;
if (fnameMatchIndex > -1) {
displayfname = highlightMatch(fname, query, fnameMatchIndex);
@@ -1240,12 +1240,17 @@ var _MembersAutoComplete = function (div
}
if (nnameMatchIndex > -1) {
- displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
+ displaynname = highlightMatch(nname, query, nnameMatchIndex);
} else {
- displaynname = nname ? "(" + nname + ")" : "";
+ displaynname = nname;
}
- return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk, oResultData.gravatar_size);
+ displayname = displaynname;
+ if (displayfname && displaylname) {
+ displayname += " (" + displayfname + " " + displaylname + ")";
+ }
+
+ return _gravatar(displayname, oResultData.gravatar_lnk, oResultData.gravatar_size);
} else {
return '';
}
@@ -1369,7 +1374,7 @@ var MentionsAutoComplete = function (div
var fnameMatchIndex = fname.toLowerCase().indexOf(query),
lnameMatchIndex = lname.toLowerCase().indexOf(query),
nnameMatchIndex = nname.toLowerCase().indexOf(query),
- displayfname, displaylname, displaynname;
+ displayfname, displaylname, displaynname, displayname;
if (fnameMatchIndex > -1) {
displayfname = highlightMatch(fname, query, fnameMatchIndex);
@@ -1384,12 +1389,17 @@ var MentionsAutoComplete = function (div
}
if (nnameMatchIndex > -1) {
- displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
+ displaynname = highlightMatch(nname, query, nnameMatchIndex);
} else {
- displaynname = nname ? "(" + nname + ")" : "";
+ displaynname = nname;
}
- return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk, oResultData.gravatar_size);
+ displayname = displaynname;
+ if (displayfname && displaylname) {
+ displayname += " (" + displayfname + " " + displaylname + ")";
+ }
+
+ return _gravatar(displayname, oResultData.gravatar_lnk, oResultData.gravatar_size);
} else {
return '';
}
@@ -1612,7 +1622,7 @@ var PullRequestAutoComplete = function (
var fnameMatchIndex = fname.toLowerCase().indexOf(query),
lnameMatchIndex = lname.toLowerCase().indexOf(query),
nnameMatchIndex = nname.toLowerCase().indexOf(query),
- displayfname, displaylname, displaynname;
+ displayfname, displaylname, displaynname, displayname;
if (fnameMatchIndex > -1) {
displayfname = highlightMatch(fname, query, fnameMatchIndex);
@@ -1627,12 +1637,17 @@ var PullRequestAutoComplete = function (
}
if (nnameMatchIndex > -1) {
- displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
+ displaynname = highlightMatch(nname, query, nnameMatchIndex);
} else {
- displaynname = nname ? "(" + nname + ")" : "";
+ displaynname = nname;
}
- return _gravatar(displayfname + " " + displaylname + " " + displaynname, oResultData.gravatar_lnk, oResultData.gravatar_size);
+ displayname = displaynname;
+ if (displayfname && displaylname) {
+ displayname += " (" + displayfname + " " + displaylname + ")";
+ }
+
+ return _gravatar(displayname, oResultData.gravatar_lnk, oResultData.gravatar_size);
} else {
return '';
}
More information about the kallithea-general
mailing list