fix: add missing readBooks translations
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled
This commit is contained in:
64
scripts/fix-book-reviews-ui.js
Normal file
64
scripts/fix-book-reviews-ui.js
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/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);
|
||||
Reference in New Issue
Block a user