2020-04-28 18:41:59 +08:00
|
|
|
function initAssignedTasksDropdown(table) {
|
|
|
|
function loadTasks(counterContainer) {
|
|
|
|
var tasksContainer = counterContainer.find('.tasks');
|
|
|
|
var tasksUrl = counterContainer.data('task-list-url');
|
|
|
|
var searchQuery = counterContainer.find('.search-tasks').val();
|
|
|
|
$.get(tasksUrl, { query: searchQuery }, function(result) {
|
|
|
|
tasksContainer.html(result.html);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(table).on('show.bs.dropdown', '.assign-counter-container', function() {
|
|
|
|
var cell = $(this);
|
|
|
|
loadTasks(cell);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(table).on('click', '.assign-counter-container .dropdown-menu', function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
2020-05-22 20:36:28 +08:00
|
|
|
$(table).on('click', '.assign-counter-container .clear-search', function() {
|
|
|
|
var cell = $(this).closest('.assign-counter-container');
|
|
|
|
$(this).prev('.search-tasks').val('');
|
|
|
|
loadTasks(cell);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(table).on('keyup', '.assign-counter-container .search-tasks', function() {
|
2020-04-28 18:41:59 +08:00
|
|
|
var cell = $(this).closest('.assign-counter-container');
|
|
|
|
loadTasks(cell);
|
|
|
|
});
|
|
|
|
}
|
2020-07-17 21:17:09 +08:00
|
|
|
|
|
|
|
function prepareRepositoryHeaderForExport(th) {
|
|
|
|
var val;
|
|
|
|
switch ($(th).attr('id')) {
|
|
|
|
case 'checkbox':
|
|
|
|
val = -1;
|
|
|
|
break;
|
|
|
|
case 'assigned':
|
|
|
|
val = -2;
|
|
|
|
break;
|
|
|
|
case 'row-id':
|
|
|
|
val = -3;
|
|
|
|
break;
|
|
|
|
case 'row-name':
|
|
|
|
val = -4;
|
|
|
|
break;
|
|
|
|
case 'added-by':
|
|
|
|
val = -5;
|
|
|
|
break;
|
|
|
|
case 'added-on':
|
|
|
|
val = -6;
|
|
|
|
break;
|
|
|
|
case 'archived-by':
|
|
|
|
val = -7;
|
|
|
|
break;
|
|
|
|
case 'archived-on':
|
|
|
|
val = -8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
val = th.attr('id');
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
2022-03-15 17:24:35 +08:00
|
|
|
|
|
|
|
function initReminderDropdown(table) {
|
2022-03-24 17:16:47 +08:00
|
|
|
$(table).on('keyup', '.row-reminders-dropdown', function(e) {
|
2022-05-16 17:16:07 +08:00
|
|
|
if (e.key === 'Escape' && $('.row-reminders-dropdown').hasClass('open')) {
|
2022-04-09 00:08:55 +08:00
|
|
|
$(this).children('.dropdown-menu').dropdown('toggle');
|
2022-05-16 17:16:07 +08:00
|
|
|
// Preventing closing modal on full view mode for assigning repository items
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2022-03-24 17:16:47 +08:00
|
|
|
}
|
|
|
|
});
|
2022-05-16 17:16:07 +08:00
|
|
|
|
|
|
|
$(table).on('keyup', '.row-reminders-footer', function(e) {
|
|
|
|
if (e.key === ' ') {
|
|
|
|
$(this).click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-03-15 17:24:35 +08:00
|
|
|
$(table).on('show.bs.dropdown', '.row-reminders-dropdown', function() {
|
|
|
|
let row = $(this).closest('tr');
|
|
|
|
let screenHeight = screen.height;
|
|
|
|
let rowPosition = row[0].getBoundingClientRect().y;
|
2022-03-24 17:16:47 +08:00
|
|
|
let dropdownMenu = $(this).find('.dropdown-menu');
|
2022-04-04 18:10:14 +08:00
|
|
|
if ((screenHeight / 2) < rowPosition && $('.repository-show').length) {
|
2022-03-24 17:16:47 +08:00
|
|
|
dropdownMenu.css({ top: 'unset', bottom: '100%' });
|
2022-03-15 17:24:35 +08:00
|
|
|
} else {
|
2022-03-24 17:16:47 +08:00
|
|
|
dropdownMenu.css({ bottom: 'unset', top: '100%' });
|
2022-03-15 17:24:35 +08:00
|
|
|
}
|
|
|
|
$.ajax({
|
|
|
|
url: $(this).attr('data-row-reminders-url'),
|
|
|
|
type: 'GET',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data) {
|
2022-03-24 17:16:47 +08:00
|
|
|
dropdownMenu.html(data.html);
|
2022-03-15 17:24:35 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$(table).on('click', '.row-reminders-footer', function(e) {
|
|
|
|
var dropdownMenuLength = $(this).closest('.dropdown-menu').children().length;
|
|
|
|
var bellIcon = $(this).closest('.row-reminders-dropdown');
|
|
|
|
$.ajax({
|
|
|
|
url: $(this).attr('data-row-hide-reminders-url'),
|
|
|
|
type: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function() {
|
|
|
|
$(this).closest('.row-reminders-notification').remove();
|
|
|
|
|
|
|
|
if (dropdownMenuLength === 1) {
|
|
|
|
bellIcon.remove();
|
|
|
|
}
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|