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

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

109 lines
3.2 KiB
Vue
Raw Normal View History

2020-06-23 00:09:42 +05:30
<script>
2021-03-11 19:13:27 +05:30
import { GlAlert } from '@gitlab/ui';
import { sortBy } from 'lodash';
2021-02-22 17:27:13 +05:30
import Draggable from 'vuedraggable';
2020-11-24 15:15:51 +05:30
import { mapState, mapGetters, mapActions } from 'vuex';
2021-04-17 20:07:23 +05:30
import BoardAddNewColumn from 'ee_else_ce/boards/components/board_add_new_column.vue';
2022-06-21 17:19:12 +05:30
import { defaultSortableOptions } from '~/sortable/constants';
2021-10-27 15:23:28 +05:30
import { DraggableItemTypes } from '../constants';
2021-03-11 19:13:27 +05:30
import BoardColumn from './board_column.vue';
2020-06-23 00:09:42 +05:30
export default {
2021-10-27 15:23:28 +05:30
draggableItemTypes: DraggableItemTypes,
2020-06-23 00:09:42 +05:30
components: {
2021-04-17 20:07:23 +05:30
BoardAddNewColumn,
2021-09-30 23:02:18 +05:30
BoardColumn,
2021-04-29 21:17:54 +05:30
BoardContentSidebar: () => import('~/boards/components/board_content_sidebar.vue'),
EpicBoardContentSidebar: () =>
import('ee_component/boards/components/epic_board_content_sidebar.vue'),
2020-11-24 15:15:51 +05:30
EpicsSwimlanes: () => import('ee_component/boards/components/epics_swimlanes.vue'),
GlAlert,
2020-06-23 00:09:42 +05:30
},
2021-04-29 21:17:54 +05:30
inject: ['canAdminList'],
2020-06-23 00:09:42 +05:30
props: {
disabled: {
type: Boolean,
required: true,
},
},
computed: {
2021-04-17 20:07:23 +05:30
...mapState(['boardLists', 'error', 'addColumnForm']),
2021-11-11 11:23:49 +05:30
...mapGetters(['isSwimlanesOn', 'isEpicBoard', 'isIssueBoard']),
2021-04-17 20:07:23 +05:30
addColumnFormVisible() {
return this.addColumnForm?.visible;
},
2020-11-24 15:15:51 +05:30
boardListsToUse() {
2021-11-11 11:23:49 +05:30
return sortBy([...Object.values(this.boardLists)], 'position');
2021-02-22 17:27:13 +05:30
},
canDragColumns() {
2021-11-11 11:23:49 +05:30
return this.canAdminList;
2021-02-22 17:27:13 +05:30
},
boardColumnWrapper() {
return this.canDragColumns ? Draggable : 'div';
},
draggableOptions() {
const options = {
2022-06-21 17:19:12 +05:30
...defaultSortableOptions,
2021-02-22 17:27:13 +05:30
disabled: this.disabled,
draggable: '.is-draggable',
fallbackOnBody: false,
group: 'boards-list',
tag: 'div',
2021-03-08 18:12:59 +05:30
value: this.boardListsToUse,
2021-02-22 17:27:13 +05:30
};
return this.canDragColumns ? options : {};
2020-06-23 00:09:42 +05:30
},
2020-11-24 15:15:51 +05:30
},
methods: {
2021-04-29 21:17:54 +05:30
...mapActions(['moveList', 'unsetError']),
2021-04-17 20:07:23 +05:30
afterFormEnters() {
const el = this.canDragColumns ? this.$refs.list.$el : this.$refs.list;
el.scrollTo({ left: el.scrollWidth, behavior: 'smooth' });
},
2020-11-24 15:15:51 +05:30
},
2020-06-23 00:09:42 +05:30
};
</script>
<template>
2021-04-29 21:17:54 +05:30
<div v-cloak data-qa-selector="boards_list">
<gl-alert v-if="error" variant="danger" :dismissible="true" @dismiss="unsetError">
2020-11-24 15:15:51 +05:30
{{ error }}
</gl-alert>
2021-02-22 17:27:13 +05:30
<component
:is="boardColumnWrapper"
2020-06-23 00:09:42 +05:30
v-if="!isSwimlanesOn"
2021-02-22 17:27:13 +05:30
ref="list"
v-bind="draggableOptions"
2022-10-11 01:57:18 +05:30
class="boards-list gl-w-full gl-py-5 gl-pr-3 gl-white-space-nowrap gl-overflow-x-scroll"
2021-10-27 15:23:28 +05:30
@end="moveList"
2020-06-23 00:09:42 +05:30
>
2021-11-11 11:23:49 +05:30
<board-column
2021-04-17 20:07:23 +05:30
v-for="(list, index) in boardListsToUse"
:key="index"
2020-06-23 00:09:42 +05:30
ref="board"
:list="list"
2021-10-27 15:23:28 +05:30
:data-draggable-item-type="$options.draggableItemTypes.list"
2020-06-23 00:09:42 +05:30
:disabled="disabled"
2022-07-16 23:28:13 +05:30
:class="{ 'gl-xs-display-none!': addColumnFormVisible }"
2020-06-23 00:09:42 +05:30
/>
2021-04-17 20:07:23 +05:30
<transition name="slide" @after-enter="afterFormEnters">
2022-07-16 23:28:13 +05:30
<board-add-new-column v-if="addColumnFormVisible" class="gl-xs-w-full!" />
2021-04-17 20:07:23 +05:30
</transition>
2021-02-22 17:27:13 +05:30
</component>
2020-11-24 15:15:51 +05:30
2021-03-08 18:12:59 +05:30
<epics-swimlanes
2021-04-29 21:17:54 +05:30
v-else-if="boardListsToUse.length"
2021-03-08 18:12:59 +05:30
ref="swimlanes"
:lists="boardListsToUse"
:can-admin-list="canAdminList"
:disabled="disabled"
/>
2021-11-11 11:23:49 +05:30
<board-content-sidebar v-if="isIssueBoard" data-testid="issue-boards-sidebar" />
2021-04-29 21:17:54 +05:30
2021-09-30 23:02:18 +05:30
<epic-board-content-sidebar v-else-if="isEpicBoard" data-testid="epic-boards-sidebar" />
2020-06-23 00:09:42 +05:30
</div>
</template>