gitlab-org--gitlab-foss/app/assets/javascripts/boards/components/board_sidebar.js

75 lines
1.6 KiB
JavaScript
Raw Normal View History

/* eslint-disable comma-dangle, space-before-function-paren, no-new */
/* global IssuableContext */
/* global MilestoneSelect */
/* global LabelsSelect */
/* global Sidebar */
2017-03-17 17:21:25 +00:00
import Vue from 'vue';
require('./sidebar/remove_issue');
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({
props: {
currentUser: Object
},
data() {
return {
detail: Store.detail,
issue: {},
list: {},
};
},
computed: {
showSidebar () {
return Object.keys(this.issue).length;
},
assigneeId() {
return this.issue.assignee ? this.issue.assignee.id : 0;
2017-04-10 23:52:46 +00:00
}
},
watch: {
detail: {
handler () {
if (this.issue.id !== this.detail.issue.id) {
$('.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
issue () {
if (this.showSidebar) {
this.$nextTick(() => {
$('.right-sidebar').getNiceScroll(0).doScrollTop(0, 0);
$('.right-sidebar').getNiceScroll().resize();
});
2016-10-04 14:27:02 +00:00
}
2017-04-10 23:52:46 +00:00
}
},
methods: {
closeSidebar () {
this.detail.issue = {};
}
},
mounted () {
new IssuableContext(this.currentUser);
new MilestoneSelect();
new gl.DueDateSelectors();
new LabelsSelect();
new Sidebar();
gl.Subscription.bindAll('.subscription');
},
components: {
removeBtn: gl.issueBoards.RemoveIssueBtn,
},
});