2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2017-08-17 22:00:37 +05:30
|
|
|
import Cookies from 'js-cookie';
|
2020-03-09 13:42:32 +05:30
|
|
|
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
|
2017-09-10 17:25:29 +05:30
|
|
|
import UsersSelect from './users_select';
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export default class IssuableContext {
|
|
|
|
constructor(currentUser) {
|
|
|
|
this.userSelect = new UsersSelect(currentUser);
|
2021-01-03 14:25:43 +05:30
|
|
|
this.reviewersSelect = new UsersSelect(currentUser, '.js-reviewer-search');
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
import(/* webpackChunkName: 'select2' */ 'select2/select2')
|
|
|
|
.then(() => {
|
|
|
|
$('select.select2').select2({
|
|
|
|
width: 'resolve',
|
|
|
|
dropdownAutoWidth: true,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
$('.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();
|
2020-03-09 13:42:32 +05:30
|
|
|
const supportedSizes = ['xs', 'sm', 'md'];
|
|
|
|
|
|
|
|
if (supportedSizes.includes(bpBreakpoint)) {
|
2018-03-17 18:26:18 +05:30
|
|
|
Cookies.set('collapsed_gutter', true);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|