2017-11-14 01:05:40 -05:00
|
|
|
<script>
|
2018-10-30 16:28:31 -04:00
|
|
|
/* eslint-disable vue/require-default-prop */
|
|
|
|
import IssueCardInner from './issue_card_inner.vue';
|
|
|
|
import eventHub from '../eventhub';
|
2020-04-09 08:09:24 -04:00
|
|
|
import sidebarEventHub from '~/sidebar/event_hub';
|
2018-10-30 16:28:31 -04:00
|
|
|
import boardsStore from '../stores/boards_store';
|
2017-02-23 10:27:01 -05:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
export default {
|
|
|
|
name: 'BoardsIssueCard',
|
|
|
|
components: {
|
|
|
|
IssueCardInner,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-01-04 14:07:28 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
issue: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-01-04 14:07:28 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
issueLinkBase: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-01-04 14:07:28 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-01-04 14:07:28 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
index: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
rootPath: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
groupId: {
|
|
|
|
type: Number,
|
2020-03-18 11:09:45 -04:00
|
|
|
required: false,
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showDetail: false,
|
|
|
|
detailIssue: boardsStore.detail,
|
2019-10-15 05:06:09 -04:00
|
|
|
multiSelect: boardsStore.multiSelect,
|
2018-10-30 16:28:31 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
issueDetailVisible() {
|
|
|
|
return this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id;
|
|
|
|
},
|
2019-10-15 05:06:09 -04:00
|
|
|
multiSelectVisible() {
|
|
|
|
return this.multiSelect.list.findIndex(issue => issue.id === this.issue.id) > -1;
|
|
|
|
},
|
|
|
|
canMultiSelect() {
|
|
|
|
return gon.features && gon.features.multiSelectBoard;
|
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
mouseDown() {
|
|
|
|
this.showDetail = true;
|
|
|
|
},
|
|
|
|
mouseMove() {
|
|
|
|
this.showDetail = false;
|
|
|
|
},
|
|
|
|
showIssue(e) {
|
|
|
|
if (e.target.classList.contains('js-no-trigger')) return;
|
2017-02-23 10:27:01 -05:00
|
|
|
|
2020-04-09 08:09:24 -04:00
|
|
|
// If no issues are opened, close all sidebars first
|
|
|
|
if (!boardsStore.detail?.issue?.id) {
|
|
|
|
sidebarEventHub.$emit('sidebar.closeAll');
|
|
|
|
}
|
|
|
|
|
2020-02-21 04:09:01 -05:00
|
|
|
// If CMD or CTRL is clicked
|
|
|
|
const isMultiSelect = this.canMultiSelect && (e.ctrlKey || e.metaKey);
|
|
|
|
|
|
|
|
if (this.showDetail || isMultiSelect) {
|
|
|
|
this.showDetail = false;
|
2019-10-15 05:06:09 -04:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
if (boardsStore.detail.issue && boardsStore.detail.issue.id === this.issue.id) {
|
2019-10-15 05:06:09 -04:00
|
|
|
eventHub.$emit('clearDetailIssue', isMultiSelect);
|
|
|
|
|
|
|
|
if (isMultiSelect) {
|
2020-06-22 20:08:58 -04:00
|
|
|
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
|
2019-10-15 05:06:09 -04:00
|
|
|
}
|
2018-10-30 16:28:31 -04:00
|
|
|
} else {
|
2020-06-22 20:08:58 -04:00
|
|
|
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
|
2019-06-05 08:44:29 -04:00
|
|
|
boardsStore.setListDetail(this.list);
|
2017-02-23 10:27:01 -05:00
|
|
|
}
|
2018-10-30 16:28:31 -04:00
|
|
|
}
|
2017-02-23 10:49:12 -05:00
|
|
|
},
|
2018-10-30 16:28:31 -04:00
|
|
|
},
|
|
|
|
};
|
2017-11-14 01:05:40 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2018-01-04 14:07:28 -05:00
|
|
|
<li
|
|
|
|
:class="{
|
2019-10-15 05:06:09 -04:00
|
|
|
'multi-select': multiSelectVisible,
|
2018-01-04 14:07:28 -05:00
|
|
|
'user-can-drag': !disabled && issue.id,
|
|
|
|
'is-disabled': disabled || !issue.id,
|
2018-11-16 15:07:38 -05:00
|
|
|
'is-active': issueDetailVisible,
|
2018-01-04 14:07:28 -05:00
|
|
|
}"
|
2017-11-14 01:05:40 -05:00
|
|
|
:index="index"
|
|
|
|
:data-issue-id="issue.id"
|
2019-08-15 10:38:46 -04:00
|
|
|
data-qa-selector="board_card"
|
2019-04-29 03:40:25 -04:00
|
|
|
class="board-card p-3 rounded"
|
2017-11-14 01:05:40 -05:00
|
|
|
@mousedown="mouseDown"
|
|
|
|
@mousemove="mouseMove"
|
2019-01-10 16:56:37 -05:00
|
|
|
@mouseup="showIssue($event)"
|
2018-11-16 15:07:38 -05:00
|
|
|
>
|
2017-11-14 01:05:40 -05:00
|
|
|
<issue-card-inner
|
|
|
|
:list="list"
|
|
|
|
:issue="issue"
|
|
|
|
:issue-link-base="issueLinkBase"
|
2018-02-19 14:06:16 -05:00
|
|
|
:group-id="groupId"
|
2017-11-14 01:05:40 -05:00
|
|
|
:root-path="rootPath"
|
2018-01-05 09:31:01 -05:00
|
|
|
:update-filters="true"
|
|
|
|
/>
|
2017-11-14 01:05:40 -05:00
|
|
|
</li>
|
|
|
|
</template>
|