summaryrefslogtreecommitdiffstats
path: root/client/components/boards/router.js
blob: 9c5bee351217a51807d90f65053ba0ebdfe44fdf (plain)
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
51
52
53
54
55
56
57
Meteor.subscribe('boards');

var boardSubsManager = new SubsManager();

Router.route('/boards', {
  name: 'Boards',
  template: 'boards',
  authenticated: true,
  onBeforeAction: function() {
    Session.set('currentBoard', '');
    Filter.reset();
    this.next();
  }
});

Router.route('/boards/:_id/:slug', {
  name: 'Board',
  template: 'board',
  onAfterAction: function() {
    // XXX We probably shouldn't rely on Session
    Session.set('sidebarIsOpen', true);
    Session.set('currentWidget', 'home');
    Session.set('menuWidgetIsOpen', false);
  },
  waitOn: function() {
    var params = this.params;
    Session.set('currentBoard', params._id);
    Session.set('currentCard', null);

    return boardSubsManager.subscribe('board', params._id, params.slug);
  },
  data: function() {
    return Boards.findOne(this.params._id);
  }
});

Router.route('/boards/:boardId/:slug/:cardId', {
  name: 'Card',
  template: 'board',
  onAfterAction: function() {
    Tracker.nonreactive(function() {
      if (! Session.get('currentCard') && typeof Sidebar !== 'undefined') {
        Sidebar.hide();
      }
    });
    var params = this.params;
    Session.set('currentBoard', params.boardId);
    Session.set('currentCard', params.cardId);
  },
  waitOn: function() {
    var params = this.params;
    return boardSubsManager.subscribe('board', params.boardId, params.slug);
  },
  data: function() {
    return Boards.findOne(this.params.boardId);
  }
});