summaryrefslogtreecommitdiffstats
path: root/client/components/swimlanes/swimlaneHeader.js
blob: 72437ba422036a0a642d7ce0815e959cfe0ddfcb (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
BlazeComponent.extendComponent({
  editTitle(evt) {
    evt.preventDefault();
    const newTitle = this.childComponents('inlinedForm')[0].getValue().trim();
    const swimlane = this.currentData();
    if (newTitle) {
      swimlane.rename(newTitle.trim());
    }
  },

  events() {
    return [{
      'click .js-open-swimlane-menu': Popup.open('swimlaneAction'),
      'click .js-open-add-swimlane-menu': Popup.open('swimlaneAdd'),
      submit: this.editTitle,
    }];
  },
}).register('swimlaneHeader');

Template.swimlaneActionPopup.events({
  'click .js-close-swimlane' (evt) {
    evt.preventDefault();
    this.archive();
    Popup.close();
  },
});

BlazeComponent.extendComponent({
  events() {
    return [{
      submit(evt) {
        evt.preventDefault();
        const titleInput = this.find('.swimlane-name-input');
        const title = titleInput.value.trim();
        if (title) {
          Swimlanes.insert({
            title,
            boardId: Session.get('currentBoard'),
            // XXX we should insert the swimlane right after the caller
            sort: $('.swimlane').length,
          });

          titleInput.value = '';
          titleInput.focus();
        }
        // XXX ideally, we should move the popup to the newly
        // created swimlane so a user can add more than one swimlane
        // with a minimum of interactions
        Popup.close();
      },
    }];
  },
}).register('swimlaneAddPopup');