board_card.vue 2.04 KB
Newer Older
1
<script>
2 3 4 5
/* eslint-disable vue/require-default-prop */
import IssueCardInner from './issue_card_inner.vue';
import eventHub from '../eventhub';
import boardsStore from '../stores/boards_store';
Phil Hughes's avatar
Phil Hughes committed
6

7 8 9 10 11 12 13 14 15
export default {
  name: 'BoardsIssueCard',
  components: {
    IssueCardInner,
  },
  props: {
    list: {
      type: Object,
      default: () => ({}),
Filipa Lacerda's avatar
Filipa Lacerda committed
16
    },
17 18 19
    issue: {
      type: Object,
      default: () => ({}),
Filipa Lacerda's avatar
Filipa Lacerda committed
20
    },
21 22 23
    issueLinkBase: {
      type: String,
      default: '',
Filipa Lacerda's avatar
Filipa Lacerda committed
24
    },
25 26 27
    disabled: {
      type: Boolean,
      default: false,
Filipa Lacerda's avatar
Filipa Lacerda committed
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 58 59 60
    index: {
      type: Number,
      default: 0,
    },
    rootPath: {
      type: String,
      default: '',
    },
    groupId: {
      type: Number,
    },
  },
  data() {
    return {
      showDetail: false,
      detailIssue: boardsStore.detail,
    };
  },
  computed: {
    issueDetailVisible() {
      return this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id;
    },
  },
  methods: {
    mouseDown() {
      this.showDetail = true;
    },
    mouseMove() {
      this.showDetail = false;
    },
    showIssue(e) {
      if (e.target.classList.contains('js-no-trigger')) return;
61

62 63
      if (this.showDetail) {
        this.showDetail = false;
Phil Hughes's avatar
Phil Hughes committed
64

65 66 67 68
        if (boardsStore.detail.issue && boardsStore.detail.issue.id === this.issue.id) {
          eventHub.$emit('clearDetailIssue');
        } else {
          eventHub.$emit('newDetailIssue', this.issue);
69
          boardsStore.setListDetail(this.list);
Phil Hughes's avatar
Phil Hughes committed
70
        }
71
      }
Phil Hughes's avatar
Phil Hughes committed
72
    },
73 74
  },
};
75 76 77
</script>

<template>
Filipa Lacerda's avatar
Filipa Lacerda committed
78 79 80 81
  <li
    :class="{
      'user-can-drag': !disabled && issue.id,
      'is-disabled': disabled || !issue.id,
Mike Greiling's avatar
Mike Greiling committed
82
      'is-active': issueDetailVisible,
Filipa Lacerda's avatar
Filipa Lacerda committed
83
    }"
84 85
    :index="index"
    :data-issue-id="issue.id"
86
    class="board-card p-3 rounded"
87 88
    @mousedown="mouseDown"
    @mousemove="mouseMove"
89
    @mouseup="showIssue($event)"
Mike Greiling's avatar
Mike Greiling committed
90
  >
91 92 93 94
    <issue-card-inner
      :list="list"
      :issue="issue"
      :issue-link-base="issueLinkBase"
Felipe Artur's avatar
Felipe Artur committed
95
      :group-id="groupId"
96
      :root-path="rootPath"
Filipa Lacerda's avatar
Filipa Lacerda committed
97 98
      :update-filters="true"
    />
99 100
  </li>
</template>