OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 general_error_element; | 5 library general_error_element; |
6 | 6 |
7 import 'observatory_element.dart'; | 7 import 'dart:html'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' as M; | |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | |
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | |
12 import 'package:observatory/src/elements/nav/bar.dart'; | |
13 import 'package:observatory/src/elements/nav/notify.dart'; | |
14 import 'package:observatory/src/elements/nav/top_menu.dart'; | |
9 | 15 |
10 /// Displays an error message | 16 class GeneralErrorElement extends HtmlElement implements Renderable{ |
Cutch
2016/08/02 23:58:28
space before {
cbernaschina
2016/08/03 22:00:37
Done.
| |
11 @CustomTag('general-error') | 17 static const tag = const Tag<GeneralErrorElement>('general-error', |
12 class GeneralErrorElement extends ObservatoryElement { | 18 dependencies: const [NavBarElement.tag, |
13 @published String message; | 19 NavTopMenuElement.tag, |
20 NavNotifyElement.tag]); | |
21 | |
22 RenderingScheduler _r; | |
23 | |
24 Stream<RenderedEvent<GeneralErrorElement>> get onRendered => _r.onRendered; | |
25 | |
26 M.NotificationRepository _notifications; | |
27 String _message; | |
28 | |
29 String get message => _message; | |
30 | |
31 set message(String value) => _message = _r.checkAndReact(_message, value); | |
32 | |
33 | |
34 factory GeneralErrorElement(M.NotificationRepository notifications, | |
35 {String message: '', RenderingQueue queue}) { | |
36 assert(notifications != null); | |
37 assert(message != null); | |
38 GeneralErrorElement e = document.createElement(tag.name); | |
39 e._r = new RenderingScheduler(e, queue: queue); | |
40 e._message = message; | |
41 e._notifications = notifications; | |
42 return e; | |
43 } | |
14 | 44 |
15 GeneralErrorElement.created() : super.created(); | 45 GeneralErrorElement.created() : super.created(); |
46 | |
47 @override | |
48 void attached() { | |
49 super.attached(); | |
50 _r.enable(); | |
51 } | |
52 | |
53 @override | |
54 void detached() { | |
55 super.detached(); | |
56 children = []; | |
57 _r.disable(notify: true); | |
58 } | |
59 | |
60 void render() { | |
61 children = [ | |
62 new NavBarElement(queue: _r.queue) | |
63 ..children = [ | |
64 new NavTopMenuElement(last: true, queue: _r.queue), | |
65 new NavNotifyElement(_notifications, queue: _r.queue) | |
66 ], | |
67 new DivElement()..classes = ['content-centered'] | |
68 ..children = [ | |
69 new HeadingElement.h1()..text = 'Error', | |
70 new BRElement(), | |
71 new DivElement()..classes = ['well'] | |
72 ..text = message | |
73 ] | |
74 ]; | |
75 } | |
16 } | 76 } |
OLD | NEW |