feat(#22): Add settings page with language switcher
This commit is contained in:
@@ -231,6 +231,8 @@ legalconsenthub/
|
|||||||
│ │ ├── permissions.global.ts # Authorization check
|
│ │ ├── permissions.global.ts # Authorization check
|
||||||
│ │ └── refreshToken.global.ts # Token refresh logic
|
│ │ └── refreshToken.global.ts # Token refresh logic
|
||||||
│ ├── pages/ # Route pages
|
│ ├── pages/ # Route pages
|
||||||
|
│ │ ├── settings.vue # User settings page (language, theme, appearance)
|
||||||
|
│ │ ├── administration.vue # Admin template editor
|
||||||
│ │ ├── application-forms/
|
│ │ ├── application-forms/
|
||||||
│ │ ├── callback.vue # OAuth callback
|
│ │ ├── callback.vue # OAuth callback
|
||||||
│ │ ├── create.vue
|
│ │ ├── create.vue
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<UApp>
|
<UApp :locale="locales[locale]">
|
||||||
<NuxtLoadingIndicator />
|
<NuxtLoadingIndicator />
|
||||||
|
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
@@ -11,9 +11,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import * as locales from '@nuxt/ui/locale'
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
const colorMode = useColorMode()
|
const colorMode = useColorMode()
|
||||||
|
|
||||||
const color = computed(() => (colorMode.value === 'dark' ? '#111827' : 'white'))
|
const color = computed(() => (colorMode.value === 'dark' ? '#111827' : 'white'))
|
||||||
|
const lang = computed(() => locales[locale.value].code)
|
||||||
|
const dir = computed(() => locales[locale.value].dir)
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
meta: [
|
meta: [
|
||||||
@@ -23,7 +28,8 @@ useHead({
|
|||||||
],
|
],
|
||||||
link: [{ rel: 'icon', href: '/favicon.ico' }],
|
link: [{ rel: 'icon', href: '/favicon.ico' }],
|
||||||
htmlAttrs: {
|
htmlAttrs: {
|
||||||
lang: 'en'
|
lang,
|
||||||
|
dir
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<UModal :open="isOpen" :title="$t('applicationForms.deleteTitle')" @update:open="$emit('update:isOpen', $event)">
|
<UModal :open="isOpen" :title="$t('applicationForms.deleteTitle')" @update:open="$emit('update:isOpen', $event)">
|
||||||
<template #body>
|
<template #body>
|
||||||
<span v-html="$t('applicationForms.deleteConfirm', { name: applicationFormToDelete.name })"></span>
|
{{ $t('applicationForms.deleteConfirm', { name: applicationFormToDelete.name }) }}
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<UButton :label="$t('common.cancel')" color="neutral" variant="outline" @click="$emit('update:isOpen', false)" />
|
<UButton :label="$t('common.cancel')" color="neutral" variant="outline" @click="$emit('update:isOpen', false)" />
|
||||||
|
|||||||
@@ -14,18 +14,11 @@
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
block
|
block
|
||||||
:square="collapsed"
|
:square="collapsed"
|
||||||
class="data-[state=open]:bg-(--ui-bg-elevated)"
|
class="data-[state=open]:bg-elevated"
|
||||||
:ui="{
|
:ui="{
|
||||||
trailingIcon: 'text-(--ui-text-dimmed)'
|
trailingIcon: 'text-(--ui-text-dimmed)'
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template #chip-leading="{ item }">
|
|
||||||
<span
|
|
||||||
:style="{ '--chip': `var(--color-${(item as any).chip}-400)` }"
|
|
||||||
class="ms-0.5 size-2 rounded-full bg-(--chip)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</UDropdownMenu>
|
</UDropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -37,30 +30,6 @@ defineProps<{
|
|||||||
collapsed?: boolean
|
collapsed?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const colorMode = useColorMode()
|
|
||||||
const appConfig = useAppConfig()
|
|
||||||
|
|
||||||
const colors = [
|
|
||||||
'red',
|
|
||||||
'orange',
|
|
||||||
'amber',
|
|
||||||
'yellow',
|
|
||||||
'lime',
|
|
||||||
'green',
|
|
||||||
'emerald',
|
|
||||||
'teal',
|
|
||||||
'cyan',
|
|
||||||
'sky',
|
|
||||||
'blue',
|
|
||||||
'indigo',
|
|
||||||
'violet',
|
|
||||||
'purple',
|
|
||||||
'fuchsia',
|
|
||||||
'pink',
|
|
||||||
'rose'
|
|
||||||
]
|
|
||||||
const neutrals = ['slate', 'gray', 'zinc', 'neutral', 'stone']
|
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const { user: keyCloakUser } = storeToRefs(userStore)
|
const { user: keyCloakUser } = storeToRefs(userStore)
|
||||||
|
|
||||||
@@ -82,10 +51,6 @@ const items = computed<DropdownMenuItem[][]>(() => [
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
|
||||||
label: $t('user.profile'),
|
|
||||||
icon: 'i-lucide-user'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: $t('user.administration'),
|
label: $t('user.administration'),
|
||||||
icon: 'i-lucide-shield',
|
icon: 'i-lucide-shield',
|
||||||
@@ -97,84 +62,6 @@ const items = computed<DropdownMenuItem[][]>(() => [
|
|||||||
to: '/settings'
|
to: '/settings'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
|
||||||
{
|
|
||||||
label: $t('user.theme'),
|
|
||||||
icon: 'i-lucide-palette',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: $t('user.themePrimary'),
|
|
||||||
slot: 'chip',
|
|
||||||
chip: appConfig.ui.colors.primary,
|
|
||||||
content: {
|
|
||||||
align: 'center',
|
|
||||||
collisionPadding: 16
|
|
||||||
},
|
|
||||||
children: colors.map((color) => ({
|
|
||||||
label: color,
|
|
||||||
chip: color,
|
|
||||||
slot: 'chip',
|
|
||||||
checked: appConfig.ui.colors.primary === color,
|
|
||||||
type: 'checkbox',
|
|
||||||
onSelect: (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
appConfig.ui.colors.primary = color
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('user.themeNeutral'),
|
|
||||||
slot: 'chip',
|
|
||||||
chip: appConfig.ui.colors.neutral,
|
|
||||||
content: {
|
|
||||||
align: 'end',
|
|
||||||
collisionPadding: 16
|
|
||||||
},
|
|
||||||
children: neutrals.map((color) => ({
|
|
||||||
label: color,
|
|
||||||
chip: color,
|
|
||||||
slot: 'chip',
|
|
||||||
type: 'checkbox',
|
|
||||||
checked: appConfig.ui.colors.neutral === color,
|
|
||||||
onSelect: (e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
appConfig.ui.colors.neutral = color
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('user.appearance'),
|
|
||||||
icon: 'i-lucide-sun-moon',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
label: $t('user.light'),
|
|
||||||
icon: 'i-lucide-sun',
|
|
||||||
type: 'checkbox',
|
|
||||||
checked: colorMode.value === 'light',
|
|
||||||
onSelect(e: Event) {
|
|
||||||
e.preventDefault()
|
|
||||||
colorMode.preference = 'light'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: $t('user.dark'),
|
|
||||||
icon: 'i-lucide-moon',
|
|
||||||
type: 'checkbox',
|
|
||||||
checked: colorMode.value === 'dark',
|
|
||||||
onUpdateChecked(checked: boolean) {
|
|
||||||
if (checked) {
|
|
||||||
colorMode.preference = 'dark'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSelect(e: Event) {
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: $t('user.logout'),
|
label: $t('user.logout'),
|
||||||
|
|||||||
135
legalconsenthub/app/pages/settings.vue
Normal file
135
legalconsenthub/app/pages/settings.vue
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<template>
|
||||||
|
<UDashboardPanel id="settings">
|
||||||
|
<template #header>
|
||||||
|
<UDashboardNavbar :title="$t('settings.title')">
|
||||||
|
<template #leading>
|
||||||
|
<UDashboardSidebarCollapse />
|
||||||
|
</template>
|
||||||
|
</UDashboardNavbar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #body>
|
||||||
|
<div class="flex flex-col gap-6 w-full lg:max-w-4xl mx-auto p-6">
|
||||||
|
<!-- Language Section -->
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-semibold text-highlighted">{{ $t('settings.language.title') }}</h3>
|
||||||
|
<p class="text-sm text-muted mt-1">{{ $t('settings.language.description') }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<ULocaleSelect
|
||||||
|
:model-value="locale"
|
||||||
|
:locales="[de, en]"
|
||||||
|
class="w-full max-w-xs"
|
||||||
|
size="md"
|
||||||
|
@update:model-value="handleLocaleChange"
|
||||||
|
/>
|
||||||
|
</UCard>
|
||||||
|
|
||||||
|
<!-- Appearance Section -->
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-semibold text-highlighted">{{ $t('settings.appearance.title') }}</h3>
|
||||||
|
<p class="text-sm text-muted mt-1">{{ $t('settings.appearance.description') }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<URadioGroup v-model="selectedColorMode" :items="colorModeOptions" class="gap-4" />
|
||||||
|
</UCard>
|
||||||
|
|
||||||
|
<!-- Theme Colors Section -->
|
||||||
|
<UCard>
|
||||||
|
<template #header>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-lg font-semibold text-highlighted">{{ $t('settings.theme.title') }}</h3>
|
||||||
|
<p class="text-sm text-muted mt-1">{{ $t('settings.theme.description') }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="space-y-6">
|
||||||
|
<!-- Primary Color -->
|
||||||
|
<div>
|
||||||
|
<h4 class="text-sm font-medium text-highlighted mb-3">{{ $t('settings.theme.primary') }}</h4>
|
||||||
|
<div class="grid grid-cols-10 gap-2">
|
||||||
|
<button
|
||||||
|
v-for="color in colors"
|
||||||
|
:key="color"
|
||||||
|
type="button"
|
||||||
|
:class="[
|
||||||
|
'w-10 h-10 rounded-md transition-all',
|
||||||
|
appConfig.ui.colors.primary === color
|
||||||
|
? 'ring-2 ring-offset-2 ring-offset-background'
|
||||||
|
: 'hover:scale-110'
|
||||||
|
]"
|
||||||
|
:style="{
|
||||||
|
backgroundColor: `var(--color-${color}-500)`,
|
||||||
|
'--tw-ring-color': `var(--color-${color}-500)`
|
||||||
|
}"
|
||||||
|
@click="appConfig.ui.colors.primary = color"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</UCard>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</UDashboardPanel>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { de, en } from '@nuxt/ui/locale'
|
||||||
|
|
||||||
|
definePageMeta({
|
||||||
|
layout: 'default'
|
||||||
|
})
|
||||||
|
|
||||||
|
const { t: $t, locale, setLocale } = useI18n()
|
||||||
|
const colorMode = useColorMode()
|
||||||
|
const appConfig = useAppConfig()
|
||||||
|
|
||||||
|
const colors = [
|
||||||
|
'red',
|
||||||
|
'orange',
|
||||||
|
'amber',
|
||||||
|
'yellow',
|
||||||
|
'lime',
|
||||||
|
'green',
|
||||||
|
'emerald',
|
||||||
|
'teal',
|
||||||
|
'cyan',
|
||||||
|
'sky',
|
||||||
|
'blue',
|
||||||
|
'indigo',
|
||||||
|
'violet',
|
||||||
|
'purple',
|
||||||
|
'fuchsia',
|
||||||
|
'pink'
|
||||||
|
]
|
||||||
|
|
||||||
|
function handleLocaleChange(newLocale: string | undefined) {
|
||||||
|
if (newLocale) {
|
||||||
|
setLocale(newLocale as 'de' | 'en')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const colorModeOptions = computed(() => [
|
||||||
|
{
|
||||||
|
value: 'light',
|
||||||
|
label: $t('settings.appearance.light'),
|
||||||
|
icon: 'i-lucide-sun'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'dark',
|
||||||
|
label: $t('settings.appearance.dark'),
|
||||||
|
icon: 'i-lucide-moon'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const selectedColorMode = computed({
|
||||||
|
get: () => colorMode.value,
|
||||||
|
set: (value) => {
|
||||||
|
colorMode.preference = value as 'light' | 'dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
"noPermission": "Keine Berechtigung",
|
"noPermission": "Keine Berechtigung",
|
||||||
"noPermissionDescription": "Sie haben keine Berechtigung zum Erstellen von Anträgen.",
|
"noPermissionDescription": "Sie haben keine Berechtigung zum Erstellen von Anträgen.",
|
||||||
"backToOverview": "Zurück zur Übersicht",
|
"backToOverview": "Zurück zur Übersicht",
|
||||||
"deleteConfirm": "Möchten Sie wirklich den Mitbestimmungsantrag <strong>{name}</strong> löschen?",
|
"deleteConfirm": "Möchten Sie wirklich den Mitbestimmungsantrag \"{name}\" löschen?",
|
||||||
"deleteTitle": "Mitbestimmungsantrag löschen",
|
"deleteTitle": "Mitbestimmungsantrag löschen",
|
||||||
"lastEditedBy": "Zuletzt bearbeitet von",
|
"lastEditedBy": "Zuletzt bearbeitet von",
|
||||||
"createdBy": "Erstellt von",
|
"createdBy": "Erstellt von",
|
||||||
@@ -102,16 +102,28 @@
|
|||||||
"accessDenied": "Zugriff verweigert"
|
"accessDenied": "Zugriff verweigert"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"profile": "Profil",
|
|
||||||
"administration": "Administration",
|
"administration": "Administration",
|
||||||
"settings": "Einstellungen",
|
"settings": "Einstellungen",
|
||||||
"logout": "Abmelden",
|
"logout": "Abmelden"
|
||||||
"theme": "Design",
|
},
|
||||||
"themePrimary": "Primärfarbe",
|
"settings": {
|
||||||
"themeNeutral": "Neutralfarbe",
|
"title": "Einstellungen",
|
||||||
"appearance": "Erscheinungsbild",
|
"language": {
|
||||||
"light": "Hell",
|
"title": "Sprache",
|
||||||
"dark": "Dunkel"
|
"description": "Wählen Sie Ihre bevorzugte Sprache"
|
||||||
|
},
|
||||||
|
"appearance": {
|
||||||
|
"title": "Erscheinungsbild",
|
||||||
|
"description": "Wählen Sie zwischen hellem und dunklem Modus",
|
||||||
|
"light": "Hell",
|
||||||
|
"dark": "Dunkel"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"title": "Farbschema",
|
||||||
|
"description": "Passen Sie die Farben der Anwendung an",
|
||||||
|
"primary": "Primärfarbe",
|
||||||
|
"neutral": "Neutralfarbe"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"organization": {
|
"organization": {
|
||||||
"current": "Aktuelle Organisation"
|
"current": "Aktuelle Organisation"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"noPermission": "No Permission",
|
"noPermission": "No Permission",
|
||||||
"noPermissionDescription": "You do not have permission to create applications.",
|
"noPermissionDescription": "You do not have permission to create applications.",
|
||||||
"backToOverview": "Back to Overview",
|
"backToOverview": "Back to Overview",
|
||||||
"deleteConfirm": "Do you really want to delete the co-determination application <strong>{name}</strong>?",
|
"deleteConfirm": "Do you really want to delete the co-determination application \"{name}\"?",
|
||||||
"deleteTitle": "Delete Co-determination Application",
|
"deleteTitle": "Delete Co-determination Application",
|
||||||
"lastEditedBy": "Last edited by",
|
"lastEditedBy": "Last edited by",
|
||||||
"createdBy": "Created by",
|
"createdBy": "Created by",
|
||||||
@@ -102,16 +102,28 @@
|
|||||||
"accessDenied": "Access denied"
|
"accessDenied": "Access denied"
|
||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"profile": "Profile",
|
|
||||||
"administration": "Administration",
|
"administration": "Administration",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"logout": "Log out",
|
"logout": "Log out"
|
||||||
"theme": "Theme",
|
},
|
||||||
"themePrimary": "Primary Color",
|
"settings": {
|
||||||
"themeNeutral": "Neutral Color",
|
"title": "Settings",
|
||||||
"appearance": "Appearance",
|
"language": {
|
||||||
"light": "Light",
|
"title": "Language",
|
||||||
"dark": "Dark"
|
"description": "Choose your preferred language"
|
||||||
|
},
|
||||||
|
"appearance": {
|
||||||
|
"title": "Appearance",
|
||||||
|
"description": "Choose between light and dark mode",
|
||||||
|
"light": "Light",
|
||||||
|
"dark": "Dark"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"title": "Color Theme",
|
||||||
|
"description": "Customize the application colors",
|
||||||
|
"primary": "Primary Color",
|
||||||
|
"neutral": "Neutral Color"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"organization": {
|
"organization": {
|
||||||
"current": "Current Organization"
|
"current": "Current Organization"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default defineNuxtConfig({
|
|||||||
],
|
],
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: 'de',
|
defaultLocale: 'de',
|
||||||
|
strategy: 'no_prefix',
|
||||||
locales: [
|
locales: [
|
||||||
{ code: 'en', name: 'English', file: 'en.json' },
|
{ code: 'en', name: 'English', file: 'en.json' },
|
||||||
{ code: 'de', name: 'Deutsch', file: 'de.json' }
|
{ code: 'de', name: 'Deutsch', file: 'de.json' }
|
||||||
|
|||||||
Reference in New Issue
Block a user