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

62 lines
1.4 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2020-11-24 15:15:51 +05:30
import BoardCardLayout from './board_card_layout.vue';
2018-12-13 13:39:08 +05:30
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: {
2020-11-24 15:15:51 +05:30
BoardCardLayout,
2018-12-13 13:39:08 +05:30
},
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
},
methods: {
2020-11-24 15:15:51 +05:30
// These are methods instead of computed's, because boardsStore is not reactive.
isActive() {
return this.getActiveId() === this.issue.id;
2018-12-13 13:39:08 +05:30
},
2020-11-24 15:15:51 +05:30
getActiveId() {
return boardsStore.detail?.issue?.id;
2018-12-13 13:39:08 +05:30
},
2020-11-24 15:15:51 +05:30
showIssue({ isMultiSelect }) {
2020-04-22 19:07:51 +05:30
// If no issues are opened, close all sidebars first
2020-11-24 15:15:51 +05:30
if (!this.getActiveId()) {
2020-04-22 19:07:51 +05:30
sidebarEventHub.$emit('sidebar.closeAll');
}
2020-11-24 15:15:51 +05:30
if (this.isActive()) {
eventHub.$emit('clearDetailIssue', isMultiSelect);
2020-04-22 19:07:51 +05:30
2020-11-24 15:15:51 +05:30
if (isMultiSelect) {
2019-12-21 20:55:43 +05:30
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
2018-03-17 18:26:18 +05:30
}
2020-11-24 15:15:51 +05:30
} else {
eventHub.$emit('newDetailIssue', this.issue, isMultiSelect);
boardsStore.setListDetail(this.list);
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>
2020-11-24 15:15:51 +05:30
<board-card-layout
2019-12-04 20:38:33 +05:30
data-qa-selector="board_card"
2020-11-24 15:15:51 +05:30
:issue="issue"
:list="list"
:is-active="isActive()"
v-bind="$attrs"
@show="showIssue"
/>
2018-03-17 18:26:18 +05:30
</template>