Forum: Anpinnen pro Thema/global + Admin-Berechtigung (v1303)
- Anpinnen-Scope: pin_scope ('global' | 'kategorie'). Global haelt oben in
jeder Ansicht; Themen-Pin nur in der gefilterten Kategorie (nicht in 'Alle').
- Bugfix Berechtigung: Forum pruefte nur is_moderator -> Admins ohne das Flag
wurden ausgesperrt. Neuer Helper _can_moderate() = rolle in (admin,moderator)
ODER is_moderator, an allen 7 Forum-Checks + beiden Frontend-isMod-Gates.
- Thread-Detail-Toolbar (nur Admin/Mod): 'Global anpinnen' / 'Im Thema anpinnen'
/ 'Loesen' + Status- und Badge-Anzeige nach Scope.
- DB-Migration forum_threads.pin_scope (idempotent, Default 'global').
- Tests: tests/test_forum_pinning.py (Berechtigung + Scope-Sortierung).
This commit is contained in:
parent
901df5468c
commit
ac0814e687
9 changed files with 175 additions and 36 deletions
|
|
@ -86,14 +86,14 @@
|
|||
<title>Ban Yaro</title>
|
||||
|
||||
<!-- Theme + theme-color Statusleiste vor CSS setzen -->
|
||||
<script src="/js/boot-early.js?v=1302"></script>
|
||||
<script src="/js/boot-early.js?v=1303"></script>
|
||||
|
||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1302">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1302">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1302">
|
||||
<link rel="stylesheet" href="/css/utilities.css?v=1302">
|
||||
<link rel="stylesheet" href="/css/lists.css?v=1302">
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1303">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1303">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1303">
|
||||
<link rel="stylesheet" href="/css/utilities.css?v=1303">
|
||||
<link rel="stylesheet" href="/css/lists.css?v=1303">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -624,12 +624,12 @@
|
|||
<div id="modal-container"></div>
|
||||
|
||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||
<script src="/js/api.js?v=1302"></script>
|
||||
<script src="/js/ui.js?v=1302"></script>
|
||||
<script src="/js/app.js?v=1302"></script>
|
||||
<script src="/js/worlds.js?v=1302"></script>
|
||||
<script src="/js/offline-indicator.js?v=1302"></script>
|
||||
<script src="/js/contact-form.js?v=1302"></script>
|
||||
<script src="/js/api.js?v=1303"></script>
|
||||
<script src="/js/ui.js?v=1303"></script>
|
||||
<script src="/js/app.js?v=1303"></script>
|
||||
<script src="/js/worlds.js?v=1303"></script>
|
||||
<script src="/js/offline-indicator.js?v=1303"></script>
|
||||
<script src="/js/contact-form.js?v=1303"></script>
|
||||
|
||||
<!-- Feature-Seiten werden lazy geladen -->
|
||||
|
||||
|
|
@ -639,7 +639,7 @@
|
|||
|
||||
|
||||
<!-- Boot: Offline-Banner + SW-Registration (extrahiert für CSP) -->
|
||||
<script src="/js/boot.js?v=1302"></script>
|
||||
<script src="/js/boot.js?v=1303"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '1302'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '1303'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
|
||||
window.APP_VERSION = APP_VERSION;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ function _fmtDate(iso) {
|
|||
// RENDER — Grundstruktur
|
||||
// ----------------------------------------------------------
|
||||
function _render() {
|
||||
const isMod = !!_appState.user?.is_moderator;
|
||||
const _u = _appState.user;
|
||||
const isMod = !!(_u && (_u.rolle === 'admin' || _u.rolle === 'moderator' || _u.is_moderator));
|
||||
|
||||
_container.innerHTML = `
|
||||
<div class="forum-layout">
|
||||
|
|
@ -438,7 +439,7 @@ function _fmtDate(iso) {
|
|||
const preview = t.text_preview
|
||||
? UI.escape(t.text_preview.slice(0, 120)) + (t.text_preview.length >= 120 ? '…' : '')
|
||||
: '';
|
||||
const pinBadge = t.is_pinned ? `<span class="forum-pin-badge" title="Angepinnt">${UI.icon('push-pin')}</span>` : '';
|
||||
const pinBadge = t.is_pinned ? `<span class="forum-pin-badge" title="${t.pin_scope === 'kategorie' ? 'Im Thema angepinnt' : 'Angepinnt'}">${UI.icon('push-pin')}</span>` : '';
|
||||
const lockBadge = t.is_locked ? `<span class="forum-lock-badge" title="Gesperrt">${UI.icon('lock')}</span>` : '';
|
||||
const fotoHtml = t.foto_preview
|
||||
? /\.(mp4|mov|webm|m4v|avi)$/i.test(t.foto_preview)
|
||||
|
|
@ -515,14 +516,25 @@ function _fmtDate(iso) {
|
|||
}
|
||||
|
||||
const uid = _appState.user?.id;
|
||||
const isMod = !!_appState.user?.is_moderator;
|
||||
const _u = _appState.user;
|
||||
const isMod = !!(_u && (_u.rolle === 'admin' || _u.rolle === 'moderator' || _u.is_moderator));
|
||||
const isOwn = uid && uid === thread.user_id;
|
||||
|
||||
const pinControls = thread.is_pinned
|
||||
? `<span class="forum-pin-state" style="display:inline-flex;align-items:center;gap:4px;font-size:var(--text-sm);color:var(--c-text-secondary)">
|
||||
${UI.icon('push-pin')} Angepinnt${thread.pin_scope === 'kategorie' ? ` (Thema „${UI.escape(thread.kategorie)}")` : ' (global)'}
|
||||
</span>
|
||||
<button class="btn btn-ghost btn-sm forum-mod-unpin" title="Anpinnen aufheben">Lösen</button>`
|
||||
: `<button class="btn btn-ghost btn-sm forum-mod-pin-global" title="Überall ganz oben halten">
|
||||
${UI.icon('push-pin')} Global anpinnen
|
||||
</button>
|
||||
<button class="btn btn-ghost btn-sm forum-mod-pin-cat" title="Nur im Thema „${UI.escape(thread.kategorie)}" oben halten">
|
||||
${UI.icon('push-pin')} Im Thema anpinnen
|
||||
</button>`;
|
||||
|
||||
const modToolbar = (isMod) ? `
|
||||
<div class="forum-mod-toolbar">
|
||||
<button class="btn btn-ghost btn-sm forum-mod-pin" title="${thread.is_pinned ? 'Unpin' : 'Anpinnen'}">
|
||||
${UI.icon('push-pin')} ${thread.is_pinned ? 'Unpin' : 'Pin'}
|
||||
</button>
|
||||
${pinControls}
|
||||
<button class="btn btn-ghost btn-sm forum-mod-lock" title="${thread.is_locked ? 'Entsperren' : 'Sperren'}">
|
||||
${UI.icon('lock')} ${thread.is_locked ? 'Entsperren' : 'Sperren'}
|
||||
</button>
|
||||
|
|
@ -677,14 +689,20 @@ function _fmtDate(iso) {
|
|||
});
|
||||
|
||||
// Moderator: pin/lock/delete
|
||||
document.querySelector('.forum-mod-pin')?.addEventListener('click', async () => {
|
||||
const _applyPin = async (payload) => {
|
||||
try {
|
||||
await API.forum.patchThread(thread.id, { is_pinned: thread.is_pinned ? 0 : 1 });
|
||||
await API.forum.patchThread(thread.id, payload);
|
||||
UI.toast.success('Gespeichert.');
|
||||
UI.modal.close();
|
||||
_loadThreads(true);
|
||||
} catch (err) { UI.toast.error(err.message); }
|
||||
});
|
||||
};
|
||||
document.querySelector('.forum-mod-pin-global')?.addEventListener('click',
|
||||
() => _applyPin({ is_pinned: 1, pin_scope: 'global' }));
|
||||
document.querySelector('.forum-mod-pin-cat')?.addEventListener('click',
|
||||
() => _applyPin({ is_pinned: 1, pin_scope: 'kategorie' }));
|
||||
document.querySelector('.forum-mod-unpin')?.addEventListener('click',
|
||||
() => _applyPin({ is_pinned: 0 }));
|
||||
|
||||
document.querySelector('.forum-mod-lock')?.addEventListener('click', async () => {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<script src="/js/landing-init.js?v=1302"></script>
|
||||
<script src="/js/landing-init.js?v=1303"></script>
|
||||
<title>Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz</title>
|
||||
<meta name="description" content="Ban Yaro: Die kostenlose All-in-One Hunde-App für DACH. Tagebuch, Giftköder-Alarm, Training mit KI, Forum, Wurfbörse, Stammbaum, Inzucht-Check — DSGVO-konform, offline-fähig, direkt im Browser oder als native iPhone-App (Ban Yaro Go).">
|
||||
<meta name="keywords" content="Hunde App, Hunde Community, Wurfbörse, Züchter, Welpen kaufen, Stammbaum Hund, Inzuchtkoeffizient, Hundezucht, Impfpass Hund, Giftköder Alarm, Gassi Community, Hundetraining App, Hunde Forum, Hunde KI, Hundefilm Datenbank, Welpen Marktplatz">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
============================================================ */
|
||||
|
||||
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
||||
const VER = '1302';
|
||||
const VER = '1303';
|
||||
const CACHE_VERSION = `by-v${VER}`;
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue