Skip to content

Commit

Permalink
list filtering; testing way behind now
Browse files Browse the repository at this point in the history
  • Loading branch information
buzzdecafe committed Nov 3, 2013
1 parent 6fb1b17 commit eb877c8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/js/controllers/loadCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ angular.module('kinghunt.controllers').
controller('LoadCtrl', ['$scope', 'bookSvc', function($scope, bookSvc) {
$scope.book = bookSvc.getBook();
$scope.solved = bookSvc.getSolved();

$scope.hideProblem = function(problem) {
return $scope.skipSolved && $scope.solved[problem.id];
};
}]);
10 changes: 9 additions & 1 deletion app/js/directives/skipSolvedProblems.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ angular.module('kinghunt.directives').
return {
restrict: 'C',
replace: false,
template: '<button class="btn btn-default" ng-click="bookSvc.toggleSkipSolved()">{{ bookSvc.getSkipSolved() | solvedMsg }} solved</button>',
link: function(scope, element, attrs) {
scope.skipSolved = bookSvc.getSkipSolved();

element.on('click', function(e) {
bookSvc.toggleSkipSolved();
scope.skipSolved = bookSvc.getSkipSolved();
scope.$apply();
});
}
}
}]);
2 changes: 1 addition & 1 deletion app/js/filters/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module('kinghunt.filters', []).
filter('solvedMsg', function() {
return function(skip) {
return skip ? "Show" : "Hide";
}
};
}).
filter('translateStipulation', [function() {
var mateInRx = /^#(\d+)$/;
Expand Down
6 changes: 4 additions & 2 deletions app/partials/load.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ <h3>Enter a FEN:</h3>
</div>
-->
<div id="problem-book">
<div class="skipSolvedProblems pull-right"></div>
<div class="pull-right">
<button class="btn btn-default skipSolvedProblems">{{ skipSolved | solvedMsg }} solved</button>
</div>
<h3>KingHunt</h3>
<p><em>{{book.title}}</em>, {{book.year}}</p>
<ul class="list-group">
<li class="list-group-item problem-list" ng-repeat="problem in book.problems | filter:bookSvc.isSolved(problem.id)">
<li class="list-group-item problem-list" ng-repeat="problem in book.problems" ng-hide="hideProblem(problem)">
<button class="solvedMark"></button>
<a href="#/board/{{problem.id}}">
<div class="stipulation">#{{ problem.id }}: {{ problem.fen | whoseTurn }} to play and {{problem.stipulation | translateStipulation }}</div>
Expand Down
2 changes: 1 addition & 1 deletion config/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(config) {
'test/unit/**/*.js'
],
autoWatch: true,
browsers: ['Firefox', 'Chrome'],
browsers: ['PhantomJS', 'Firefox', 'Chrome'],
junitReporter: {
outputFile: 'test_out/unit.xml',
suite: 'unit'
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"grunt-contrib-jasmine": "~0.5.1",
"grunt-contrib-compress": "~0.5.2",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-uglify": "~0.2.2"
"grunt-contrib-uglify": "~0.2.2",
"karma": "~0.10.4"
}
}
2 changes: 1 addition & 1 deletion test/unit/services/servicesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('service', function() {
});

expect(gameSvc.getStatus instanceof Function).toBe(true);

describe('getStatus', function() {
it("returns a status object", function() {
var goalMoves = 2;
Expand Down

0 comments on commit eb877c8

Please sign in to comment.