debian-mirror-gitlab/app/assets/javascripts/pages/admin/labels/index/index.js

24 lines
736 B
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
function initLabels() {
2021-06-08 01:23:25 +05:30
const pagination = document.querySelector('.labels .gl-pagination');
const emptyState = document.querySelector('.labels .nothing-here-block.hidden');
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
function removeLabelSuccessCallback() {
this.closest('li').classList.add('gl-display-none!');
const labelsCount = document.querySelectorAll(
'ul.manage-labels-list li:not(.gl-display-none\\!)',
).length;
// display the empty state if there are no more labels
if (labelsCount < 1 && !pagination && emptyState) {
emptyState.classList.remove('hidden');
}
}
document.querySelectorAll('.js-remove-label').forEach((row) => {
row.addEventListener('ajax:success', removeLabelSuccessCallback);
});
2021-09-30 23:02:18 +05:30
}
initLabels();