Skip to content

Commit

Permalink
Merge branch 'joyclark-chat_match_users' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
crookedneighbor committed Apr 27, 2015
2 parents dcd4be7 + a94aad7 commit e8da13b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
17 changes: 11 additions & 6 deletions test/spec/groupCtrlSpec.js
Expand Up @@ -90,23 +90,28 @@ describe("Autocomplete controller", function() {
});

describe("filterUser", function() {
it('filters with undefined query (not loaded yet) and defaults to true', function() {
expect(scope.filterUser({user: "boo"})).to.be.eq(true);
it('filters with undefined query (not loaded yet) and returns false (so it will not be rendered)', function() {
expect(scope.filterUser({user: "boo"})).to.be.eq(false);
})

it('filters with null query (no typing yet) and defaults to true', function() {
it('filters with null query (no typing yet) and returns false (so it will not be rendered)', function() {
scope.query = null
expect(scope.filterUser({user: "boo"})).to.be.ok
expect(scope.filterUser({user: "boo"})).to.be.eq(false);
})

it('filters with empty prefix and returns true', function() {
scope.query = {text: ""}
expect(scope.filterUser({user: "prefix"})).to.be.eq(true);
})

it('filters with prefix element and returns true', function() {
scope.query = {text: "pre"}
expect(scope.filterUser({user: "prefix"})).to.be.ok
expect(scope.filterUser({user: "prefix"})).to.be.eq(true);
})

it('filters with nonprefix element and returns false', function() {
scope.query = {text: "noprefix"}
expect(scope.filterUser({user: "prefix"})).to.not.be.ok
expect(scope.filterUser({user: "prefix"})).to.be.eq(false);
})
});
});
6 changes: 3 additions & 3 deletions website/public/js/controllers/groupsCtrl.js
Expand Up @@ -220,11 +220,11 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
$scope.usernames = [];
}

$scope.filterUser = function(userItem) {
$scope.filterUser = function(msg) {
if ($scope.query === undefined || $scope.query === null) {
return true;
return false;
}
return userItem.user.indexOf($scope.query.text) == 0; // query should be prefix of item.user
return msg.user.indexOf($scope.query.text) == 0; // query should be prefix of msg.user
}

$scope.addNewUser = function(user) {
Expand Down
4 changes: 2 additions & 2 deletions website/views/options/social/chat-box.jade
Expand Up @@ -15,8 +15,8 @@ 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') : ''}}")
span.user-list(ng-show='!isAtListHidden')
ul.list-at-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}}
li(ng-repeat='msg in response | filter:filterUser | limitTo: 5', ng-click='autoComplete(msg)')
span.username.label.label-default(ng-class=':: userLevelStyle(msg)') {{::msg.user}}
.chat-controls
.chat-formatting
include ../../shared/formatting-help
Expand Down

0 comments on commit e8da13b

Please sign in to comment.