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

130 lines
3 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';
2020-04-22 19:07:51 +05:30
import sidebarEventHub from '~/sidebar/event_hub';
2018-12-13 13:39:08 +05:30
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: () => ({}),
2020-04-22 19:07:51 +05:30
required: false,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
issue: {
type: Object,
default: () => ({}),
2020-04-22 19:07:51 +05:30
required: false,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
issueLinkBase: {
type: String,
default: '',
2020-04-22 19:07:51 +05:30
required: false,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
disabled: {
type: Boolean,
default: false,
2020-04-22 19:07:51 +05:30
required: false,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
index: {
type: Number,
default: 0,
2020-04-22 19:07:51 +05:30
required: false,
2018-12-13 13:39:08 +05:30
},
rootPath: {
type: String,
default: '',
2020-04-22 19:07:51 +05:30
required: false,
2018-12-13 13:39:08 +05:30
},
groupId: {
type: Number,
2020-04-22 19:07:51 +05:30
required: false,
2018-12-13 13:39:08 +05:30
},
},
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;
2018-03-17 18:26:18 +05:30
2020-04-22 19:07:51 +05:30
// If no issues are opened, close all sidebars first
if (!boardsStore.detail?.issue?.id) {
sidebarEventHub.$emit('sidebar.closeAll');
}
2020-04-08 14:13:33 +05:30
// If CMD or CTRL is clicked
const isMultiSelect = this.canMultiSelect && (e.ctrlKey || e.metaKey);
if (this.showDetail || isMultiSelect) {
this.showDetail = false;
2019-12-21 20:55:43 +05:30
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>