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

22 lines
753 B
JavaScript
Raw Normal View History

2021-06-08 01:23:25 +05:30
document.addEventListener('DOMContentLoaded', () => {
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);
});
});