debian-mirror-gitlab/app/assets/javascripts/boards/components/board_sidebar.js

116 lines
3.4 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
// This is a true violation of @gitlab/no-runtime-template-compiler, as it
// relies on app/views/shared/boards/components/_sidebar.html.haml for its
// template.
/* eslint-disable no-new, @gitlab/no-runtime-template-compiler */
2017-08-17 22:00:37 +05:30
2021-03-11 19:13:27 +05:30
import { GlLabel } from '@gitlab/ui';
2018-05-09 12:01:36 +05:30
import $ from 'jquery';
2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2019-07-31 22:56:46 +05:30
import DueDateSelectors from '~/due_date_select';
import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select';
2021-03-11 19:13:27 +05:30
import { isScopedLabel } from '~/lib/utils/common_utils';
import { sprintf, __ } from '~/locale';
import MilestoneSelect from '~/milestone_select';
import Sidebar from '~/right_sidebar';
2019-07-31 22:56:46 +05:30
import AssigneeTitle from '~/sidebar/components/assignees/assignee_title.vue';
import Assignees from '~/sidebar/components/assignees/assignees.vue';
2021-03-11 19:13:27 +05:30
import SidebarAssigneesWidget from '~/sidebar/components/assignees/sidebar_assignees_widget.vue';
2019-07-31 22:56:46 +05:30
import Subscriptions from '~/sidebar/components/subscriptions/subscriptions.vue';
import TimeTracker from '~/sidebar/components/time_tracking/time_tracker.vue';
2021-03-11 19:13:27 +05:30
import eventHub from '~/sidebar/event_hub';
2018-12-13 13:39:08 +05:30
import boardsStore from '../stores/boards_store';
2017-08-17 22:00:37 +05:30
2018-12-13 13:39:08 +05:30
export default Vue.extend({
2018-11-08 19:23:39 +05:30
components: {
AssigneeTitle,
Assignees,
2020-04-08 14:13:33 +05:30
GlLabel,
2019-12-04 20:38:33 +05:30
SidebarEpicsSelect: () =>
import('ee_component/sidebar/components/sidebar_item_epics_select.vue'),
2018-11-08 19:23:39 +05:30
Subscriptions,
2019-07-31 22:56:46 +05:30
TimeTracker,
2021-03-11 19:13:27 +05:30
SidebarAssigneesWidget,
2018-11-08 19:23:39 +05:30
},
2017-08-17 22:00:37 +05:30
props: {
2018-11-08 19:23:39 +05:30
currentUser: {
type: Object,
default: () => ({}),
2020-04-22 19:07:51 +05:30
required: false,
2018-11-08 19:23:39 +05:30
},
2017-08-17 22:00:37 +05:30
},
data() {
return {
2018-12-13 13:39:08 +05:30
detail: boardsStore.detail,
2017-08-17 22:00:37 +05:30
issue: {},
list: {},
loadingAssignees: false,
2019-09-30 21:07:59 +05:30
timeTrackingLimitToHours: boardsStore.timeTracking.limitToHours,
2017-08-17 22:00:37 +05:30
};
},
computed: {
2018-12-13 13:39:08 +05:30
showSidebar() {
2017-08-17 22:00:37 +05:30
return Object.keys(this.issue).length;
},
2017-09-10 17:25:29 +05:30
milestoneTitle() {
2020-05-24 23:13:21 +05:30
return this.issue.milestone ? this.issue.milestone.title : __('No milestone');
2017-09-10 17:25:29 +05:30
},
canRemove() {
2020-06-23 00:09:42 +05:30
return !this.list?.preset;
2017-09-10 17:25:29 +05:30
},
2018-11-18 11:00:15 +05:30
hasLabels() {
return this.issue.labels && this.issue.labels.length;
},
labelDropdownTitle() {
2018-12-13 13:39:08 +05:30
return this.hasLabels
? sprintf(__('%{firstLabel} +%{labelCount} more'), {
firstLabel: this.issue.labels[0].title,
labelCount: this.issue.labels.length - 1,
})
: __('Label');
2018-11-18 11:00:15 +05:30
},
selectedLabels() {
2021-03-08 18:12:59 +05:30
return this.hasLabels ? this.issue.labels.map((l) => l.title).join(',') : '';
2018-12-13 13:39:08 +05:30
},
2017-08-17 22:00:37 +05:30
},
watch: {
detail: {
2018-12-13 13:39:08 +05:30
handler() {
2017-08-17 22:00:37 +05:30
if (this.issue.id !== this.detail.issue.id) {
$('.js-issue-board-sidebar', this.$el).each((i, el) => {
2021-03-08 18:12:59 +05:30
$(el).data('deprecatedJQueryDropdown').clearMenu();
2017-08-17 22:00:37 +05:30
});
}
this.issue = this.detail.issue;
this.list = this.detail.list;
},
2018-12-13 13:39:08 +05:30
deep: true,
2017-08-17 22:00:37 +05:30
},
},
2018-12-13 13:39:08 +05:30
created() {
2020-04-22 19:07:51 +05:30
eventHub.$on('sidebar.closeAll', this.closeSidebar);
2018-11-08 19:23:39 +05:30
},
beforeDestroy() {
2020-04-22 19:07:51 +05:30
eventHub.$off('sidebar.closeAll', this.closeSidebar);
2018-11-08 19:23:39 +05:30
},
2018-12-13 13:39:08 +05:30
mounted() {
2018-11-08 19:23:39 +05:30
new IssuableContext(this.currentUser);
new MilestoneSelect();
new DueDateSelectors();
new LabelsSelect();
new Sidebar();
},
2017-08-17 22:00:37 +05:30
methods: {
2018-12-13 13:39:08 +05:30
closeSidebar() {
2017-08-17 22:00:37 +05:30
this.detail.issue = {};
},
2021-04-17 20:07:23 +05:30
setAssignees(assignees) {
boardsStore.detail.issue.setAssignees(assignees);
2017-08-17 22:00:37 +05:30
},
2019-07-31 22:56:46 +05:30
showScopedLabels(label) {
return boardsStore.scopedLabels.enabled && isScopedLabel(label);
},
2017-08-17 22:00:37 +05:30
},
});