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