feat(dashboard): enhance widget availability and initialization
All checks were successful
Deploy to production / deploy (push) Successful in 3m2s
All checks were successful
Deploy to production / deploy (push) Successful in 3m2s
- Updated `getAvailableWidgets` method in `DashboardService` to merge default widget types with database entries, ensuring immediate visibility of new widgets post-deployment. - Introduced `DASHBOARD_WIDGET_TYPE_DEFAULTS` in `initializeWidgetTypes` for canonical widget types, facilitating API merging when database entries are absent. - Modified `StatusBar.vue` to utilize a computed property for quick access children, improving menu item handling and visibility based on user context. - Enhanced `LoggedInView.vue` to dynamically return localized widget labels, improving user experience with accurate translations.
This commit is contained in:
@@ -38,11 +38,11 @@
|
||||
class="statusbar-section statusbar-section--nav"
|
||||
>
|
||||
<div class="quick-access">
|
||||
<template v-for="(menuItem, key) in menu.falukant.children" :key="menuItem.id" >
|
||||
<template v-for="[key, menuItem] in falukantQuickAccessChildren" :key="menuItem.id || key" >
|
||||
<img
|
||||
:src="'/images/icons/falukant/shortmap/' + key + '.png'"
|
||||
class="menu-icon"
|
||||
@click="openPage(menuItem)"
|
||||
@click="openPage(menuItem.path)"
|
||||
:title="$t(`navigation.m-falukant.${key}`)"
|
||||
/>
|
||||
</template>
|
||||
@@ -96,6 +96,16 @@ export default {
|
||||
computed: {
|
||||
...mapState(["socket", "daemonSocket", "user"]),
|
||||
...mapGetters(['menu']),
|
||||
/** Menü kann hinter /info zurückbleiben: „Erstellen“ ausblenden, sobald ein Account erkennbar ist. */
|
||||
falukantQuickAccessChildren() {
|
||||
const ch = this.menu?.falukant?.children;
|
||||
if (!ch || typeof ch !== 'object') return [];
|
||||
const keys = Object.keys(ch);
|
||||
const hasOtherThanCreate = keys.some((k) => k !== 'create');
|
||||
const hasCharacterName = Boolean((this.characterName || '').trim());
|
||||
const hideCreate = hasOtherThanCreate || hasCharacterName;
|
||||
return Object.entries(ch).filter(([key]) => !(key === 'create' && hideCreate));
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// Wenn sich das Menü ändert, lade die Bilder neu
|
||||
@@ -140,12 +150,10 @@ export default {
|
||||
methods: {
|
||||
preloadQuickAccessImages() {
|
||||
// Lade alle Schnellzugriffs-Bilder vor, damit sie gecacht werden
|
||||
if (this.menu.falukant && this.menu.falukant.children) {
|
||||
Object.keys(this.menu.falukant.children).forEach(key => {
|
||||
const img = new Image();
|
||||
img.src = `/images/icons/falukant/shortmap/${key}.png`;
|
||||
});
|
||||
}
|
||||
this.falukantQuickAccessChildren.forEach(([key]) => {
|
||||
const img = new Image();
|
||||
img.src = `/images/icons/falukant/shortmap/${key}.png`;
|
||||
});
|
||||
|
||||
// Lade auch andere häufig verwendete Bilder vor
|
||||
const commonImages = [
|
||||
|
||||
@@ -186,15 +186,18 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getLocalizedWidgetLabel(endpoint, fallbackLabel = '') {
|
||||
const ep = String(endpoint || '');
|
||||
if (ep.startsWith('/api/news')) {
|
||||
return this.$t('home.dashboard.widgetLabels.news');
|
||||
}
|
||||
const key = {
|
||||
'/api/termine': 'home.dashboard.widgetLabels.appointments',
|
||||
'/api/falukant/dashboard-widget': 'home.dashboard.widgetLabels.falukant',
|
||||
'/api/news': 'home.dashboard.widgetLabels.news',
|
||||
'/api/calendar/widget/birthdays': 'home.dashboard.widgetLabels.birthdays',
|
||||
'/api/calendar/widget/upcoming': 'home.dashboard.widgetLabels.upcoming',
|
||||
'/api/calendar/widget/mini': 'home.dashboard.widgetLabels.calendar',
|
||||
'/api/vocab/dashboard-widget': 'home.dashboard.widgetLabels.vocabCourses'
|
||||
}[endpoint];
|
||||
}[ep];
|
||||
return key ? this.$t(key) : fallbackLabel;
|
||||
},
|
||||
normalizeWidgetType(widgetType) {
|
||||
|
||||
Reference in New Issue
Block a user