debian-mirror-gitlab/app/assets/javascripts/boards/components/board_card.vue

116 lines
2.6 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2018-12-13 13:39:08 +05:30
/* eslint-disable vue/require-default-prop */
import IssueCardInner from './issue_card_inner.vue';
import eventHub from '../eventhub';
import boardsStore from '../stores/boards_store';
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
export default {
name: 'BoardsIssueCard',
components: {
IssueCardInner,
},
props: {
list: {
type: Object,
default: () => ({}),
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
issue: {
type: Object,
default: () => ({}),
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
issueLinkBase: {
type: String,
default: '',
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
disabled: {
type: Boolean,
default: false,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
index: {
type: Number,
default: 0,
},
rootPath: {
type: String,
default: '',
},
groupId: {
type: Number,
},
},
data() {
return {
showDetail: false,
detailIssue: boardsStore.detail,
2019-12-21 20:55:43 +05:30
multiSelect: boardsStore.multiSelect,
2018-12-13 13:39:08 +05:30
};
},
computed: {
issueDetailVisible() {
return this.detailIssue.issue && this.detailIssue.issue.id === this.issue.id;
},
2019-12-21 20:55:43 +05:30
multiSelectVisible() {
return this.multiSelect.list.findIndex(issue => issue.id === this.issue.id) > -1;
},
canMultiSelect() {
return gon.features && gon.features.multiSelectBoard;
},
2018-12-13 13:39:08 +05:30
},
methods: {
mouseDown() {
this.showDetail = true;
},
mouseMove() {
this.showDetail = false;
},
showIssue(e) {
if (e.target.classList.contains('js-no-trigger')) return;
if (this.showDetail) {
this.showDetail = false;
2018-03-17 18:26:18 +05:30
2019-12-21 20:55:43 +05:30
// If CMD or CTRL is clicked
const isMultiSelect = this.canMultiSelect && (e.ctrlKey || e.metaKey);
2018-12-13 13:39:08 +05:30
if (boardsStore.detail.issue && boardsStore.detail.issue.id === this.issue.id) {
2019-12-21 20:55:43 +05:30
eventHub.$emit('clearDetailIssue', isMultiSelect);
if (isMultiSelect) {
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
}
2018-12-13 13:39:08 +05:30
} else {
2019-12-21 20:55:43 +05:30
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
2019-09-04 21:01:54 +05:30
boardsStore.setListDetail(this.list);
2018-03-17 18:26:18 +05:30
}
2018-12-13 13:39:08 +05:30
}
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<li
:class="{
2019-12-21 20:55:43 +05:30
'multi-select': multiSelectVisible,
2018-03-17 18:26:18 +05:30
'user-can-drag': !disabled && issue.id,
'is-disabled': disabled || !issue.id,
2019-02-15 15:39:39 +05:30
'is-active': issueDetailVisible,
2018-03-17 18:26:18 +05:30
}"
:index="index"
:data-issue-id="issue.id"
2019-12-04 20:38:33 +05:30
data-qa-selector="board_card"
2019-07-31 22:56:46 +05:30
class="board-card p-3 rounded"
2018-03-17 18:26:18 +05:30
@mousedown="mouseDown"
@mousemove="mouseMove"
2019-03-02 22:35:43 +05:30
@mouseup="showIssue($event)"
2019-02-15 15:39:39 +05:30
>
2018-03-17 18:26:18 +05:30
<issue-card-inner
:list="list"
:issue="issue"
:issue-link-base="issueLinkBase"
2018-03-27 19:54:05 +05:30
:group-id="groupId"
2018-03-17 18:26:18 +05:30
:root-path="rootPath"
:update-filters="true"
/>
</li>
</template>