| OLD | NEW |
| (Empty) |
| 1 library companyinfo; | |
| 2 | |
| 3 import 'dart:async'; | |
| 4 import 'dart:html'; | |
| 5 | |
| 6 import 'package:route_hierarchical/client.dart'; | |
| 7 import 'package:web_ui/web_ui.dart'; | |
| 8 | |
| 9 import 'index.dart'; | |
| 10 | |
| 11 | |
| 12 class CompanyInfoComponent extends WebComponent { | |
| 13 var company; | |
| 14 RouteHandle route; | |
| 15 @observable String section; | |
| 16 @observable String infoUrl; | |
| 17 @observable String activitiesUrl; | |
| 18 @observable String notesUrl; | |
| 19 | |
| 20 inserted() { | |
| 21 route.getRoute('info').onRoute.listen((_) => showSection('info')); | |
| 22 route.getRoute('activities') | |
| 23 .onRoute.listen((_) => showSection('activities')); | |
| 24 route.getRoute('notes') | |
| 25 ..onRoute.listen((_) => showSection('notes')) | |
| 26 ..onLeave.listen(notesLeave); | |
| 27 | |
| 28 infoUrl = router.url('info', startingFrom: route); | |
| 29 activitiesUrl = router.url('activities', startingFrom: route); | |
| 30 notesUrl = router.url('notes', startingFrom: route); | |
| 31 } | |
| 32 | |
| 33 removed() { | |
| 34 route.discard(); | |
| 35 } | |
| 36 | |
| 37 notesLeave(RouteEvent e) { | |
| 38 e.allowLeave(new Future.value(window.confirm('Are you sure you want ' + | |
| 39 'to leave?'))); | |
| 40 } | |
| 41 | |
| 42 showSection(section) { | |
| 43 this.section = section; | |
| 44 } | |
| 45 | |
| 46 gotoSection(section, e) { | |
| 47 if (e != null) { | |
| 48 e.preventDefault(); | |
| 49 } | |
| 50 router.go(section, {}, startingFrom: route).then((allowed) { | |
| 51 if (allowed) { | |
| 52 showSection(section); | |
| 53 } | |
| 54 }); | |
| 55 } | |
| 56 | |
| 57 String activeClass(sect) { | |
| 58 if (sect == section) { | |
| 59 return "active"; | |
| 60 } | |
| 61 return ""; | |
| 62 } | |
| 63 } | |
| OLD | NEW |