2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2017-08-17 22:00:37 +05:30
|
|
|
import Cookies from 'js-cookie';
|
2017-09-10 17:25:29 +05:30
|
|
|
import bp from './breakpoints';
|
|
|
|
import UsersSelect from './users_select';
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default class IssuableContext {
|
|
|
|
constructor(currentUser) {
|
|
|
|
this.userSelect = new UsersSelect(currentUser);
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
$('select.select2').select2({
|
|
|
|
width: 'resolve',
|
|
|
|
dropdownAutoWidth: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$('.issuable-sidebar .inline-update').on('change', '.js-assignee', function onClickAssignee() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$(document)
|
|
|
|
.off('click', '.issuable-sidebar .dropdown-content a')
|
|
|
|
.on('click', '.issuable-sidebar .dropdown-content a', e => e.preventDefault());
|
|
|
|
|
|
|
|
$(document)
|
|
|
|
.off('click', '.edit-link')
|
|
|
|
.on('click', '.edit-link', function onClickEdit(e) {
|
2016-09-13 17:45:13 +05:30
|
|
|
e.preventDefault();
|
2018-03-17 18:26:18 +05:30
|
|
|
const $block = $(this).parents('.block');
|
|
|
|
const $selectbox = $block.find('.selectbox');
|
2016-09-13 17:45:13 +05:30
|
|
|
if ($selectbox.is(':visible')) {
|
|
|
|
$selectbox.hide();
|
2018-10-15 14:42:47 +05:30
|
|
|
$block.find('.value:not(.dont-hide)').show();
|
2016-09-13 17:45:13 +05:30
|
|
|
} else {
|
|
|
|
$selectbox.show();
|
2018-10-15 14:42:47 +05:30
|
|
|
$block.find('.value:not(.dont-hide)').hide();
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
if ($selectbox.is(':visible')) {
|
|
|
|
setTimeout(() => $block.find('.dropdown-menu-toggle').trigger('click'), 0);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
window.addEventListener('beforeunload', () => {
|
|
|
|
// collapsed_gutter cookie hides the sidebar
|
|
|
|
const bpBreakpoint = bp.getBreakpointSize();
|
|
|
|
if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') {
|
|
|
|
Cookies.set('collapsed_gutter', true);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|