mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
Adjust PR #5389
* Convert $watch to ng-change and re-wrote test * Removed unnecessary styles * Use .form-control instead of class='form-control'
This commit is contained in:
@@ -10,28 +10,30 @@ describe('Filters Controller', function() {
|
|||||||
$controller('FiltersCtrl', {$scope: scope, User: {user: user}});
|
$controller('FiltersCtrl', {$scope: scope, User: {user: user}});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('creates a tag', function(){
|
describe('tags', function(){
|
||||||
scope._newTag = {name:'tagName'}
|
it('creates a tag', function(){
|
||||||
scope.createTag();
|
scope._newTag = {name:'tagName'}
|
||||||
expect(user.tags).to.have.length(1);
|
scope.createTag();
|
||||||
expect(user.tags[0].name).to.eql('tagName');
|
expect(user.tags).to.have.length(1);
|
||||||
expect(user.tags[0]).to.have.property('id');
|
expect(user.tags[0].name).to.eql('tagName');
|
||||||
|
expect(user.tags[0]).to.have.property('id');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('toggles tag filtering', inject(function(Shared){
|
||||||
|
var tag = {id: Shared.uuid(), name: 'myTag'};
|
||||||
|
scope.toggleFilter(tag);
|
||||||
|
expect(user.filters[tag.id]).to.eql(true);
|
||||||
|
scope.toggleFilter(tag);
|
||||||
|
expect(user.filters[tag.id]).to.eql(false);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toggles tag filtering', inject(function(Shared){
|
describe('updateTaskFilter', function(){
|
||||||
var tag = {id: Shared.uuid(), name: 'myTag'};
|
it('updatest user\'s filter query with the value of filterQuery', function () {
|
||||||
scope.toggleFilter(tag);
|
scope.filterQuery = 'task';
|
||||||
expect(user.filters[tag.id]).to.eql(true);
|
scope.updateTaskFilter();
|
||||||
scope.toggleFilter(tag);
|
|
||||||
expect(user.filters[tag.id]).to.eql(false);
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('updates user\'s filter query when filterQuery is changed', function () {
|
expect(user.filterQuery).to.eql(scope.filterQuery);
|
||||||
scope.$apply();
|
});
|
||||||
|
|
||||||
scope.filterQuery = 'foo';
|
|
||||||
scope.$apply();
|
|
||||||
|
|
||||||
expect(user.filterQuery).to.eql('foo');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,13 +36,5 @@
|
|||||||
@extend $hrpg-button-with-input
|
@extend $hrpg-button-with-input
|
||||||
hrpg-button-color-mixin($color-options-submenu)
|
hrpg-button-color-mixin($color-options-submenu)
|
||||||
.filters-search
|
.filters-search
|
||||||
float: left
|
|
||||||
margin-right: 5px
|
|
||||||
margin-bottom: 0.618em
|
margin-bottom: 0.618em
|
||||||
width: 180px
|
max-width: 180px
|
||||||
input
|
|
||||||
padding: 4.5px 6px !important
|
|
||||||
height: 29px !important
|
|
||||||
.input-group-addon
|
|
||||||
height: 29px !important
|
|
||||||
padding: 4.5px 10px !important
|
|
||||||
|
|||||||
@@ -31,11 +31,9 @@ habitrpg.controller("FiltersCtrl", ['$scope', '$rootScope', 'User', 'Shared',
|
|||||||
// User.save();
|
// User.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('filterQuery', function (newValue, oldValue) {
|
$scope.updateTaskFilter = function(){
|
||||||
if (newValue !== oldValue) {
|
user.filterQuery = $scope.filterQuery;
|
||||||
user.filterQuery = newValue;
|
};
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.createTag = function() {
|
$scope.createTag = function() {
|
||||||
User.user.ops.addTag({body:{name:$scope._newTag.name, id:Shared.uuid()}});
|
User.user.ops.addTag({body:{name:$scope._newTag.name, id:Shared.uuid()}});
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
.row
|
.row
|
||||||
.filters(ng-controller='FiltersCtrl')
|
.filters(ng-controller='FiltersCtrl')
|
||||||
.input-group.input-group-sm.filters-search.pull-right
|
.input-group.input-group-sm.filters-search.pull-right
|
||||||
input(type='text', class='form-control', placeholder=env.t('search'), ng-model='filterQuery')
|
input.form-control(type='text', placeholder=env.t('search'), ng-model='filterQuery', ng-change='updateTaskFilter()', ng-model-options='{ debounce: 250 }')
|
||||||
.input-group-addon
|
.input-group-addon
|
||||||
.glyphicon.glyphicon-search
|
.glyphicon.glyphicon-search
|
||||||
ul.filters-controls
|
ul.filters-controls
|
||||||
li=env.t('tags')
|
li=env.t('tags')
|
||||||
//- Edit button
|
//- Edit button
|
||||||
|
|||||||
Reference in New Issue
Block a user