| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library tracker.web.task_form_element; | 5 library tracker.web.task_form_element; |
| 6 | 6 |
| 7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
| 8 import 'package:tracker/models.dart'; | 8 import 'package:tracker/models.dart'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'dart:math'; | 10 import 'dart:math'; |
| 11 | 11 |
| 12 @CustomTag('task-form-element') | 12 @CustomTag('task-form-element') |
| 13 class TaskFormElement extends PolymerElement { | 13 class TaskFormElement extends PolymerElement { |
| 14 bool get applyAuthorStyles => true; | 14 bool get applyAuthorStyles => true; |
| 15 @observable Task task; | 15 @observable Task task; |
| 16 @observable String titleErrorMessage = ''; | 16 @observable String titleErrorMessage = ''; |
| 17 @observable int maxTitleLength = Task.MAX_TITLE_LENGTH; | 17 @observable int maxTitleLength = Task.MAX_TITLE_LENGTH; |
| 18 @observable String descriptionErrorMessage = ''; | 18 @observable String descriptionErrorMessage = ''; |
| 19 @observable int maxDescriptionLength = Task.MAX_DESCRIPTION_LENGTH; | 19 @observable int maxDescriptionLength = Task.MAX_DESCRIPTION_LENGTH; |
| 20 @observable final List<String> taskStatusOptions = toObservable([ | 20 @observable final List<String> taskStatusOptions = toObservable([ |
| 21 Task.CURRENT, Task.PENDING, Task.COMPLETED]); | 21 Task.CURRENT, Task.PENDING, Task.COMPLETED]); |
| 22 @observable int statusSelectedIndex = 1; | 22 @observable int statusSelectedIndex = 1; |
| 23 @observable String previousStatus = ''; | 23 @observable String previousStatus = ''; |
| 24 @observable String submitLabel = ''; | 24 @observable String submitLabel = ''; |
| 25 | 25 |
| 26 TaskFormElement.created() : super.created(); | 26 TaskFormElement.created() : super.created(); |
| 27 | 27 |
| 28 enteredView() { | 28 attached() { |
| 29 super.enteredView(); | 29 super.attached(); |
| 30 submitLabel = task.saved ? 'Update' : 'Create'; | 30 submitLabel = task.saved ? 'Update' : 'Create'; |
| 31 statusSelectedIndex = taskStatusOptions.indexOf(task.status); | 31 statusSelectedIndex = taskStatusOptions.indexOf(task.status); |
| 32 if (!task.saved) { | 32 if (!task.saved) { |
| 33 statusSelectedIndex = taskStatusOptions.indexOf(task.status); | 33 statusSelectedIndex = taskStatusOptions.indexOf(task.status); |
| 34 previousStatus = task.status; | 34 previousStatus = task.status; |
| 35 } | 35 } |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool validateTitle() { | 38 bool validateTitle() { |
| 39 int len = task.title.length; | 39 int len = task.title.length; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 appModel.tasks.add(task); | 106 appModel.tasks.add(task); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 deleteTask() { | 110 deleteTask() { |
| 111 if (window.confirm('Are you sure you want to delete this?')) { | 111 if (window.confirm('Are you sure you want to delete this?')) { |
| 112 appModel.tasks.remove(task); | 112 appModel.tasks.remove(task); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 } | 115 } |
| OLD | NEW |