#!/usr/bin/env node require('dotenv').config(); const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev'; const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN; async function api(endpoint, method = 'GET', body = null) { const url = `${DIRECTUS_URL}/${endpoint}`; const options = { method, headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' } }; if (body) options.body = JSON.stringify(body); const response = await fetch(url, options); return response.ok ? await response.json() : { error: true }; } async function fixUI() { console.log('🔧 Repariere Directus UI für Book Reviews...'); // 1. Status Feld verschönern await api('fields/book_reviews/status', 'PATCH', { meta: { interface: 'select-dropdown', display: 'labels', display_options: { showAsDot: true, choices: [ { value: 'published', foreground: '#FFFFFF', background: '#00C897' }, { value: 'draft', foreground: '#FFFFFF', background: '#666666' } ] }, options: { choices: [ { text: 'Veröffentlicht', value: 'published' }, { text: 'Entwurf', value: 'draft' } ] } } }); // 2. Sprachen-Verknüpfung reparieren (WICHTIG für Tabs) await api('relations', 'POST', { collection: 'book_reviews_translations', field: 'languages_code', related_collection: 'languages', meta: { interface: 'select-dropdown' } }).catch(() => console.log('Relation existiert evtl. schon...')); // 3. Übersetzungs-Interface aktivieren await api('fields/book_reviews/translations', 'PATCH', { meta: { interface: 'translations', display: 'translations', options: { languageField: 'languages_code', userLanguage: true } } }); console.log('✅ UI-Fix angewendet! Bitte lade Directus neu.'); } fixUI().catch(console.error);