board_card.vue 1.6 KB

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