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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

115 lines
2.9 KiB
Vue
Raw Normal View History

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