import TodoTask from 'TodoTask';

define TodoList {
	
	slot toggleAll (event) {
		var completed = event.currentTarget.checked;
		this.model.toggleAll(completed);
	}

	slot taskChanged () {
		this.model.save();
	}

	slot taskRemoved (event, task) {
		this.model.del(task);
	}

	input .toggle-all
		type = checkbox
		checked = '~[bind: status.todoCount == 0 ? "checked" ]'
		x-tap = toggleAll
		;

	label for='toggle-all' > 'Mark all as complete'
	
	ul .todo-list {
		// bind todos collection
		+each (.) > TodoTask;
	}
}
