board_blank_state.js.es6 1.3 KB
Newer Older
1
(() => {
P
Phil Hughes 已提交
2
  const BoardBlankState = Vue.extend({
3 4 5 6 7 8 9 10 11 12
    data: function () {
      return {
        predefinedLabels: [
          new Label({ title: 'Development', color: '#5CB85C' }),
          new Label({ title: 'Testing', color: '#F0AD4E' }),
          new Label({ title: 'Production', color: '#FF5F00' }),
          new Label({ title: 'Ready', color: '#FF0000' })
        ]
      }
    },
P
Phil Hughes 已提交
13 14
    methods: {
      addDefaultLists: function () {
15
        BoardsStore.removeBlankState();
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
        _.each(this.predefinedLabels, (label, i) => {
          BoardsStore.addList({
            title: label.title,
            position: i,
            type: 'label',
            label: {
              title: label.title,
              color: label.color
            }
          });
        });

        // Save the labels
        gl.boardService
          .generateDefaultLists()
          .then((resp) => {
            const data = resp.json();
34

35 36 37 38 39 40 41
            _.each(data, (listObj) => {
              const list = BoardsStore.findList('title', listObj.title);
              list.id = listObj.id;
              list.label.id = listObj.label.id;
              list.getIssues();
            });
          });
P
Phil Hughes 已提交
42 43
      },
      clearBlankState: function () {
44
        BoardsStore.removeBlankState();
P
Phil Hughes 已提交
45 46 47 48 49 50
      }
    }
  });

  Vue.component('board-blank-state', BoardBlankState);
})();