OLD | NEW |
1 // Copyright (c) 2016, 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 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
11 import 'package:observatory/src/elements/helpers/tag.dart'; | 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
13 import 'package:observatory/src/elements/nav/notify.dart'; | 13 import 'package:observatory/src/elements/nav/notify.dart'; |
14 import 'package:observatory/src/elements/nav/top_menu.dart'; | 14 import 'package:observatory/src/elements/nav/top_menu.dart'; |
15 | 15 |
16 class GeneralErrorElement extends HtmlElement implements Renderable { | 16 class GeneralErrorElement extends HtmlElement implements Renderable { |
17 static const tag = const Tag<GeneralErrorElement>('general-error', | 17 static const tag = const Tag<GeneralErrorElement>('general-error', |
18 dependencies: const [NavTopMenuElement.tag, | 18 dependencies: const [NavTopMenuElement.tag, NavNotifyElement.tag]); |
19 NavNotifyElement.tag]); | |
20 | 19 |
21 RenderingScheduler _r; | 20 RenderingScheduler _r; |
22 | 21 |
23 Stream<RenderedEvent<GeneralErrorElement>> get onRendered => _r.onRendered; | 22 Stream<RenderedEvent<GeneralErrorElement>> get onRendered => _r.onRendered; |
24 | 23 |
25 M.NotificationRepository _notifications; | 24 M.NotificationRepository _notifications; |
26 String _message; | 25 String _message; |
27 | 26 |
28 String get message => _message; | 27 String get message => _message; |
29 | 28 |
30 set message(String value) => _message = _r.checkAndReact(_message, value); | 29 set message(String value) => _message = _r.checkAndReact(_message, value); |
31 | 30 |
32 | |
33 factory GeneralErrorElement(M.NotificationRepository notifications, | 31 factory GeneralErrorElement(M.NotificationRepository notifications, |
34 {String message: '', RenderingQueue queue}) { | 32 {String message: '', RenderingQueue queue}) { |
35 assert(notifications != null); | 33 assert(notifications != null); |
36 assert(message != null); | 34 assert(message != null); |
37 GeneralErrorElement e = document.createElement(tag.name); | 35 GeneralErrorElement e = document.createElement(tag.name); |
38 e._r = new RenderingScheduler(e, queue: queue); | 36 e._r = new RenderingScheduler(e, queue: queue); |
39 e._message = message; | 37 e._message = message; |
40 e._notifications = notifications; | 38 e._notifications = notifications; |
41 return e; | 39 return e; |
42 } | 40 } |
43 | 41 |
44 GeneralErrorElement.created() : super.created(); | 42 GeneralErrorElement.created() : super.created(); |
(...skipping 10 matching lines...) Expand all Loading... |
55 children = []; | 53 children = []; |
56 _r.disable(notify: true); | 54 _r.disable(notify: true); |
57 } | 55 } |
58 | 56 |
59 void render() { | 57 void render() { |
60 children = [ | 58 children = [ |
61 navBar([ | 59 navBar([ |
62 new NavTopMenuElement(queue: _r.queue), | 60 new NavTopMenuElement(queue: _r.queue), |
63 new NavNotifyElement(_notifications, queue: _r.queue) | 61 new NavNotifyElement(_notifications, queue: _r.queue) |
64 ]), | 62 ]), |
65 new DivElement()..classes = ['content-centered'] | 63 new DivElement() |
| 64 ..classes = ['content-centered'] |
66 ..children = [ | 65 ..children = [ |
67 new HeadingElement.h1()..text = 'Error', | 66 new HeadingElement.h1()..text = 'Error', |
68 new BRElement(), | 67 new BRElement(), |
69 new DivElement()..classes = ['well'] | 68 new DivElement() |
| 69 ..classes = ['well'] |
70 ..text = message | 70 ..text = message |
71 ] | 71 ] |
72 ]; | 72 ]; |
73 } | 73 } |
74 } | 74 } |
OLD | NEW |