Premades: replace inline invite/class selects with popup modals

Invite now opens a member-list popup instead of an inline auto-submit
select, and class selection reuses the raid-signup modal's class-picker
grid, triggered via a "Klasse festlegen/ändern" button.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Maaxxs 2026-09-20 01:05:06 +02:00
parent 1ca3f2e339
commit 2d3a3562c2
3 changed files with 174 additions and 41 deletions

View file

@ -828,29 +828,59 @@ input:focus, select:focus, textarea:focus {
font-size: 1.3rem; font-size: 1.3rem;
} }
.premade-invite-inline { width: 100%; } .premade-slot-invite-btn {
background: none;
.premade-invite-inline select { border: none;
width: 100%; padding: 1rem 2rem;
padding: 0.45rem 0.6rem;
font-size: 0.82rem;
color: var(--text-muted); color: var(--text-muted);
background: transparent; font-size: 1.5rem;
border: 1px dashed var(--border); line-height: 1;
border-radius: 6px; cursor: pointer;
} }
.premade-invite-inline select:hover { border-color: var(--gold); color: var(--gold); } .premade-slot-invite-btn:hover { color: var(--gold); }
.premade-class-select { .premade-class-btn {
width: auto; background: none;
max-width: 100%; border: none;
padding: 0.15rem 0.4rem; padding: 0;
margin: 0;
font: inherit;
font-size: 0.78rem; font-size: 0.78rem;
border-radius: 4px; font-weight: 600;
color: var(--text-muted); text-align: left;
color: var(--gold);
cursor: pointer;
} }
.premade-class-btn:hover { color: var(--gold-hover); text-decoration: underline; }
.premade-invite-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-height: 340px;
overflow-y: auto;
margin: 1.25rem 0;
}
.premade-invite-option {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.5rem 0.75rem;
background: var(--bg-panel-alt);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
cursor: pointer;
text-align: left;
font-size: 0.95rem;
width: 100%;
}
.premade-invite-option:hover { border-color: var(--gold); color: var(--gold); }
.premade-slot-name { .premade-slot-name {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

74
assets/js/premades.js Normal file
View file

@ -0,0 +1,74 @@
(function () {
'use strict';
function openModal(modal) {
if (modal) modal.hidden = false;
}
function closeModal(modal) {
if (modal) modal.hidden = true;
}
function wireModal(modal) {
if (!modal) return;
var closeBtn = modal.querySelector('.modal-close');
if (closeBtn) closeBtn.addEventListener('click', function () { closeModal(modal); });
modal.addEventListener('click', function (e) {
if (e.target === modal) closeModal(modal);
});
}
// ---- Mitglied einladen ----
var inviteModal = document.getElementById('premade-invite-modal');
var inviteForm = document.getElementById('premade-invite-form');
var invitePremadeIdField = document.getElementById('premade-invite-premade-id');
var inviteUserIdField = document.getElementById('premade-invite-user-id');
wireModal(inviteModal);
document.querySelectorAll('.premade-slot-invite-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
invitePremadeIdField.value = btn.getAttribute('data-premade-id') || '';
openModal(inviteModal);
});
});
if (inviteModal) {
inviteModal.querySelectorAll('.premade-invite-option').forEach(function (btn) {
btn.addEventListener('click', function () {
inviteUserIdField.value = btn.getAttribute('data-user-id') || '';
inviteForm.submit();
});
});
}
// ---- Klasse festlegen/aendern ----
var classModal = document.getElementById('premade-class-modal');
var classForm = document.getElementById('premade-class-form');
var classPremadeIdField = document.getElementById('premade-class-premade-id');
var classValueField = document.getElementById('premade-class-value');
wireModal(classModal);
document.querySelectorAll('.premade-class-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
classPremadeIdField.value = btn.getAttribute('data-premade-id') || '';
var currentClass = btn.getAttribute('data-current-class') || '';
if (classModal) {
classModal.querySelectorAll('.class-picker-option').forEach(function (option) {
option.classList.toggle('selected', option.getAttribute('data-class') === currentClass);
});
}
openModal(classModal);
});
});
if (classModal) {
classModal.querySelectorAll('.class-picker-option').forEach(function (btn) {
btn.addEventListener('click', function () {
classValueField.value = btn.getAttribute('data-class') || '';
classForm.submit();
});
});
}
})();

View file

