LuminaWebsite/assets/js/reports.js
Maaxxs 8588c2fd58 Reports: exclude roles from auto-mute; wire up new landscape backgrounds
Adds a per-role opt-out from the auto-mute mechanic (e.g. Gildenleitung):
members with an excluded role keep accumulating report points normally,
but the timeout itself is skipped, same as the existing server-owner
exemption. Configured the same way as the point weighting - a list of
currently-excluded roles plus a green "+ Rolle ausschliessen" popup for
adding more. Split reports.js into two independently-guarded modal
initializers so the weights and exclusions popups do not depend on each
other being present.

Also wires in the 7 new landscape images as page backgrounds
(web-optimized JPEGs generated via Pillow): raids gets landscape6 as
requested, and the rest are split out for Premades, Mitglieder,
Berechtigungsgruppen, Reports and the logged-out login/homepage view,
which previously had no themed background at all.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-20 02:27:37 +02:00

127 lines
4.9 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();
});
}
initAddWeightModal();
initAddExclusionModal();
})();