-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.js
50 lines (47 loc) · 1.14 KB
/
router.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Tracker.autorun(function() {
Router.onBeforeAction(function() {
var firstAccess = LocalStore.get('firstAccess');
if (!firstAccess) this.render('welcome', {to: 'welcome'});
else this.render(null, {to: 'welcome'});
this.next();
});
});
Router.route('/', function() {
Session.set("selected", null);
this.render('details');
}, {
name: 'home',
layoutTemplate: 'page'
});
Router.route('/parking/:_id', {
name: 'parking',
layoutTemplate: 'page',
waitOn: function() {
return Meteor.subscribe('parking', this.params._id);
},
action: function() {
if (this.ready()) {
this.render('details', {
data: function() {
var parking = Parkings.findOne({_id: this.params._id});
if (parking && !Session.equals("selected", parking._id)) {
Session.set("selected", parking._id);
}
return parking;
}
});
}
}
});
Router.route('/profile', {
name: 'profile',
action: function() {
this.render('profile', {
data: function() {
var user = Meteor.user();
if (!user) return null;
return user.profile;
}
});
}
});