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

82 lines
1.9 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2021-04-17 20:07:23 +05:30
import { mapActions, mapGetters, mapState } from 'vuex';
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
},
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']),
...mapGetters(['isSwimlanesOn']),
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-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
if (e.target.classList.contains('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;
if (isMultiSelect) {
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 });
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,
'user-can-drag': !disabled && item.id,
'is-disabled': disabled || !item.id,
'is-active': isActive,
}"
: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"
@mouseup="toggleIssue($event)"
>
<board-card-inner :list="list" :item="item" :update-filters="true" />
</li>
2018-03-17 18:26:18 +05:30
</template>