2018-06-16 13:20:30 +00:00
|
|
|
/* eslint-disable comma-dangle, no-new */
|
2016-12-14 03:01:05 +00:00
|
|
|
|
2018-03-09 20:18:59 +00:00
|
|
|
import $ from 'jquery';
|
2017-03-17 17:21:25 +00:00
|
|
|
import Vue from 'vue';
|
2017-10-02 12:32:53 +00:00
|
|
|
import Flash from '../../flash';
|
2018-02-12 20:28:57 +00:00
|
|
|
import { __ } from '../../locale';
|
2017-12-15 12:57:08 +00:00
|
|
|
import Sidebar from '../../right_sidebar';
|
2017-05-04 12:11:15 +00:00
|
|
|
import eventHub from '../../sidebar/event_hub';
|
2018-02-27 17:44:10 +00:00
|
|
|
import assigneeTitle from '../../sidebar/components/assignees/assignee_title.vue';
|
2018-02-06 16:30:35 +00:00
|
|
|
import assignees from '../../sidebar/components/assignees/assignees.vue';
|
2017-10-18 11:31:01 +00:00
|
|
|
import DueDateSelectors from '../../due_date_select';
|
2018-06-21 12:07:05 +00:00
|
|
|
import removeBtn from './sidebar/remove_issue.vue';
|
2017-10-26 20:21:55 +00:00
|
|
|
import IssuableContext from '../../issuable_context';
|
2017-11-01 12:32:15 +00:00
|
|
|
import LabelsSelect from '../../labels_select';
|
2017-11-14 06:05:40 +00:00
|
|
|
import subscriptions from '../../sidebar/components/subscriptions/subscriptions.vue';
|
2017-12-28 20:07:05 +00:00
|
|
|
import MilestoneSelect from '../../milestone_select';
|
2016-12-14 03:01:05 +00:00
|
|
|
|
2017-04-10 23:52:46 +00:00
|
|
|
const Store = gl.issueBoards.BoardsStore;
|
2016-10-04 14:27:02 +00:00
|
|
|
|
2017-04-10 23:52:46 +00:00
|
|
|
window.gl = window.gl || {};
|
|
|
|
window.gl.issueBoards = window.gl.issueBoards || {};
|
2016-10-04 14:27:02 +00:00
|
|
|
|
2017-04-10 23:52:46 +00:00
|
|
|
gl.issueBoards.BoardSidebar = Vue.extend({
|
2018-06-11 09:49:47 +00:00
|
|
|
components: {
|
|
|
|
assigneeTitle,
|
|
|
|
assignees,
|
2018-06-21 12:07:05 +00:00
|
|
|
removeBtn,
|
2018-06-11 09:49:47 +00:00
|
|
|
subscriptions,
|
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
props: {
|
2018-06-11 09:49:47 +00:00
|
|
|
currentUser: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
detail: Store.detail,
|
|
|
|
issue: {},
|
|
|
|
list: {},
|
2017-05-04 12:11:15 +00:00
|
|
|
loadingAssignees: false,
|
2017-04-10 23:52:46 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showSidebar () {
|
|
|
|
return Object.keys(this.issue).length;
|
2017-05-02 21:38:40 +00:00
|
|
|
},
|
2017-05-03 22:21:14 +00:00
|
|
|
milestoneTitle() {
|
|
|
|
return this.issue.milestone ? this.issue.milestone.title : 'No Milestone';
|
2017-07-03 07:44:58 +00:00
|
|
|
},
|
|
|
|
canRemove() {
|
|
|
|
return !this.list.preset;
|
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
detail: {
|
|
|
|
handler () {
|
|
|
|
if (this.issue.id !== this.detail.issue.id) {
|
2017-05-17 15:26:52 +00:00
|
|
|
$('.block.assignee')
|
|
|
|
.find('input:not(.js-vue)[name="issue[assignee_ids][]"]')
|
|
|
|
.each((i, el) => {
|
|
|
|
$(el).remove();
|
|
|
|
});
|
|
|
|
|
2017-04-10 23:52:46 +00:00
|
|
|
$('.js-issue-board-sidebar', this.$el).each((i, el) => {
|
|
|
|
$(el).data('glDropdown').clearMenu();
|
2016-10-05 07:49:40 +00:00
|
|
|
});
|
|
|
|
}
|
2017-04-10 23:52:46 +00:00
|
|
|
|
|
|
|
this.issue = this.detail.issue;
|
|
|
|
this.list = this.detail.list;
|
|
|
|
},
|
|
|
|
deep: true
|
2016-10-05 07:49:40 +00:00
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
},
|
2018-06-11 09:49:47 +00:00
|
|
|
created () {
|
|
|
|
// Get events from glDropdown
|
|
|
|
eventHub.$on('sidebar.removeAssignee', this.removeAssignee);
|
|
|
|
eventHub.$on('sidebar.addAssignee', this.addAssignee);
|
|
|
|
eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees);
|
|
|
|
eventHub.$on('sidebar.saveAssignees', this.saveAssignees);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
eventHub.$off('sidebar.removeAssignee', this.removeAssignee);
|
|
|
|
eventHub.$off('sidebar.addAssignee', this.addAssignee);
|
|
|
|
eventHub.$off('sidebar.removeAllAssignees', this.removeAllAssignees);
|
|
|
|
eventHub.$off('sidebar.saveAssignees', this.saveAssignees);
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
new IssuableContext(this.currentUser);
|
|
|
|
new MilestoneSelect();
|
|
|
|
new DueDateSelectors();
|
|
|
|
new LabelsSelect();
|
|
|
|
new Sidebar();
|
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
methods: {
|
|
|
|
closeSidebar () {
|
|
|
|
this.detail.issue = {};
|
2017-05-04 12:11:15 +00:00
|
|
|
},
|
|
|
|
assignSelf () {
|
|
|
|
// Notify gl dropdown that we are now assigning to current user
|
|
|
|
this.$refs.assigneeBlock.dispatchEvent(new Event('assignYourself'));
|
|
|
|
|
|
|
|
this.addAssignee(this.currentUser);
|
|
|
|
this.saveAssignees();
|
|
|
|
},
|
|
|
|
removeAssignee (a) {
|
|
|
|
gl.issueBoards.BoardsStore.detail.issue.removeAssignee(a);
|
|
|
|
},
|
|
|
|
addAssignee (a) {
|
|
|
|
gl.issueBoards.BoardsStore.detail.issue.addAssignee(a);
|
|
|
|
},
|
|
|
|
removeAllAssignees () {
|
|
|
|
gl.issueBoards.BoardsStore.detail.issue.removeAllAssignees();
|
|
|
|
},
|
|
|
|
saveAssignees () {
|
|
|
|
this.loadingAssignees = true;
|
|
|
|
|
2018-04-04 21:43:33 +00:00
|
|
|
gl.issueBoards.BoardsStore.detail.issue.update()
|
2017-05-04 12:11:15 +00:00
|
|
|
.then(() => {
|
|
|
|
this.loadingAssignees = false;
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
this.loadingAssignees = false;
|
2018-02-12 20:28:57 +00:00
|
|
|
Flash(__('An error occurred while saving assignees'));
|
2017-05-04 12:11:15 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
2017-04-10 23:52:46 +00:00
|
|
|
});
|