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

66 lines
1.5 KiB
JavaScript
Raw Normal View History

/* eslint-disable comma-dangle, space-before-function-paren, no-new */
/* global Vue */
/* global IssuableContext */
/* global MilestoneSelect */
/* global LabelsSelect */
/* global Sidebar */
2016-10-04 14:27:02 +00:00
(() => {
const Store = gl.issueBoards.BoardsStore;
window.gl = window.gl || {};
window.gl.issueBoards = window.gl.issueBoards || {};
gl.issueBoards.BoardSidebar = Vue.extend({
props: {
currentUser: Object
},
2016-10-04 14:27:02 +00:00
data() {
return {
2016-10-05 07:49:40 +00:00
detail: Store.detail,
issue: {}
2016-10-04 14:27:02 +00:00
};
},
2016-10-05 07:49:40 +00:00
computed: {
showSidebar () {
return Object.keys(this.issue).length;
}
2016-10-04 14:27:02 +00:00
},
watch: {
2016-10-05 07:49:40 +00:00
detail: {
2016-10-04 14:27:02 +00:00
handler () {
if (this.issue.id !== this.detail.issue.id) {
$('.js-issue-board-sidebar', this.$el).each((i, el) => {
$(el).data('glDropdown').clearMenu();
});
}
this.issue = this.detail.issue;
2016-10-04 14:27:02 +00:00
},
deep: true
2016-10-05 07:49:40 +00:00
},
issue () {
if (this.showSidebar) {
this.$nextTick(() => {
$('.right-sidebar').getNiceScroll(0).doScrollTop(0, 0);
$('.right-sidebar').getNiceScroll().resize();
2016-10-05 07:49:40 +00:00
});
}
}
},
methods: {
closeSidebar () {
this.detail.issue = {};
2016-10-04 14:27:02 +00:00
}
},
2016-11-03 00:37:33 +00:00
mounted () {
new IssuableContext(this.currentUser);
new MilestoneSelect();
new gl.DueDateSelectors();
new LabelsSelect();
new Sidebar();
gl.Subscription.bindAll('.subscription');
2016-10-04 14:27:02 +00:00
}
});
})();