Commit fa6a2630 authored by Aaron Boushley's avatar Aaron Boushley

Adding count of completed items to the clear button.

parent 778a624b
......@@ -52,10 +52,8 @@
<!-- Insert this after the CreateTodoView and before the collection. -->
{{#view Todos.StatsView id="todo-stats"}}
{{#view Ember.Button
target="Todos.todosController"
action="clearCompletedTodos"}}
Clear Completed
{{#view Ember.Button target="Todos.todosController" action="clearCompletedTodos" content=this}}
Clear {{content.completedString}}
{{/view}}
{{remainingString}} left
{{/view}}
......
......@@ -25,6 +25,10 @@ Todos.todosController = Ember.ArrayProxy.create({
return this.filterProperty('isDone', false).get('length');
}.property('@each.isDone'),
completed: function() {
return this.filterProperty('isDone', true).get('length');
}.property('@each.isDone'),
allAreDone: function(key, value) {
if (value !== undefined) {
this.setEach('isDone', value);
......@@ -38,11 +42,16 @@ Todos.todosController = Ember.ArrayProxy.create({
Todos.StatsView = Ember.View.extend({
remainingBinding: 'Todos.todosController.remaining',
remainingString: function() {
var remaining = this.get('remaining');
return remaining + (remaining === 1 ? " item" : " items");
}.property('remaining')
}.property('remaining'),
completedBinding: 'Todos.todosController.completed',
completedString: function() {
var completed = this.get('completed');
return completed + " completed" + (completed === 1 ? " item" : " items");
}.property('completed')
});
Todos.CreateTodoView = Ember.TextField.extend({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment