frontend admin refakctorálás

This commit is contained in:
Roo
2026-07-08 08:03:57 +00:00
parent 07b59032ce
commit 2e0abc62a7
455 changed files with 14428 additions and 21651 deletions

View File

@@ -20,7 +20,7 @@
@change="$emit('toggle', node.id)"
class="w-4 h-4 rounded border-slate-500 bg-slate-700 text-indigo-500 focus:ring-indigo-500/50"
/>
<span class="text-sm text-slate-300">{{ node.name_hu || node.name_en || node.key }}</span>
<span class="text-sm text-slate-300">{{ resolveNodeLabel(node) }}</span>
<span class="text-xs text-slate-500">(Szint {{ node.level }})</span>
</label>
</div>
@@ -42,19 +42,27 @@
/**
* Recursive TreeNode component for the category tree.
* Renders a checkbox tree with expand/collapse for nested categories.
*
* i18n Resolution (Phase 4):
* Uses name_i18n JSONB dictionary with fallback chain:
* 1. Active language in name_i18n dict
* 2. Hungarian (hu) in name_i18n dict
* 3. Deprecated name_hu field
* 4. Fallback to node.key
*/
interface CategoryTreeNode {
id: number
key: string
name_hu?: string | null
name_en?: string | null
name_i18n?: Record<string, string> | null
level: number
path?: string | null
is_official: boolean
children: CategoryTreeNode[]
}
defineProps<{
const props = defineProps<{
node: CategoryTreeNode
selectedIds: number[]
expandedIds: Set<number>
@@ -64,4 +72,42 @@ defineEmits<{
toggle: [id: number]
'toggle-expand': [id: number]
}>()
// ── i18n locale (dynamic) ─────────────────────────────
let currentLocale = 'hu'
try {
const i18n = useI18n()
currentLocale = i18n.locale?.value || i18n.locale || 'hu'
} catch {
// useI18n() may throw outside of setup context; fallback to 'hu'
}
/**
* Resolve a tree node's display label using i18n JSONB dictionary.
*
* Fallback chain:
* 1. Active language in name_i18n dict
* 2. Hungarian (hu) in name_i18n dict
* 3. Deprecated name_hu field
* 4. Fallback to node.key
*/
function resolveNodeLabel(node: CategoryTreeNode): string {
// 1. Try active language in i18n dict
if (node.name_i18n?.[currentLocale]) {
return node.name_i18n[currentLocale]
}
// 2. Fallback to Hungarian in i18n dict
if (node.name_i18n?.hu) {
return node.name_i18n.hu
}
// 3. Fallback to deprecated name_hu (safe transition)
if (node.name_hu) {
return node.name_hu
}
// 4. Fallback to key
return node.key
}
</script>