board_sidebar.js 1.66 KB
Newer Older
1 2 3 4 5 6
/* eslint-disable comma-dangle, space-before-function-paren, no-new */
/* global IssuableContext */
/* global MilestoneSelect */
/* global LabelsSelect */
/* global Sidebar */

7 8
import Vue from 'vue';

9
require('./sidebar/remove_issue');
10

Phil Hughes's avatar
Phil Hughes committed
11 12 13 14 15 16 17
(() => {
  const Store = gl.issueBoards.BoardsStore;

  window.gl = window.gl || {};
  window.gl.issueBoards = window.gl.issueBoards || {};

  gl.issueBoards.BoardSidebar = Vue.extend({
18 19 20
    props: {
      currentUser: Object
    },
Phil Hughes's avatar
Phil Hughes committed
21 22
    data() {
      return {
23
        detail: Store.detail,
Phil Hughes's avatar
Phil Hughes committed
24 25
        issue: {},
        list: {},
Phil Hughes's avatar
Phil Hughes committed
26 27
      };
    },
28 29 30 31
    computed: {
      showSidebar () {
        return Object.keys(this.issue).length;
      }
Phil Hughes's avatar
Phil Hughes committed
32 33
    },
    watch: {
34
      detail: {
Phil Hughes's avatar
Phil Hughes committed
35
        handler () {
36 37 38 39
          if (this.issue.id !== this.detail.issue.id) {
            $('.js-issue-board-sidebar', this.$el).each((i, el) => {
              $(el).data('glDropdown').clearMenu();
            });
40
          }
41 42

          this.issue = this.detail.issue;
Phil Hughes's avatar
Phil Hughes committed
43
          this.list = this.detail.list;
Phil Hughes's avatar
Phil Hughes committed
44 45
        },
        deep: true
46 47 48 49
      },
      issue () {
        if (this.showSidebar) {
          this.$nextTick(() => {
50 51
            $('.right-sidebar').getNiceScroll(0).doScrollTop(0, 0);
            $('.right-sidebar').getNiceScroll().resize();
52 53 54 55 56 57 58
          });
        }
      }
    },
    methods: {
      closeSidebar () {
        this.detail.issue = {};
Phil Hughes's avatar
Phil Hughes committed
59
      }
60
    },
Fatih Acet's avatar
Fatih Acet committed
61
    mounted () {
62 63 64 65 66
      new IssuableContext(this.currentUser);
      new MilestoneSelect();
      new gl.DueDateSelectors();
      new LabelsSelect();
      new Sidebar();
67
      gl.Subscription.bindAll('.subscription');
Phil Hughes's avatar
Phil Hughes committed
68 69
    },
    components: {
70
      removeBtn: gl.issueBoards.RemoveIssueBtn,
Phil Hughes's avatar
Phil Hughes committed
71
    },
Phil Hughes's avatar
Phil Hughes committed
72 73
  });
})();