Chromium Code Reviews| 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 { |