mirror of
https://codeberg.org/kirche-im-netz/Startodon-Hub.git
synced 2025-08-30 22:59:33 +02:00
Starterkit-userConsent-Check wieder implementiert
This commit is contained in:
parent
df6e9483e6
commit
0a0e6b8538
2 changed files with 32 additions and 10 deletions
|
@ -13,9 +13,11 @@ export function getUserConsent() {
|
||||||
|
|
||||||
// Überprüft, ob bereits eine Zustimmung vorliegt
|
// Überprüft, ob bereits eine Zustimmung vorliegt
|
||||||
export function checkConsent() {
|
export function checkConsent() {
|
||||||
return getUserConsent() !== null;
|
const consent = getUserConsent();
|
||||||
|
return consent === true; // Liefert true nur, wenn explizit zugestimmt wurde
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Zeigt das Consent-Banner an
|
// Zeigt das Consent-Banner an
|
||||||
export function showConsentPopup(onAccept, onDecline) {
|
export function showConsentPopup(onAccept, onDecline) {
|
||||||
const title = 'Datenschutzeinstellungen';
|
const title = 'Datenschutzeinstellungen';
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { createRecommendationPopup, populateAuthorsContainer } from './recommendations-utils.js';
|
import { createRecommendationPopup, populateAuthorsContainer } from './recommendations-utils.js';
|
||||||
|
import { checkConsent, showConsentPopup, setUserConsent } from '../components/consentManager.js';
|
||||||
|
|
||||||
|
// StarterKit-Element erstellen
|
||||||
export function createStarterKitElement(kit) {
|
export function createStarterKitElement(kit) {
|
||||||
const template = document.getElementById('starterkit-template').content.cloneNode(true);
|
const template = document.getElementById('starterkit-template').content.cloneNode(true);
|
||||||
|
|
||||||
|
@ -8,39 +10,57 @@ export function createStarterKitElement(kit) {
|
||||||
kitElement.querySelector('h3').textContent = kit.name;
|
kitElement.querySelector('h3').textContent = kit.name;
|
||||||
kitElement.querySelector('p').textContent = kit.description;
|
kitElement.querySelector('p').textContent = kit.description;
|
||||||
|
|
||||||
// Aufteilen der Profilanzahl in zwei Zeilen
|
// Profilanzahl
|
||||||
const profileCount = kitElement.querySelector('.profile-count');
|
const profileCount = kitElement.querySelector('.profile-count');
|
||||||
profileCount.querySelector('.profile-line2').textContent = `${kit.accounts.length}`;
|
profileCount.querySelector('.profile-line2').textContent = `${kit.accounts.length}`;
|
||||||
|
|
||||||
// Hinzufügen der Autoren mit 'created by' über die neue Funktion
|
// Autoren hinzufügen
|
||||||
const authorsContainer = kitElement.querySelector('.authors-container');
|
const authorsContainer = kitElement.querySelector('.authors-container');
|
||||||
if (!authorsContainer) {
|
if (!authorsContainer) {
|
||||||
console.error('Fehlendes Element: .authors-container im Template. Bitte prüfen!');
|
console.error('Fehlendes Element: .authors-container im Template. Bitte prüfen!');
|
||||||
return kitElement; // Gibt das unvollständige Element zurück
|
return kitElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
populateAuthorsContainer(authorsContainer, kit.authors); // Nutzt die ausgelagerte Funktion
|
populateAuthorsContainer(authorsContainer, kit.authors);
|
||||||
|
|
||||||
kitElement.dataset.accounts = JSON.stringify(kit.accounts);
|
kitElement.dataset.accounts = JSON.stringify(kit.accounts);
|
||||||
|
|
||||||
return kitElement;
|
return kitElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StarterKits mit Event-Listenern versehen
|
||||||
export function enhanceStarterKits() {
|
export function enhanceStarterKits() {
|
||||||
const starterkits = document.querySelectorAll('.starterkit');
|
const starterkits = document.querySelectorAll('.starterkit');
|
||||||
|
|
||||||
starterkits.forEach(kit => {
|
starterkits.forEach(kit => {
|
||||||
kit.addEventListener('click', function () {
|
kit.addEventListener('click', function () {
|
||||||
// Direkt die Profile laden, ohne Consent-Überprüfung
|
handleStarterKitClick(kit);
|
||||||
loadStarterKitProfiles(kit);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Funktion zum Laden der StarterKit-Profile
|
// StarterKit-Klick behandeln
|
||||||
|
function handleStarterKitClick(kit) {
|
||||||
|
if (checkConsent()) {
|
||||||
|
// Zustimmung vorhanden – StarterKit-Popup öffnen
|
||||||
|
loadStarterKitProfiles(kit);
|
||||||
|
} else {
|
||||||
|
// Keine Zustimmung – Consent-Popup anzeigen
|
||||||
|
showConsentPopup(
|
||||||
|
() => {
|
||||||
|
setUserConsent(true); // Zustimmung speichern
|
||||||
|
loadStarterKitProfiles(kit); // Nachträglich StarterKit-Popup öffnen
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
console.log('Consent wurde abgelehnt. StarterKit-Popup wird nicht geöffnet.');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StarterKit-Profile laden
|
||||||
function loadStarterKitProfiles(kit) {
|
function loadStarterKitProfiles(kit) {
|
||||||
const title = kit.querySelector('h3').textContent;
|
const title = kit.querySelector('h3').textContent;
|
||||||
const description = kit.querySelector('p').textContent; // Beschreibung auslesen
|
const description = kit.querySelector('p').textContent;
|
||||||
const accounts = JSON.parse(kit.dataset.accounts || '[]');
|
const accounts = JSON.parse(kit.dataset.accounts || '[]');
|
||||||
const authors = Array.from(kit.querySelectorAll('.authors-container .account')).map(author => author.href);
|
const authors = Array.from(kit.querySelectorAll('.authors-container .account')).map(author => author.href);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue