2020-04-22 19:07:51 +05:30
|
|
|
<script>
|
2020-11-24 15:15:51 +05:30
|
|
|
import { mapGetters, mapActions } from 'vuex';
|
2020-04-22 19:07:51 +05:30
|
|
|
import Sortable from 'sortablejs';
|
2020-10-24 23:57:45 +05:30
|
|
|
import BoardListHeader from 'ee_else_ce/boards/components/board_list_header.vue';
|
2020-04-22 19:07:51 +05:30
|
|
|
import Tooltip from '~/vue_shared/directives/tooltip';
|
|
|
|
import EmptyComponent from '~/vue_shared/components/empty_component';
|
2020-11-24 15:15:51 +05:30
|
|
|
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
2020-04-22 19:07:51 +05:30
|
|
|
import BoardList from './board_list.vue';
|
2021-01-03 14:25:43 +05:30
|
|
|
import BoardListNew from './board_list_new.vue';
|
2020-04-22 19:07:51 +05:30
|
|
|
import boardsStore from '../stores/boards_store';
|
2020-06-23 00:09:42 +05:30
|
|
|
import eventHub from '../eventhub';
|
2020-04-22 19:07:51 +05:30
|
|
|
import { getBoardSortableDefaultOptions, sortableEnd } from '../mixins/sortable_default_options';
|
|
|
|
import { ListType } from '../constants';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
BoardPromotionState: EmptyComponent,
|
2020-06-23 00:09:42 +05:30
|
|
|
BoardListHeader,
|
2021-01-03 14:25:43 +05:30
|
|
|
BoardList: gon.features?.graphqlBoardLists ? BoardListNew : BoardList,
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
Tooltip,
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
mixins: [glFeatureFlagMixin()],
|
2020-04-22 19:07:51 +05:30
|
|
|
props: {
|
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
canAdminList: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
inject: {
|
|
|
|
boardId: {
|
2021-01-03 14:25:43 +05:30
|
|
|
default: '',
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
detailIssue: boardsStore.detail,
|
|
|
|
filter: boardsStore.filter,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2020-11-24 15:15:51 +05:30
|
|
|
...mapGetters(['getIssues']),
|
2020-04-22 19:07:51 +05:30
|
|
|
showBoardListAndBoardInfo() {
|
2021-01-03 14:25:43 +05:30
|
|
|
return this.list.type !== ListType.promotion;
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
uniqueKey() {
|
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
|
|
|
return `boards.${this.boardId}.${this.list.type}.${this.list.id}`;
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
listIssues() {
|
|
|
|
if (!this.glFeatures.graphqlBoardLists) {
|
|
|
|
return this.list.issues;
|
|
|
|
}
|
|
|
|
return this.getIssues(this.list.id);
|
|
|
|
},
|
|
|
|
shouldFetchIssues() {
|
|
|
|
return this.glFeatures.graphqlBoardLists && this.list.type !== ListType.blank;
|
|
|
|
},
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filter: {
|
|
|
|
handler() {
|
2020-11-24 15:15:51 +05:30
|
|
|
if (this.shouldFetchIssues) {
|
2021-01-03 14:25:43 +05:30
|
|
|
this.fetchIssuesForList({ listId: this.list.id });
|
2020-11-24 15:15:51 +05:30
|
|
|
} else {
|
|
|
|
this.list.page = 1;
|
|
|
|
this.list.getIssues(true).catch(() => {
|
|
|
|
// TODO: handle request error
|
|
|
|
});
|
|
|
|
}
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
deep: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-11-24 15:15:51 +05:30
|
|
|
if (this.shouldFetchIssues) {
|
2021-01-03 14:25:43 +05:30
|
|
|
this.fetchIssuesForList({ listId: this.list.id });
|
2020-11-24 15:15:51 +05:30
|
|
|
}
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
const instance = this;
|
|
|
|
|
|
|
|
const sortableOptions = getBoardSortableDefaultOptions({
|
|
|
|
disabled: this.disabled,
|
|
|
|
group: 'boards',
|
|
|
|
draggable: '.is-draggable',
|
|
|
|
handle: '.js-board-handle',
|
|
|
|
onEnd(e) {
|
|
|
|
sortableEnd();
|
|
|
|
|
|
|
|
const sortable = this;
|
|
|
|
|
|
|
|
if (e.newIndex !== undefined && e.oldIndex !== e.newIndex) {
|
|
|
|
const order = sortable.toArray();
|
|
|
|
const list = boardsStore.findList('id', parseInt(e.item.dataset.id, 10));
|
|
|
|
|
|
|
|
instance.$nextTick(() => {
|
|
|
|
boardsStore.moveList(list, order);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
Sortable.create(this.$el.parentNode, sortableOptions);
|
|
|
|
},
|
|
|
|
methods: {
|
2020-11-24 15:15:51 +05:30
|
|
|
...mapActions(['fetchIssuesForList']),
|
2020-06-23 00:09:42 +05:30
|
|
|
showListNewIssueForm(listId) {
|
|
|
|
eventHub.$emit('showForm', listId);
|
2020-04-22 19:07:51 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
'is-draggable': !list.preset,
|
|
|
|
'is-expandable': list.isExpandable,
|
|
|
|
'is-collapsed': !list.isExpanded,
|
|
|
|
'board-type-assignee': list.type === 'assignee',
|
|
|
|
}"
|
|
|
|
:data-id="list.id"
|
2020-06-23 00:09:42 +05:30
|
|
|
class="board gl-h-full gl-px-3 gl-vertical-align-top gl-white-space-normal"
|
2020-04-22 19:07:51 +05:30
|
|
|
data-qa-selector="board_list"
|
|
|
|
>
|
2020-06-23 00:09:42 +05:30
|
|
|
<div
|
|
|
|
class="board-inner gl-display-flex gl-flex-direction-column gl-relative gl-h-full gl-rounded-base"
|
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<board-list-header :can-admin-list="canAdminList" :list="list" :disabled="disabled" />
|
2020-04-22 19:07:51 +05:30
|
|
|
<board-list
|
|
|
|
v-if="showBoardListAndBoardInfo"
|
|
|
|
ref="board-list"
|
|
|
|
:disabled="disabled"
|
2020-11-24 15:15:51 +05:30
|
|
|
:issues="listIssues"
|
2020-04-22 19:07:51 +05:30
|
|
|
:list="list"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<!-- Will be only available in EE -->
|
|
|
|
<board-promotion-state v-if="list.id === 'promotion'" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|