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

Unified Diff: samples/tracker/web/elements/task_form_element.dart

Issue 66783006: Updated Tracker to deal with Polymer element restrictions Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « no previous file | samples/tracker/web/elements/task_form_element.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/tracker/web/elements/task_form_element.dart
diff --git a/samples/tracker/web/elements/task_form_element.dart b/samples/tracker/web/elements/task_form_element.dart
index 52efd28cb85b95a7028a87441b5fb6adfaf3b34f..d9c92cf1a0482fdcf7bc03b527ca52dd523f1b14 100644
--- a/samples/tracker/web/elements/task_form_element.dart
+++ b/samples/tracker/web/elements/task_form_element.dart
@@ -23,6 +23,34 @@ class TaskFormElement extends PolymerElement {
@observable String previousStatus = '';
@observable String submitLabel = '';
+ // Define variables, getters, and setters to get around Polymer Element
Siggi Cherem (dart-lang) 2013/11/12 18:53:54 Consider rephrasing this. This is really a restric
+ // restrictions.
+ @observable bool titleErrorMessageIsEmpty;
+ @observable bool descriptionErrorMessageIsEmpty;
+ @observable bool taskSaved;
Siggi Cherem (dart-lang) 2013/11/12 18:53:54 Let's move some of these workarounds to Task so th
+
+ int _taskTitleLength = 0;
+ int get taskTitleLength => _taskTitleLength;
+ void set taskTitleLength(int c) {
+ _taskTitleLength = notifyPropertyChange(#taskTitleLength,
+ _taskTitleLength, c);
+ }
+
+ int _taskDescriptionLength = 0;
+ int get taskDescriptionLength => _taskDescriptionLength;
+ void set taskDescriptionLength(int c) {
+ _taskDescriptionLength = notifyPropertyChange(#taskDescriptionLength,
+ _taskDescriptionLength, c);
+ }
Siggi Cherem (dart-lang) 2013/11/12 18:53:54 with my suggestion above you should be able to get
+
+ titleErrorMessageChanged(String oldValue) {
+ titleErrorMessageIsEmpty = titleErrorMessage.isEmpty;
+ }
Siggi Cherem (dart-lang) 2013/11/12 18:53:54 FYI - this trick s very similar to what I'm sugges
+
+ descriptionErrorMessageChanged(String oldValue) {
+ descriptionErrorMessageIsEmpty = descriptionErrorMessage.isEmpty;
+ }
+
TaskFormElement.created() : super.created();
enteredView() {
@@ -33,14 +61,18 @@ class TaskFormElement extends PolymerElement {
statusSelectedIndex = taskStatusOptions.indexOf(task.status);
previousStatus = task.status;
}
+
+ taskTitleLength = task.title.length;
+ taskDescriptionLength = task.description.length;
+ taskSaved = task.saved;
}
bool validateTitle() {
- int len = task.title.length;
+ taskTitleLength = task.title.length;
bool valid = false;
- if (len == 0 && Task.TITLE_REQUIRED) {
+ if (taskTitleLength == 0 && Task.TITLE_REQUIRED) {
titleErrorMessage = 'Title is required';
- } else if (len > maxTitleLength) {
+ } else if (taskTitleLength > maxTitleLength) {
titleErrorMessage = 'Title must be less than $maxTitleLength characters';
} else {
titleErrorMessage = '';
@@ -50,9 +82,9 @@ class TaskFormElement extends PolymerElement {
}
bool validateDescription() {
- int len = task.description.length;
+ taskDescriptionLength = task.description.length;
bool valid = false;
- if (len >= maxDescriptionLength) {
+ if (taskDescriptionLength >= maxDescriptionLength) {
descriptionErrorMessage = 'Description must be less than '
'$maxDescriptionLength characters';
} else {
« no previous file with comments | « no previous file | samples/tracker/web/elements/task_form_element.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698