2016-10-26 08:02:58 +00:00
|
|
|
/* eslint-disable */
|
2016-11-04 10:24:59 +00:00
|
|
|
(() => {
|
|
|
|
window.gl = window.gl || {};
|
|
|
|
window.gl.issueBoards = window.gl.issueBoards || {};
|
|
|
|
|
2016-08-16 08:02:45 +00:00
|
|
|
const Store = gl.issueBoards.BoardsStore;
|
|
|
|
|
2016-10-07 15:18:42 +00:00
|
|
|
$(document).off('created.label').on('created.label', (e, label) => {
|
|
|
|
Store.new({
|
|
|
|
title: label.title,
|
|
|
|
position: Store.state.lists.length - 2,
|
|
|
|
list_type: 'label',
|
|
|
|
label: {
|
|
|
|
id: label.id,
|
|
|
|
title: label.title,
|
|
|
|
color: label.color
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-11-04 10:24:59 +00:00
|
|
|
gl.issueBoards.newListDropdownInit = () => {
|
|
|
|
$('.js-new-board-list').each(function () {
|
|
|
|
const $this = $(this);
|
|
|
|
new gl.CreateLabelDropdown($this.closest('.dropdown').find('.dropdown-new-label'), $this.data('namespace-path'), $this.data('project-path'));
|
2016-08-08 14:43:07 +00:00
|
|
|
|
2016-11-04 10:24:59 +00:00
|
|
|
$this.glDropdown({
|
|
|
|
data(term, callback) {
|
|
|
|
$.get($this.attr('data-labels'))
|
|
|
|
.then((resp) => {
|
|
|
|
callback(resp);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
renderRow (label) {
|
|
|
|
const active = Store.findList('title', label.title),
|
|
|
|
$li = $('<li />'),
|
|
|
|
$a = $('<a />', {
|
|
|
|
class: (active ? `is-active js-board-list-${active.id}` : ''),
|
|
|
|
text: label.title,
|
|
|
|
href: '#'
|
|
|
|
}),
|
|
|
|
$labelColor = $('<span />', {
|
|
|
|
class: 'dropdown-label-box',
|
|
|
|
style: `background-color: ${label.color}`
|
|
|
|
});
|
2016-08-01 13:18:30 +00:00
|
|
|
|
2016-11-04 10:24:59 +00:00
|
|
|
return $li.append($a.prepend($labelColor));
|
|
|
|
},
|
|
|
|
search: {
|
|
|
|
fields: ['title']
|
|
|
|
},
|
|
|
|
filterable: true,
|
|
|
|
selectable: true,
|
|
|
|
multiSelect: true,
|
|
|
|
clicked (label, $el, e) {
|
|
|
|
e.preventDefault();
|
2016-08-08 08:21:37 +00:00
|
|
|
|
2016-11-04 10:24:59 +00:00
|
|
|
if (!Store.findList('title', label.title)) {
|
|
|
|
Store.new({
|
2016-08-08 08:21:37 +00:00
|
|
|
title: label.title,
|
2016-11-04 10:24:59 +00:00
|
|
|
position: Store.state.lists.length - 2,
|
|
|
|
list_type: 'label',
|
|
|
|
label: {
|
|
|
|
id: label.id,
|
|
|
|
title: label.title,
|
|
|
|
color: label.color
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-08-08 08:21:37 +00:00
|
|
|
}
|
2016-11-04 10:24:59 +00:00
|
|
|
});
|
2016-08-01 13:18:30 +00:00
|
|
|
});
|
2016-11-04 10:24:59 +00:00
|
|
|
};
|
|
|
|
})();
|