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

91 lines
2.2 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,
},
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;
},
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"
2021-04-17 20:07:23 +05:30
:class="{
'multi-select': multiSelectVisible,
2021-09-04 01:27:46 +05:30
'user-can-drag': isDraggable,
'is-disabled': isDisabled,
2021-04-17 20:07:23 +05:30
'is-active': isActive,
2021-09-04 01:27:46 +05:30
'gl-cursor-not-allowed gl-bg-gray-10': item.isLoading,
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"
data-testid="board_card"
class="board-card gl-p-5 gl-rounded-base"
2021-12-11 22:18:48 +05:30
@click="toggleIssue($event)"
2021-04-17 20:07:23 +05:30
>
<board-card-inner :list="list" :item="item" :update-filters="true" />
</li>
2018-03-17 18:26:18 +05:30
</template>