@ -89,7 +89,7 @@ foreach ($premades as $p) {
} }
} }
$inviteCandidates = []; $inviteCandidates = [];
foreach (db()->query("SELECT discord_id, discord_username, display_name FROM users WHERE discord_id IS NOT NULL AND status = 'active' ORDER BY display_name, username")->fetchAll() as $row) { foreach (db()->query("SELECT id, discord_id, discord_username, display_name, avatar_filename FROM users WHERE discord_id IS NOT NULL AND status = 'active' ORDER BY display_name, username")->fetchAll() as $row) {
if (in_array((int) $row['discord_id'], $busyDiscordIds, true)) { if (in_array((int) $row['discord_id'], $busyDiscordIds, true)) {
continue; continue;
} }
@ -201,19 +201,7 @@ include __DIR__ . '/includes/header.php';
<div class="premade-slot premade-slot-empty<?= $isInvitable ? ' premade-slot-invitable' : '' ?>"> <div class="premade-slot premade-slot-empty<?= $isInvitable ? ' premade-slot-invitable' : '' ?>">
<div class="premade-slot-inner"> <div class="premade-slot-inner">
<?php if ($isInvitable): ?> <?php if ($isInvitable): ?>
<form method="post" action="/premade_action.php" class="premade-invite-inline"> <button type="button" class="premade-slot-invite-btn" data-premade-id="<?= $premadeId ?>" title="Mitglied einladen">+</button>
<?= csrf_field() ?>
<input type="hidden" name="action" value="invite">
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
<select name="user_id" onchange="this.form.submit()">
<option value="">+ Mitglied einladen</option>
<?php foreach ($inviteCandidates as $candidate): ?>
<option value="<?= (int) $candidate['discord_id'] ?>">
<?= e($candidate['display_name'] !== '' ? $candidate['display_name'] : $candidate['discord_username']) ?>
</option>
<?php endforeach; ?>
</select>
</form>
<?php else: ?> <?php else: ?>
<span class="premade-slot-placeholder">+</span> <span class="premade-slot-placeholder">+</span>
<?php endif; ?> <?php endif; ?>
@ -232,17 +220,9 @@ include __DIR__ . '/includes/header.php';
<?php if ($slot['type'] === 'pending'): ?> <?php if ($slot['type'] === 'pending'): ?>
<span class="text-muted">Einladung offen</span> <span class="text-muted">Einladung offen</span>
<?php elseif ($isMe): ?> <?php elseif ($isMe): ?>
<form method="post" action="/premade_action.php"> <button type="button" class="premade-class-btn" data-premade-id="<?= $premadeId ?>" data-current-class="<?= e((string) ($slot['class'] ?? '')) ?>">
<?= csrf_field() ?> <?= empty($slot['class']) ? 'Klasse festlegen' : 'Klasse ändern' ?>
<input type="hidden" name="action" value="set_class"> </button>
<input type="hidden" name="premade_id" value="<?= $premadeId ?>">
<select name="class" class="premade-class-select" onchange="this.form.submit()">
<option value="">Klasse wählen…</option>
<?php foreach (AION_CLASSES as $classOption): ?>
<option value="<?= e($classOption) ?>" <?= $slot['class'] === $classOption ? 'selected' : '' ?>><?= e($classOption) ?></option>
<?php endforeach; ?>
</select>
</form>
<?php elseif (!empty($slot['class'])): ?> <?php elseif (!empty($slot['class'])): ?>
<span class="text-muted"><?= e($slot['class']) ?></span> <span class="text-muted"><?= e($slot['class']) ?></span>
<?php endif; ?> <?php endif; ?>
@ -300,6 +280,55 @@ include __DIR__ . '/includes/header.php';
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<!-- Gemeinsames Einladen-Popup fuer alle Premades auf dieser Seite -->
<div id="premade-invite-modal" class="modal-overlay" hidden>
<div class="modal">
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
<h2>Mitglied einladen</h2>
<p class="text-muted">Wähle ein Mitglied, das du per Discord-PN in diese Premade einladen möchtest.</p>
<div class="premade-invite-list">
<?php foreach ($inviteCandidates as $candidate): ?>
<?php $candidateName = $candidate['display_name'] !== '' ? $candidate['display_name'] : $candidate['discord_username']; ?>
<button type="button" class="premade-invite-option" data-user-id="<?= (int) $candidate['discord_id'] ?>">
<?= avatar_html(['id' => $candidate['id'], 'display_name' => $candidateName, 'username' => $candidateName, 'avatar_filename' => $candidate['avatar_filename'] ?? null], 32) ?>
<span><?= e($candidateName) ?></span>
</button>
<?php endforeach; ?>
</div>
</div>
</div>
<form id="premade-invite-form" method="post" action="/premade_action.php" style="display:none;">
<?= csrf_field() ?>
<input type="hidden" name="action" value="invite">
<input type="hidden" name="premade_id" id="premade-invite-premade-id">
<input type="hidden" name="user_id" id="premade-invite-user-id">
</form>
<!-- Gemeinsames Klassen-Popup - identisch zur Klassenauswahl bei der Raid-Anmeldung -->
<div id="premade-class-modal" class="modal-overlay" hidden>
<div class="modal">
<button type="button" class="modal-close icon-button" title="Schließen"><?= icon('x') ?></button>
<h2>Klasse wählen</h2>
<p class="text-muted">Welche Klasse spielst du in dieser Premade? Das ist optional und jederzeit änderbar.</p>
<div class="class-picker">
<?php foreach (AION_CLASSES as $classOption): ?>
<button type="button" class="class-picker-option" data-class="<?= e($classOption) ?>">
<span class="class-icon-frame"><img src="<?= e(class_icon_url($classOption)) ?>" alt=""></span>
<span class="class-picker-label"><?= e($classOption) ?></span>
</button>
<?php endforeach; ?>
</div>
</div>
</div>
<form id="premade-class-form" method="post" action="/premade_action.php" style="display:none;">
<?= csrf_field() ?>
<input type="hidden" name="action" value="set_class">
<input type="hidden" name="premade_id" id="premade-class-premade-id">
<input type="hidden" name="class" id="premade-class-value">
</form>
<script src="/assets/js/premades.js"></script>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>