Skip to content

Commit 3e3c3fe

Browse files
committed
Fix todomvc to reflect All/Active/Completed choice
1 parent e511dd1 commit 3e3c3fe

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

todomvc/todomvc.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ var state = {
66
localStorage["todos-mithril"] = JSON.stringify(state.todos)
77
})
88
},
9-
9+
1010
todos: JSON.parse(localStorage["todos-mithril"] || "[]"),
1111
editing: null,
1212
filter: "",
1313
remaining: 0,
1414
todosByStatus: [],
15-
15+
1616
createTodo: function(title) {
1717
state.todos.push({title: title.trim(), completed: false})
1818
},
@@ -97,7 +97,7 @@ var Todos = {
9797
m("input#toggle-all[type='checkbox']", {checked: state.remaining === 0, onclick: ui.toggleAll}),
9898
m("label[for='toggle-all']", {onclick: ui.toggleAll}, "Mark all as complete"),
9999
m("ul#todo-list", [
100-
state.todos.map(function(todo) {
100+
state.todosByStatus.map(function(todo) {
101101
return m("li", {class: (todo.completed ? "completed" : "") + " " + (todo === state.editing ? "editing" : "")}, [
102102
m(".view", [
103103
m("input.toggle[type='checkbox']", {checked: todo.completed, onclick: function() {ui.toggle(todo)}}),
@@ -115,9 +115,9 @@ var Todos = {
115115
state.remaining === 1 ? " item left" : " items left",
116116
]),
117117
m("ul#filters", [
118-
m("li", m("a[href='/']", {oncreate: m.route.link, class: state.filter === "" ? "selected" : ""}, "All")),
119-
m("li", m("a[href='/active']", {oncreate: m.route.link, class: state.filter === "active" ? "selected" : ""}, "Active")),
120-
m("li", m("a[href='/completed']", {oncreate: m.route.link, class: state.filter === "completed" ? "selected" : ""}, "Completed")),
118+
m("li", m("a[href='/']", {oncreate: m.route.link, class: state.showing === "" ? "selected" : ""}, "All")),
119+
m("li", m("a[href='/active']", {oncreate: m.route.link, class: state.showing === "active" ? "selected" : ""}, "Active")),
120+
m("li", m("a[href='/completed']", {oncreate: m.route.link, class: state.showing === "completed" ? "selected" : ""}, "Completed")),
121121
]),
122122
m("button#clear-completed", {onclick: function() {state.dispatch("clear")}}, "Clear completed"),
123123
]) : null,

0 commit comments

Comments
 (0)