2019-09-30 21:07:59 +05:30
|
|
|
import $ from 'jquery';
|
2018-11-08 19:23:39 +05:30
|
|
|
import Sortable from 'sortablejs';
|
2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2020-04-08 14:13:33 +05:30
|
|
|
import { GlButtonGroup, GlButton, GlLabel, GlTooltip } from '@gitlab/ui';
|
2020-01-01 13:55:28 +05:30
|
|
|
import isWipLimitsOn from 'ee_else_ce/boards/mixins/is_wip_limits';
|
2020-03-13 15:44:24 +05:30
|
|
|
import { s__, __, sprintf } from '~/locale';
|
2018-11-18 11:00:15 +05:30
|
|
|
import Icon from '~/vue_shared/components/icon.vue';
|
|
|
|
import Tooltip from '~/vue_shared/directives/tooltip';
|
2017-09-10 17:25:29 +05:30
|
|
|
import AccessorUtilities from '../../lib/utils/accessor';
|
2018-10-15 14:42:47 +05:30
|
|
|
import BoardBlankState from './board_blank_state.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
import BoardDelete from './board_delete';
|
|
|
|
import BoardList from './board_list.vue';
|
2020-01-01 13:55:28 +05:30
|
|
|
import IssueCount from './issue_count.vue';
|
2018-12-13 13:39:08 +05:30
|
|
|
import boardsStore from '../stores/boards_store';
|
|
|
|
import { getBoardSortableDefaultOptions, sortableEnd } from '../mixins/sortable_default_options';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { ListType } from '../constants';
|
2020-04-08 14:13:33 +05:30
|
|
|
import { isScopedLabel } from '~/lib/utils/common_utils';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default Vue.extend({
|
2017-08-17 22:00:37 +05:30
|
|
|
components: {
|
2018-10-15 14:42:47 +05:30
|
|
|
BoardBlankState,
|
2018-12-13 13:39:08 +05:30
|
|
|
BoardDelete,
|
|
|
|
BoardList,
|
2018-11-18 11:00:15 +05:30
|
|
|
Icon,
|
2020-01-01 13:55:28 +05:30
|
|
|
GlButtonGroup,
|
|
|
|
IssueCount,
|
|
|
|
GlButton,
|
2020-04-08 14:13:33 +05:30
|
|
|
GlLabel,
|
2020-01-01 13:55:28 +05:30
|
|
|
GlTooltip,
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
Tooltip,
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
mixins: [isWipLimitsOn],
|
2017-08-17 22:00:37 +05:30
|
|
|
props: {
|
2018-11-08 19:23:39 +05:30
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
issueLinkBase: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
rootPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
boardId: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
data() {
|
2017-08-17 22:00:37 +05:30
|
|
|
return {
|
2018-12-13 13:39:08 +05:30
|
|
|
detailIssue: boardsStore.detail,
|
|
|
|
filter: boardsStore.filter,
|
2017-08-17 22:00:37 +05:30
|
|
|
};
|
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
computed: {
|
2019-12-04 20:38:33 +05:30
|
|
|
isLoggedIn() {
|
|
|
|
return Boolean(gon.current_user_id);
|
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
showListHeaderButton() {
|
|
|
|
return (
|
|
|
|
!this.disabled && this.list.type !== ListType.closed && this.list.type !== ListType.blank
|
|
|
|
);
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
issuesTooltip() {
|
2018-11-18 11:00:15 +05:30
|
|
|
const { issuesSize } = this.list;
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
return sprintf(__('%{issuesSize} issues'), { issuesSize });
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
// Only needed to make karma pass.
|
|
|
|
weightCountToolTip() {}, // eslint-disable-line vue/return-in-computed-property
|
2019-09-30 21:07:59 +05:30
|
|
|
caretTooltip() {
|
|
|
|
return this.list.isExpanded ? s__('Boards|Collapse') : s__('Boards|Expand');
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
isNewIssueShown() {
|
2020-01-01 13:55:28 +05:30
|
|
|
return this.list.type === ListType.backlog || this.showListHeaderButton;
|
|
|
|
},
|
|
|
|
isSettingsShown() {
|
2019-07-07 11:18:12 +05:30
|
|
|
return (
|
2020-01-01 13:55:28 +05:30
|
|
|
this.list.type !== ListType.backlog &&
|
|
|
|
this.showListHeaderButton &&
|
|
|
|
this.list.isExpanded &&
|
|
|
|
this.isWipLimitsOn
|
2019-07-07 11:18:12 +05:30
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2020-01-01 13:55:28 +05:30
|
|
|
showBoardListAndBoardInfo() {
|
|
|
|
return this.list.type !== ListType.blank && this.list.type !== ListType.promotion;
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
uniqueKey() {
|
|
|
|
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
|
|
|
|
return `boards.${this.boardId}.${this.list.type}.${this.list.id}`;
|
|
|
|
},
|
2020-04-08 14:13:33 +05:30
|
|
|
helpLink() {
|
|
|
|
return boardsStore.scopedLabels.helpLink;
|
|
|
|
},
|
2018-11-18 11:00:15 +05:30
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
watch: {
|
|
|
|
filter: {
|
|
|
|
handler() {
|
|
|
|
this.list.page = 1;
|
2018-12-13 13:39:08 +05:30
|
|
|
this.list.getIssues(true).catch(() => {
|
|
|
|
// TODO: handle request error
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
|
|
|
deep: true,
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
mounted() {
|
2019-09-30 21:07:59 +05:30
|
|
|
const instance = this;
|
|
|
|
|
|
|
|
const sortableOptions = getBoardSortableDefaultOptions({
|
2017-08-17 22:00:37 +05:30
|
|
|
disabled: this.disabled,
|
|
|
|
group: 'boards',
|
|
|
|
draggable: '.is-draggable',
|
|
|
|
handle: '.js-board-handle',
|
2019-09-30 21:07:59 +05:30
|
|
|
onEnd(e) {
|
2018-12-13 13:39:08 +05:30
|
|
|
sortableEnd();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
const sortable = this;
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
if (e.newIndex !== undefined && e.oldIndex !== e.newIndex) {
|
2019-09-30 21:07:59 +05:30
|
|
|
const order = sortable.toArray();
|
2018-12-13 13:39:08 +05:30
|
|
|
const list = boardsStore.findList('id', parseInt(e.item.dataset.id, 10));
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
instance.$nextTick(() => {
|
2018-12-13 13:39:08 +05:30
|
|
|
boardsStore.moveList(list, order);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
}
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
Sortable.create(this.$el.parentNode, sortableOptions);
|
2017-08-17 22:00:37 +05:30
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
created() {
|
2019-12-04 20:38:33 +05:30
|
|
|
if (
|
|
|
|
this.list.isExpandable &&
|
|
|
|
AccessorUtilities.isLocalStorageAccessSafe() &&
|
|
|
|
!this.isLoggedIn
|
|
|
|
) {
|
2019-09-30 21:07:59 +05:30
|
|
|
const isCollapsed = localStorage.getItem(`${this.uniqueKey}.expanded`) === 'false';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
this.list.isExpanded = !isCollapsed;
|
|
|
|
}
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
methods: {
|
2020-04-08 14:13:33 +05:30
|
|
|
showScopedLabels(label) {
|
|
|
|
return boardsStore.scopedLabels.enabled && isScopedLabel(label);
|
|
|
|
},
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
showNewIssueForm() {
|
|
|
|
this.$refs['board-list'].showIssueForm = !this.$refs['board-list'].showIssueForm;
|
|
|
|
},
|
2019-09-30 21:07:59 +05:30
|
|
|
toggleExpanded() {
|
|
|
|
if (this.list.isExpandable) {
|
2018-11-08 19:23:39 +05:30
|
|
|
this.list.isExpanded = !this.list.isExpanded;
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
if (AccessorUtilities.isLocalStorageAccessSafe() && !this.isLoggedIn) {
|
2019-09-30 21:07:59 +05:30
|
|
|
localStorage.setItem(`${this.uniqueKey}.expanded`, this.list.isExpanded);
|
2018-11-08 19:23:39 +05:30
|
|
|
}
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
if (this.isLoggedIn) {
|
|
|
|
this.list.update();
|
|
|
|
}
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
// When expanding/collapsing, the tooltip on the caret button sometimes stays open.
|
|
|
|
// Close all tooltips manually to prevent dangling tooltips.
|
|
|
|
$('.tooltip').tooltip('hide');
|
2018-11-08 19:23:39 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
template: '#js-board-template',
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|