gitlab-org--gitlab-foss/app/assets/javascripts/boards/components/board_card.vue

130 lines
3 KiB
Vue
Raw Normal View History

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