Update for new "group-by" semantics of during
This commit is contained in:
parent
9312a28226
commit
b559ab04f8
|
@ -3,7 +3,6 @@
|
||||||
- BUG: transitions don't happen because the nodes are being replaced rather than edited.
|
- BUG: transitions don't happen because the nodes are being replaced rather than edited.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
assertion type todoExists(id);
|
|
||||||
assertion type todo(id, title, completed);
|
assertion type todo(id, title, completed);
|
||||||
|
|
||||||
message type createTodo(title);
|
message type createTodo(title);
|
||||||
|
@ -31,7 +30,6 @@ function todoListItemModel(initialId, initialTitle, initialCompleted) {
|
||||||
this.completed = initialCompleted;
|
this.completed = initialCompleted;
|
||||||
|
|
||||||
react {
|
react {
|
||||||
assert todoExists(this.id);
|
|
||||||
assert todo(this.id, this.title, this.completed);
|
assert todo(this.id, this.title, this.completed);
|
||||||
|
|
||||||
on message setCompleted(this.id, $v) { this.completed = v; }
|
on message setCompleted(this.id, $v) { this.completed = v; }
|
||||||
|
@ -63,6 +61,10 @@ function todoListItemView(id) {
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
react {
|
react {
|
||||||
during todo(id, $title, $completed) {
|
during todo(id, $title, $completed) {
|
||||||
|
// BUG: terminate() kills off the during show subfacet
|
||||||
|
// entirely?!?! Yes, it should kill "its" children - but which
|
||||||
|
// are its children? We need some way of distinguishing by
|
||||||
|
// instantiation.
|
||||||
during show(completed) {
|
during show(completed) {
|
||||||
assert this.ui.html('.todo-list',
|
assert this.ui.html('.todo-list',
|
||||||
Mustache.render(getTemplate(this.editing
|
Mustache.render(getTemplate(this.editing
|
||||||
|
@ -104,7 +106,7 @@ function todoListItemView(id) {
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
}
|
}
|
||||||
} until {
|
} until {
|
||||||
case retracted todoExists(id);
|
case retracted todo(id, _, _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,7 @@ ground dataspace G {
|
||||||
:: setAllCompleted(e.target.checked);
|
:: setAllCompleted(e.target.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
on asserted todoExists($id) {
|
on asserted todo($id, _, _) {
|
||||||
todoListItemView(id);
|
todoListItemView(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +165,8 @@ ground dataspace G {
|
||||||
var completedCount = 0;
|
var completedCount = 0;
|
||||||
var activeCount = 0;
|
var activeCount = 0;
|
||||||
react {
|
react {
|
||||||
on asserted todo(_, _, $completed) { if (completed) completedCount++; else activeCount++; }
|
on asserted todo($id, _, $completed) { if (completed) completedCount++; else activeCount++; }
|
||||||
on retracted todo(_, _, $completed) { if (completed) completedCount--; else activeCount--; }
|
on retracted todo($id, _, $completed) { if (completed) completedCount--; else activeCount--; }
|
||||||
assert activeTodoCount(activeCount);
|
assert activeTodoCount(activeCount);
|
||||||
assert completedTodoCount(completedCount);
|
assert completedTodoCount(completedCount);
|
||||||
assert totalTodoCount(activeCount + completedCount);
|
assert totalTodoCount(activeCount + completedCount);
|
||||||
|
@ -217,11 +219,13 @@ ground dataspace G {
|
||||||
todoListItemModel(db.nextId++, title, false);
|
todoListItemModel(db.nextId++, title, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
during todo($id, $title, $completed) {
|
during todo($id, _, _) {
|
||||||
|
during todo(id, $title, $completed) {
|
||||||
do {
|
do {
|
||||||
db.todos[id] = {id: id, title: title, completed: completed};
|
db.todos[id] = {id: id, title: title, completed: completed};
|
||||||
localStorage['todos-syndicate'] = JSON.stringify(db);
|
localStorage['todos-syndicate'] = JSON.stringify(db);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
delete db.todos[id];
|
delete db.todos[id];
|
||||||
localStorage['todos-syndicate'] = JSON.stringify(db);
|
localStorage['todos-syndicate'] = JSON.stringify(db);
|
||||||
|
|
Loading…
Reference in New Issue