BigW Consortium Gitlab

board_card.js 1.55 KB
Newer Older
1
import './issue_card_inner';
Phil Hughes committed
2 3 4

const Store = gl.issueBoards.BoardsStore;

5
export default {
Phil Hughes committed
6 7 8 9 10 11 12 13 14 15 16 17 18
  name: 'BoardsIssueCard',
  template: `
    <li class="card"
      :class="{ 'user-can-drag': !disabled && issue.id, 'is-disabled': disabled || !issue.id, 'is-active': issueDetailVisible }"
      :index="index"
      :data-issue-id="issue.id"
      @mousedown="mouseDown"
      @mousemove="mouseMove"
      @mouseup="showIssue($event)">
      <issue-card-inner
        :list="list"
        :issue="issue"
        :issue-link-base="issueLinkBase"
19 20
        :root-path="rootPath"
        :update-filters="true" />
Phil Hughes committed
21 22 23 24 25 26 27 28 29 30 31 32 33
    </li>
  `,
  components: {
    'issue-card-inner': gl.issueBoards.IssueCardInner,
  },
  props: {
    list: Object,
    issue: Object,
    issueLinkBase: String,
    disabled: Boolean,
    index: Number,
    rootPath: String,
  },
Phil Hughes committed
34
  data() {
Phil Hughes committed
35 36
    return {
      showDetail: false,
Phil Hughes committed
37
      detailIssue: Store.detail,
Phil Hughes committed
38 39 40
    };
  },
  computed: {
Phil Hughes committed
41
    issueDetailVisible() {
Phil Hughes committed
42
      return this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id;
Phil Hughes committed
43
    },
Phil Hughes committed
44 45
  },
  methods: {
Phil Hughes committed
46
    mouseDown() {
Phil Hughes committed
47 48 49 50 51
      this.showDetail = true;
    },
    mouseMove() {
      this.showDetail = false;
    },
Phil Hughes committed
52
    showIssue(e) {
53
      if (e.target.classList.contains('js-no-trigger')) return;
Phil Hughes committed
54 55 56 57 58 59 60 61 62 63 64

      if (this.showDetail) {
        this.showDetail = false;

        if (Store.detail.issue && Store.detail.issue.id === this.issue.id) {
          Store.detail.issue = {};
        } else {
          Store.detail.issue = this.issue;
          Store.detail.list = this.list;
        }
      }
Phil Hughes committed
65 66
    },
  },
Phil Hughes committed
67
};