The dense table row (avatar, name, time, reason/evidence, badges, actions all crammed into one baseline-misaligned line) is now a stacked list of report cards, matching the panel/avatar-chip language used elsewhere on the site: a colored left border for quick status scanning (green = active, muted = archived, gold on hover with a slight lift), a header row with a 40px avatar and reporter subtitle, reason/evidence in their own section, and a footer row for the incident timestamp and the archive/delete actions. Verified the user-filter dropdown still layers correctly above the new cards, since each card now also uses backdrop-filter (same stacking- context concern fixed previously via .panel-filter-bar's z-index). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
194 lines
7.6 KiB
JavaScript
194 lines
7.6 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
// ---- "Rolle hinzufügen" (Punkte-Gewichtung, zweistufiges Popup) ----
|
|
function initAddWeightModal() {
|
|
var modal = document.getElementById('report-add-role-modal');
|
|
var addBtn = document.getElementById('report-add-role-btn');
|
|
if (!modal || !addBtn) return;
|
|
|
|
var step1 = modal.querySelector('.report-role-step[data-step="1"]');
|
|
var step2 = modal.querySelector('.report-role-step[data-step="2"]');
|
|
var nextBtn = document.getElementById('report-role-step1-next');
|
|
var backBtn = document.getElementById('report-role-step2-back');
|
|
var submitBtn = document.getElementById('report-role-step2-submit');
|
|
var summaryEl = document.getElementById('report-role-step2-summary');
|
|
var pointsInput = document.getElementById('report-role-points');
|
|
var form = document.getElementById('report-add-role-form');
|
|
var pointsField = document.getElementById('report-add-role-points-field');
|
|
var idsContainer = document.getElementById('report-add-role-ids-container');
|
|
var closeBtn = modal.querySelector('.modal-close');
|
|
var checkboxes = modal.querySelectorAll('input[name="role_ids[]"]');
|
|
|
|
function showStep(n) {
|
|
step1.hidden = n !== 1;
|
|
step2.hidden = n !== 2;
|
|
}
|
|
|
|
function updateNextState() {
|
|
var anyChecked = Array.prototype.some.call(checkboxes, function (cb) { return cb.checked; });
|
|
nextBtn.disabled = !anyChecked;
|
|
}
|
|
|
|
function resetModal() {
|
|
checkboxes.forEach(function (cb) { cb.checked = false; });
|
|
pointsInput.value = '1';
|
|
updateNextState();
|
|
showStep(1);
|
|
}
|
|
|
|
addBtn.addEventListener('click', function () {
|
|
resetModal();
|
|
modal.hidden = false;
|
|
});
|
|
closeBtn.addEventListener('click', function () { modal.hidden = true; });
|
|
modal.addEventListener('click', function (e) {
|
|
if (e.target === modal) modal.hidden = true;
|
|
});
|
|
|
|
checkboxes.forEach(function (cb) {
|
|
cb.addEventListener('change', updateNextState);
|
|
});
|
|
|
|
nextBtn.addEventListener('click', function () {
|
|
var names = [];
|
|
checkboxes.forEach(function (cb) {
|
|
if (cb.checked) names.push(cb.getAttribute('data-role-name') || '');
|
|
});
|
|
summaryEl.textContent = names.join(', ');
|
|
showStep(2);
|
|
});
|
|
|
|
backBtn.addEventListener('click', function () {
|
|
showStep(1);
|
|
});
|
|
|
|
submitBtn.addEventListener('click', function () {
|
|
var points = pointsInput.value.trim();
|
|
if (points === '' || isNaN(Number(points))) {
|
|
pointsInput.focus();
|
|
return;
|
|
}
|
|
|
|
idsContainer.innerHTML = '';
|
|
checkboxes.forEach(function (cb) {
|
|
if (!cb.checked) return;
|
|
var hidden = document.createElement('input');
|
|
hidden.type = 'hidden';
|
|
hidden.name = 'role_ids[]';
|
|
hidden.value = cb.value;
|
|
idsContainer.appendChild(hidden);
|
|
});
|
|
pointsField.value = points;
|
|
form.submit();
|
|
});
|
|
}
|
|
|
|
// ---- "Rolle ausschließen" (Timeout-Ausnahmen, einstufiges Popup) ----
|
|
function initAddExclusionModal() {
|
|
var modal = document.getElementById('report-add-exclusion-modal');
|
|
var addBtn = document.getElementById('report-add-exclusion-btn');
|
|
if (!modal || !addBtn) return;
|
|
|
|
var closeBtn = modal.querySelector('.modal-close');
|
|
var submitBtn = document.getElementById('report-exclusion-submit');
|
|
var form = document.getElementById('report-add-exclusion-form');
|
|
var idsContainer = document.getElementById('report-add-exclusion-ids-container');
|
|
var checkboxes = modal.querySelectorAll('input[name="role_ids[]"]');
|
|
|
|
addBtn.addEventListener('click', function () {
|
|
checkboxes.forEach(function (cb) { cb.checked = false; });
|
|
modal.hidden = false;
|
|
});
|
|
closeBtn.addEventListener('click', function () { modal.hidden = true; });
|
|
modal.addEventListener('click', function (e) {
|
|
if (e.target === modal) modal.hidden = true;
|
|
});
|
|
|
|
submitBtn.addEventListener('click', function () {
|
|
idsContainer.innerHTML = '';
|
|
var anyChecked = false;
|
|
checkboxes.forEach(function (cb) {
|
|
if (!cb.checked) return;
|
|
anyChecked = true;
|
|
var hidden = document.createElement('input');
|
|
hidden.type = 'hidden';
|
|
hidden.name = 'role_ids[]';
|
|
hidden.value = cb.value;
|
|
idsContainer.appendChild(hidden);
|
|
});
|
|
if (!anyChecked) return;
|
|
form.submit();
|
|
});
|
|
}
|
|
|
|
// ---- Nach gemeldetem Nutzer filtern (eigenes Dropdown mit Avataren) ----
|
|
function initUserFilter() {
|
|
var wrapper = document.getElementById('report-user-filter');
|
|
var trigger = document.getElementById('report-user-filter-trigger');
|
|
var triggerContent = document.getElementById('report-user-filter-trigger-content');
|
|
var panel = document.getElementById('report-user-filter-panel');
|
|
var options = panel ? panel.querySelectorAll('.user-filter-option') : [];
|
|
var rows = document.querySelectorAll('.report-card');
|
|
var emptyMessage = document.getElementById('report-filter-empty');
|
|
if (!wrapper || !trigger || !panel || !options.length || !rows.length) return;
|
|
|
|
function closePanel() {
|
|
panel.classList.remove('open');
|
|
panel.hidden = true;
|
|
trigger.classList.remove('open');
|
|
trigger.setAttribute('aria-expanded', 'false');
|
|
}
|
|
|
|
function openPanel() {
|
|
panel.hidden = false;
|
|
requestAnimationFrame(function () { panel.classList.add('open'); });
|
|
trigger.classList.add('open');
|
|
trigger.setAttribute('aria-expanded', 'true');
|
|
}
|
|
|
|
trigger.addEventListener('click', function () {
|
|
if (panel.classList.contains('open')) {
|
|
closePanel();
|
|
} else {
|
|
openPanel();
|
|
}
|
|
});
|
|
|
|
document.addEventListener('click', function (e) {
|
|
if (!wrapper.contains(e.target)) closePanel();
|
|
});
|
|
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Escape') closePanel();
|
|
});
|
|
|
|
options.forEach(function (option) {
|
|
option.addEventListener('click', function () {
|
|
var userId = option.getAttribute('data-user-id') || '';
|
|
var visual = option.querySelector('.user-filter-option-visual');
|
|
|
|
options.forEach(function (o) {
|
|
var isSelected = o === option;
|
|
o.classList.toggle('selected', isSelected);
|
|
o.setAttribute('aria-selected', isSelected ? 'true' : 'false');
|
|
});
|
|
|
|
if (visual) triggerContent.innerHTML = visual.innerHTML;
|
|
closePanel();
|
|
|
|
var visibleCount = 0;
|
|
rows.forEach(function (row) {
|
|
var matches = userId === '' || row.getAttribute('data-reported-id') === userId;
|
|
row.hidden = !matches;
|
|
if (matches) visibleCount++;
|
|
});
|
|
if (emptyMessage) emptyMessage.hidden = visibleCount !== 0;
|
|
});
|
|
});
|
|
}
|
|
|
|
initAddWeightModal();
|
|
initAddExclusionModal();
|
|
initUserFilter();
|
|
})();
|