Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: samples/third_party/todomvc/web/elements/td_todos.dart

Issue 60353013: Update TodoMVC based on https://github.com/polymer/todomvc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/third_party/todomvc/web/elements/td_todos.dart
diff --git a/samples/third_party/todomvc/web/elements/td_todos.dart b/samples/third_party/todomvc/web/elements/td_todos.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c87773309771f45bde3f3f73deced76b52f8e542
--- /dev/null
+++ b/samples/third_party/todomvc/web/elements/td_todos.dart
@@ -0,0 +1,61 @@
+library todomvc.web.elements.td_todos;
+
+import 'dart:html';
+import 'package:polymer/polymer.dart';
+import 'td_input.dart';
+import 'td_model.dart';
+
+@CustomTag('td-todos')
+class TodoList extends PolymerElement {
+ @published String modelId;
+ @published String route;
+
+ @observable TodoModel model;
+ @observable String activeRoute;
+
+ factory TodoList() => new Element.tag('td-todos');
+ TodoList.created() : super.created();
+
+ TodoInput get _newTodo => $['new-todo'];
+
+ void modelIdChanged() {
+ model = document.querySelector('#$modelId');
+ }
+
+ void routeChanged() {
+ if (model != null) model.filter = route;
+
+ // TODO(jmesserly): polymer_expressions lacks boolean conversions.
+ activeRoute = (route != null && route != '') ? route : 'all';
+ }
+
+ void addTodoAction() {
+ model.newItem(_newTodo.value);
+ // when polyfilling Object.observe, make sure we update immediately
+ Observable.dirtyCheck();
+ _newTodo.value = '';
+ }
+
+ void cancelAddTodoAction() {
+ _newTodo.value = '';
+ }
+
+ void itemChangedAction() {
+ if (model != null) model.itemsChanged();
+ }
+
+ void destroyItemAction(e, detail) {
+ model.destroyItem(detail);
+ }
+
+ void toggleAllCompletedAction(e, detail, sender) {
+ model.setItemsCompleted(sender.checked);
+ }
+
+ void clearCompletedAction() {
+ model.clearItems();
+ }
+
+ // TODO(jmesserly): workaround for HTML Imports not setting correct baseURI
+ String get baseUri => declaration.ownerDocument == document ? '../' : '';
+}
« no previous file with comments | « samples/third_party/todomvc/web/elements/td_todos.css ('k') | samples/third_party/todomvc/web/elements/td_todos.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698