d84e0e3a1fe297ff5d8adb141632cae94268d2a9
[WebKit-https.git] / Websites / browserbench.org / Speedometer2.0 / resources / todomvc / architecture-examples / emberjs / source / app / components / todo-list.js
1 import Ember from 'ember';
2
3 export default Ember.Component.extend({
4     repo: Ember.inject.service(),
5     tagName: 'section',
6     elementId: 'main',
7     canToggle: true,
8     allCompleted: Ember.computed('todos.@each.completed', function () {
9         return this.get('todos').isEvery('completed');
10     }),
11
12     actions: {
13         enableToggle() {
14             this.set('canToggle', true);
15         },
16
17         disableToggle() {
18             this.set('canToggle', false);
19         },
20
21         toggleAll() {
22             let allCompleted = this.get('allCompleted');
23             this.get('todos').forEach(todo => Ember.set(todo, 'completed', !allCompleted));
24             this.get('repo').persist();
25         }
26     }
27 });