2017-11-14 06:05:40 +00:00
|
|
|
<script>
|
2021-05-05 15:10:05 +00:00
|
|
|
import { mapActions, mapState } from 'vuex';
|
2021-06-11 12:09:49 +00:00
|
|
|
import Tracking from '~/tracking';
|
2021-02-25 06:10:51 +00:00
|
|
|
import BoardCardInner from './board_card_inner.vue';
|
2017-02-23 15:27:01 +00:00
|
|
|
|
2018-10-30 20:28:31 +00:00
|
|
|
export default {
|
2021-02-22 03:10:36 +00:00
|
|
|
name: 'BoardCard',
|
2018-10-30 20:28:31 +00:00
|
|
|
components: {
|
2021-02-25 06:10:51 +00:00
|
|
|
BoardCardInner,
|
2018-10-30 20:28:31 +00:00
|
|
|
},
|
2021-06-11 12:09:49 +00:00
|
|
|
mixins: [Tracking.mixin()],
|
2018-10-30 20:28:31 +00:00
|
|
|
props: {
|
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
2020-03-18 15:09:45 +00:00
|
|
|
required: false,
|
2018-01-04 19:07:28 +00:00
|
|
|
},
|
2021-03-11 09:09:36 +00:00
|
|
|
item: {
|
2018-10-30 20:28:31 +00:00
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
2020-03-18 15:09:45 +00:00
|
|
|
required: false,
|
2018-01-04 19:07:28 +00:00
|
|
|
},
|
2021-02-22 03:10:36 +00:00
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
index: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
required: false,
|
|
|
|
},
|
2018-10-30 20:28:31 +00:00
|
|
|
},
|
2021-02-22 03:10:36 +00:00
|
|
|
computed: {
|
|
|
|
...mapState(['selectedBoardItems', 'activeId']),
|
2020-08-25 06:10:18 +00:00
|
|
|
isActive() {
|
2021-03-11 09:09:36 +00:00
|
|
|
return this.item.id === this.activeId;
|
2018-10-30 20:28:31 +00:00
|
|
|
},
|
2021-02-22 03:10:36 +00:00
|
|
|
multiSelectVisible() {
|
|
|
|
return (
|
|
|
|
!this.activeId &&
|
2021-03-11 09:09:36 +00:00
|
|
|
this.selectedBoardItems.findIndex((boardItem) => boardItem.id === this.item.id) > -1
|
2021-02-22 03:10:36 +00:00
|
|
|
);
|
2018-10-30 20:28:31 +00:00
|
|
|
},
|
2021-05-21 06:11:06 +00:00
|
|
|
isDisabled() {
|
|
|
|
return this.disabled || !this.item.id || this.item.isLoading;
|
|
|
|
},
|
|
|
|
isDraggable() {
|
|
|
|
return !this.disabled && this.item.id && !this.item.isLoading;
|
|
|
|
},
|
2021-02-22 03:10:36 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['toggleBoardItemMultiSelection', 'toggleBoardItem']),
|
|
|
|
toggleIssue(e) {
|
|
|
|
// Don't do anything if this happened on a no trigger element
|
2021-04-29 15:10:07 +00:00
|
|
|
if (e.target.closest('.js-no-trigger')) return;
|
2020-04-09 12:09:24 +00:00
|
|
|
|
2021-02-22 03:10:36 +00:00
|
|
|
const isMultiSelect = e.ctrlKey || e.metaKey;
|
2021-05-27 18:10:52 +00:00
|
|
|
if (isMultiSelect && gon?.features?.boardMultiSelect) {
|
2021-03-11 09:09:36 +00:00
|
|
|
this.toggleBoardItemMultiSelection(this.item);
|
2020-08-25 06:10:18 +00:00
|
|
|
} else {
|
2021-03-11 09:09:36 +00:00
|
|
|
this.toggleBoardItem({ boardItem: this.item });
|
2021-06-11 12:09:49 +00:00
|
|
|
this.track('click_card', { label: 'right_sidebar' });
|
2018-10-30 20:28:31 +00:00
|
|
|
}
|
2017-02-23 15:49:12 +00:00
|
|
|
},
|
2018-10-30 20:28:31 +00:00
|
|
|
},
|
|
|
|
};
|
2017-11-14 06:05:40 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-02-22 03:10:36 +00:00
|
|
|
<li
|
2019-08-15 14:38:46 +00:00
|
|
|
data-qa-selector="board_card"
|
2021-02-22 03:10:36 +00:00
|
|
|
:class="{
|
|
|
|
'multi-select': multiSelectVisible,
|
2021-05-21 06:11:06 +00:00
|
|
|
'user-can-drag': isDraggable,
|
|
|
|
'is-disabled': isDisabled,
|
2021-02-22 03:10:36 +00:00
|
|
|
'is-active': isActive,
|
2021-05-21 06:11:06 +00:00
|
|
|
'gl-cursor-not-allowed gl-bg-gray-10': item.isLoading,
|
2021-02-22 03:10:36 +00:00
|
|
|
}"
|
|
|
|
:index="index"
|
2021-03-11 09:09:36 +00:00
|
|
|
:data-item-id="item.id"
|
|
|
|
:data-item-iid="item.iid"
|
|
|
|
:data-item-path="item.referencePath"
|
2021-02-22 03:10:36 +00:00
|
|
|
data-testid="board_card"
|
|
|
|
class="board-card gl-p-5 gl-rounded-base"
|
|
|
|
@mouseup="toggleIssue($event)"
|
|
|
|
>
|
2021-03-11 09:09:36 +00:00
|
|
|
<board-card-inner :list="list" :item="item" :update-filters="true" />
|
2021-02-22 03:10:36 +00:00
|
|
|
</li>
|
2017-11-14 06:05:40 +00:00
|
|
|
</template>
|