mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Merge branch 'chat_match_users' into autocomplete_unit_tests
This commit is contained in:
@@ -137,23 +137,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);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 item.user
|
||||
}
|
||||
|
||||
$scope.addNewUser = function(user) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user