a proposed solution to issue #1866 Redefined the filter function to match based on prefix

This commit is contained in:
Joy Clark
2015-04-25 15:22:16 +02:00
parent bbc9a75d49
commit 94c5da32d6
2 changed files with 8 additions and 1 deletions

View File

@@ -220,6 +220,13 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
$scope.usernames = []; $scope.usernames = [];
} }
$scope.filterUser = function(item) {
if ($scope.query === undefined || $scope.query === null) {
return true;
}
return item.user.indexOf($scope.query.text) == 0; // query should be prefix of item.user
}
$scope.addNewUser = function(user) { $scope.addNewUser = function(user) {
if($.inArray(user.user,$scope.usernames) == -1) { if($.inArray(user.user,$scope.usernames) == -1) {
user.username = user.user; user.username = user.user;

View File

@@ -15,7 +15,7 @@ form.chat-form(ng-if='user.flags.communityGuidelinesAccepted' ng-submit='postCha
textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}") textarea.form-control(rows=4, ui-keydown='{"meta-enter":"postChat(group,message.content)"}', ui-keypress='{13:"postChat(group,message.content)"}', ng-model='message.content', updateinterval='250', flag='@', at-user, auto-complete placeholder="{{group._id == 'habitrpg' ? env.t('tavernCommunityGuidelinesPlaceholder') : ''}}")
span.user-list(ng-show='!isAtListHidden') span.user-list(ng-show='!isAtListHidden')
ul.list-at-user ul.list-at-user
li(ng-repeat='user in response | filter:query.text | limitTo: 5', ng-click='autoComplete(user)') li(ng-repeat='user in response | filter:filterUser | limitTo: 5', ng-click='autoComplete(user)')
span.username.label.label-default(ng-class=':: userLevelStyle(user)') {{::user.user}} span.username.label.label-default(ng-class=':: userLevelStyle(user)') {{::user.user}}
.chat-controls .chat-controls
.chat-formatting .chat-formatting