@quazardous/qdadm 2.55.0 → 2.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styles/qdadm.css +1 -1
- package/package.json +1 -1
- package/src/cards/QdFavoritesCard.vue +4 -1
- package/src/cards/builtin/cards-index.json +1 -1
- package/src/cards/builtin/favorites/meta.json +1 -1
- package/src/components/index.ts +7 -0
- package/src/components/layout/AppLayout.vue +38 -117
- package/src/components/layout/QdFavoriteStar.vue +15 -4
- package/src/components/layout/QdSidebarMenus.vue +123 -0
- package/src/components/layout/QdTabs.types.ts +12 -0
- package/src/components/layout/QdTabs.vue +129 -0
- package/src/components/layout/defaults/DefaultMenu.vue +42 -132
- package/src/components/lists/ListPage.vue +10 -1
- package/src/components/lists/QdSaveSearch.vue +38 -5
- package/src/composables/index.ts +1 -0
- package/src/composables/useNavigation.ts +43 -3
- package/src/composables/useSettingsMenu.ts +80 -0
- package/src/domain/QdDomainBar.vue +16 -6
- package/src/domain/registry.ts +5 -4
- package/src/favorites/index.ts +1 -0
- package/src/favorites/look.ts +30 -0
- package/src/i18n/defaults/core.en.generated.ts +5 -0
- package/src/i18n/defaults/core.en.yml +5 -0
- package/src/i18n/defaults/core.fr.generated.ts +5 -0
- package/src/i18n/defaults/core.fr.yml +5 -0
- package/src/index.ts +1 -0
- package/src/kernel/Kernel.types.ts +17 -1
- package/src/kernel/KernelContext.routing.ts +1 -0
- package/src/kernel/KernelContext.types.ts +2 -0
- package/src/module/moduleRegistry.ts +2 -0
- package/src/styles/_qd-domain-bar.scss +77 -48
- package/src/styles/_sidebar.scss +109 -0
|
@@ -14,6 +14,7 @@ import QdCardView from './QdCardView.vue'
|
|
|
14
14
|
import { useI18n } from '../i18n/useI18n'
|
|
15
15
|
import { useFavorites } from '../favorites/useFavorites'
|
|
16
16
|
import type { Favorite } from '../favorites/store'
|
|
17
|
+
import { useFavoritesLook } from '../favorites/look'
|
|
17
18
|
import type { CardSize } from './types'
|
|
18
19
|
|
|
19
20
|
const props = withDefaults(
|
|
@@ -29,6 +30,8 @@ const props = withDefaults(
|
|
|
29
30
|
)
|
|
30
31
|
const { tOr } = useI18n()
|
|
31
32
|
const favorites = useFavorites()
|
|
33
|
+
// Its header shows the app's favourite symbol (#5402), unless told otherwise
|
|
34
|
+
const look = useFavoritesLook()
|
|
32
35
|
// Read again when it shows: another tab or a page may have changed them
|
|
33
36
|
onMounted(() => void favorites.reload())
|
|
34
37
|
|
|
@@ -72,7 +75,7 @@ onBeforeUnmount(() => removed.value.forEach((r) => clearTimeout(r.timer)))
|
|
|
72
75
|
|
|
73
76
|
const envelope = computed(() => ({
|
|
74
77
|
title: props.title ?? tOr('core.favorites.title', 'Favourites'),
|
|
75
|
-
|
|
78
|
+
icon: props.icon !== undefined ? props.icon : look.icon,
|
|
76
79
|
size: props.size,
|
|
77
80
|
state: !favorites.available
|
|
78
81
|
? ('empty' as const)
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
"type": "favorites",
|
|
338
338
|
"title": "Favourites",
|
|
339
339
|
"question": "What do I follow?",
|
|
340
|
-
"icon": "pi pi-
|
|
340
|
+
"icon": "pi pi-bookmark",
|
|
341
341
|
"readings": [
|
|
342
342
|
"the pages the person starred and the searches they saved, by kind",
|
|
343
343
|
"each line opens its page, filtered as it was for a search"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "favorites",
|
|
3
3
|
"title": "Favourites",
|
|
4
4
|
"question": "What do I follow?",
|
|
5
|
-
"icon": "pi pi-
|
|
5
|
+
"icon": "pi pi-bookmark",
|
|
6
6
|
"readings": [
|
|
7
7
|
"the pages the person starred and the searches they saved, by kind",
|
|
8
8
|
"each line opens its page, filtered as it was for a search"
|
package/src/components/index.ts
CHANGED
|
@@ -27,6 +27,13 @@ export { default as DefaultFooter } from './layout/defaults/DefaultFooter.vue'
|
|
|
27
27
|
export { default as DefaultUserInfo } from './layout/defaults/DefaultUserInfo.vue'
|
|
28
28
|
export { default as DefaultBreadcrumb } from './layout/defaults/DefaultBreadcrumb.vue'
|
|
29
29
|
|
|
30
|
+
// The side menu's sections and the settings menu (#5401)
|
|
31
|
+
export { default as QdSidebarMenus } from './layout/QdSidebarMenus.vue'
|
|
32
|
+
|
|
33
|
+
// Tabs on a page of the app's own (#5398)
|
|
34
|
+
export { default as QdTabs } from './layout/QdTabs.vue'
|
|
35
|
+
export type { QdTab } from './layout/QdTabs.types'
|
|
36
|
+
|
|
30
37
|
// Item (shared between edit and show)
|
|
31
38
|
export { default as FieldGroups } from './item/FieldGroups.vue'
|
|
32
39
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { ref, watch, onMounted, onUnmounted, computed, inject, provide, useSlots } from 'vue'
|
|
16
16
|
import { SIDEBAR_COLLAPSED_KEY } from '../../composables/useSidebarState'
|
|
17
17
|
import { RouterLink, RouterView, useRouter, useRoute } from 'vue-router'
|
|
18
|
-
import { useNavigation
|
|
18
|
+
import { useNavigation } from '../../composables/useNavigation'
|
|
19
19
|
import { useApp } from '../../composables/useApp'
|
|
20
20
|
import { useAuth } from '../../composables/useAuth'
|
|
21
21
|
import { useUserBox } from '../../composables/useUserBox'
|
|
@@ -32,6 +32,8 @@ import Zone from './Zone.vue'
|
|
|
32
32
|
import AppBanner from './AppBanner.vue'
|
|
33
33
|
import NavlinksGroup from './NavlinksGroup.vue'
|
|
34
34
|
import QdDomainBarZone from '../../domain/QdDomainBarZone.vue'
|
|
35
|
+
import QdSidebarMenus from './QdSidebarMenus.vue'
|
|
36
|
+
import { useSettingsMenu, SETTINGS_MENU_IDS } from '../../composables/useSettingsMenu'
|
|
35
37
|
import qdadmLogo from '../../assets/logo.svg'
|
|
36
38
|
import { version as qdadmVersion } from '../../../package.json'
|
|
37
39
|
|
|
@@ -62,18 +64,13 @@ const app = useApp()
|
|
|
62
64
|
// Top-level binding so the template unwraps the ComputedRef — `app.version`
|
|
63
65
|
// nested in a plain object stays a ref object (always truthy) in v-if (#1382)
|
|
64
66
|
const appVersion = app.version
|
|
65
|
-
|
|
67
|
+
// The side menu, and the settings menu behind the gear (#5401)
|
|
68
|
+
const settingsMenu = useSettingsMenu(useNavigation())
|
|
66
69
|
const { logout, authEnabled } = useAuth()
|
|
67
70
|
const { displayName: userDisplayName, subtitle: userSubtitle, initials: userInitials, avatarUrl, avatarFailed, userRoute, userLink } = useUserBox()
|
|
68
71
|
const { tOr } = useI18n()
|
|
69
72
|
const signals = inject<SignalBus | null>('qdadmSignals', null)
|
|
70
73
|
|
|
71
|
-
// LocalStorage key for collapsed sections state (namespaced by app)
|
|
72
|
-
const STORAGE_KEY = computed<string>(() => `${app.shortName.toLowerCase()}_nav_collapsed`)
|
|
73
|
-
|
|
74
|
-
// Collapsed sections state (section title -> boolean)
|
|
75
|
-
const collapsedSections = ref<Record<string, boolean>>({})
|
|
76
|
-
|
|
77
74
|
// Mobile sidebar state
|
|
78
75
|
const sidebarOpen = ref<boolean>(false)
|
|
79
76
|
const MOBILE_BREAKPOINT = 768
|
|
@@ -127,55 +124,8 @@ function handleResize(): void {
|
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
126
|
|
|
130
|
-
/**
|
|
131
|
-
* Load collapsed state from localStorage
|
|
132
|
-
*/
|
|
133
|
-
function loadCollapsedState(): void {
|
|
134
|
-
try {
|
|
135
|
-
const stored = localStorage.getItem(STORAGE_KEY.value)
|
|
136
|
-
if (stored) {
|
|
137
|
-
collapsedSections.value = JSON.parse(stored) as Record<string, boolean>
|
|
138
|
-
}
|
|
139
|
-
} catch (e) {
|
|
140
|
-
console.warn('Failed to load nav state:', e)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Save collapsed state to localStorage
|
|
146
|
-
*/
|
|
147
|
-
function saveCollapsedState(): void {
|
|
148
|
-
try {
|
|
149
|
-
localStorage.setItem(STORAGE_KEY.value, JSON.stringify(collapsedSections.value))
|
|
150
|
-
} catch (e) {
|
|
151
|
-
console.warn('Failed to save nav state:', e)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Toggle section collapsed state
|
|
157
|
-
*/
|
|
158
|
-
function toggleSection(sectionTitle: string): void {
|
|
159
|
-
collapsedSections.value[sectionTitle] = !collapsedSections.value[sectionTitle]
|
|
160
|
-
saveCollapsedState()
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Check if section should be shown expanded
|
|
165
|
-
* - Never collapsed if it contains active item
|
|
166
|
-
* - Otherwise respect user preference
|
|
167
|
-
*/
|
|
168
|
-
function isSectionExpanded(section: NavSection): boolean {
|
|
169
|
-
if (sectionHasActiveItem(section)) {
|
|
170
|
-
return true
|
|
171
|
-
}
|
|
172
|
-
const title = section.title || section.label || ''
|
|
173
|
-
return !collapsedSections.value[title]
|
|
174
|
-
}
|
|
175
|
-
|
|
176
127
|
// Load state on mount + setup resize listener
|
|
177
128
|
onMounted(() => {
|
|
178
|
-
loadCollapsedState()
|
|
179
129
|
loadSidebarCollapsed()
|
|
180
130
|
window.addEventListener('resize', handleResize)
|
|
181
131
|
})
|
|
@@ -184,18 +134,9 @@ onUnmounted(() => {
|
|
|
184
134
|
window.removeEventListener('resize', handleResize)
|
|
185
135
|
})
|
|
186
136
|
|
|
187
|
-
//
|
|
137
|
+
// Close the mobile sidebar on navigation (QdSidebarMenus unfolds the current section)
|
|
188
138
|
watch(() => route.path, () => {
|
|
189
|
-
// Close mobile sidebar on navigation
|
|
190
139
|
closeSidebar()
|
|
191
|
-
|
|
192
|
-
for (const section of navSections.value) {
|
|
193
|
-
const title = section.title || section.label || ''
|
|
194
|
-
if (sectionHasActiveItem(section) && collapsedSections.value[title]) {
|
|
195
|
-
// Auto-expand but don't save (user can collapse again if they want)
|
|
196
|
-
collapsedSections.value[title] = false
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
140
|
})
|
|
200
141
|
|
|
201
142
|
async function handleLogout(): Promise<void> {
|
|
@@ -284,46 +225,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
284
225
|
<span v-if="appVersion" class="version">v{{ appVersion }}</span>
|
|
285
226
|
</div>
|
|
286
227
|
|
|
287
|
-
<
|
|
288
|
-
<div v-for="section in navSections" :key="section.title || section.label" class="nav-section">
|
|
289
|
-
<div
|
|
290
|
-
class="nav-section-title"
|
|
291
|
-
:class="{ 'nav-section-active': sectionHasActiveItem(section) }"
|
|
292
|
-
@click="toggleSection(section.title || section.label || '')"
|
|
293
|
-
>
|
|
294
|
-
<span>{{ section.title }}</span>
|
|
295
|
-
<i
|
|
296
|
-
class="nav-section-chevron pi"
|
|
297
|
-
:class="isSectionExpanded(section) ? 'pi-chevron-down' : 'pi-chevron-right'"
|
|
298
|
-
></i>
|
|
299
|
-
</div>
|
|
300
|
-
<div class="nav-section-items" :class="{ 'nav-section-collapsed': !isSectionExpanded(section) }">
|
|
301
|
-
<template v-for="item in section.items" :key="item.route ?? item.href">
|
|
302
|
-
<a
|
|
303
|
-
v-if="item.href"
|
|
304
|
-
:href="item.href"
|
|
305
|
-
:target="item.target"
|
|
306
|
-
:rel="item.rel"
|
|
307
|
-
class="nav-item nav-item-link"
|
|
308
|
-
>
|
|
309
|
-
<i :class="item.icon"></i>
|
|
310
|
-
<span>{{ item.label }}</span>
|
|
311
|
-
<span v-if="item.external" class="pi pi-external-link nav-item-external" aria-label="opens in a new tab"></span>
|
|
312
|
-
</a>
|
|
313
|
-
<RouterLink
|
|
314
|
-
v-else
|
|
315
|
-
:to="{ name: item.route }"
|
|
316
|
-
class="nav-item"
|
|
317
|
-
:class="{ 'nav-item-active': isNavActive(item) }"
|
|
318
|
-
@click="handleNavClick($event, item)"
|
|
319
|
-
>
|
|
320
|
-
<i :class="item.icon"></i>
|
|
321
|
-
<span>{{ item.label }}</span>
|
|
322
|
-
</RouterLink>
|
|
323
|
-
</template>
|
|
324
|
-
</div>
|
|
325
|
-
</div>
|
|
326
|
-
</nav>
|
|
228
|
+
<QdSidebarMenus :settings="settingsMenu" />
|
|
327
229
|
|
|
328
230
|
<!-- Slot for custom content after navigation (e.g., impersonation controls) -->
|
|
329
231
|
<div class="sidebar-slot">
|
|
@@ -376,6 +278,25 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
376
278
|
<div v-else class="user-avatar">{{ userInitials }}</div>
|
|
377
279
|
</SidebarBox>
|
|
378
280
|
|
|
281
|
+
<!-- The gear (#5401): the settings menu in place of the main one, and back -->
|
|
282
|
+
<div v-if="settingsMenu.available.value" class="sidebar-settings">
|
|
283
|
+
<button
|
|
284
|
+
:id="SETTINGS_MENU_IDS.toggle"
|
|
285
|
+
type="button"
|
|
286
|
+
class="sidebar-settings-toggle"
|
|
287
|
+
:class="{ 'sidebar-settings-toggle--open': settingsMenu.open.value }"
|
|
288
|
+
:aria-expanded="settingsMenu.open.value ? 'true' : 'false'"
|
|
289
|
+
:aria-controls="SETTINGS_MENU_IDS.settings"
|
|
290
|
+
:aria-label="settingsMenu.open.value ? tOr('core.settingsMenu.back', 'Back to the menu') : settingsMenu.label"
|
|
291
|
+
:title="settingsMenu.open.value ? tOr('core.settingsMenu.back', 'Back to the menu') : settingsMenu.label"
|
|
292
|
+
data-settings-toggle
|
|
293
|
+
@click="settingsMenu.toggle()"
|
|
294
|
+
>
|
|
295
|
+
<i :class="settingsMenu.open.value ? 'pi pi-arrow-left' : settingsMenu.icon" aria-hidden="true"></i>
|
|
296
|
+
<span>{{ settingsMenu.open.value ? tOr('core.settingsMenu.back', 'Back to the menu') : settingsMenu.label }}</span>
|
|
297
|
+
</button>
|
|
298
|
+
</div>
|
|
299
|
+
|
|
379
300
|
<SidebarBox v-if="features.poweredBy" id="powered-by">
|
|
380
301
|
<template #icon>
|
|
381
302
|
<div class="footer-logo-wrapper">
|
|
@@ -568,17 +489,17 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
568
489
|
}
|
|
569
490
|
|
|
570
491
|
/* Navigation - compact, subtle */
|
|
571
|
-
.sidebar-nav {
|
|
492
|
+
:deep(.sidebar-nav) {
|
|
572
493
|
flex: 1;
|
|
573
494
|
overflow-y: auto;
|
|
574
495
|
padding: 0.5rem 0;
|
|
575
496
|
}
|
|
576
497
|
|
|
577
|
-
.nav-section {
|
|
498
|
+
:deep(.nav-section) {
|
|
578
499
|
margin-bottom: var(--fad-nav-section-gap);
|
|
579
500
|
}
|
|
580
501
|
|
|
581
|
-
.nav-section-title {
|
|
502
|
+
:deep(.nav-section-title) {
|
|
582
503
|
padding: var(--fad-nav-item-padding-y) var(--fad-nav-item-padding-x);
|
|
583
504
|
padding-left: 1rem;
|
|
584
505
|
font-size: var(--fad-font-size-xs);
|
|
@@ -598,27 +519,27 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
598
519
|
transition: color var(--fad-transition-fast);
|
|
599
520
|
}
|
|
600
521
|
|
|
601
|
-
.nav-section-title:hover {
|
|
522
|
+
:deep(.nav-section-title:hover) {
|
|
602
523
|
color: var(--p-surface-300, #cbd5e1);
|
|
603
524
|
}
|
|
604
525
|
|
|
605
|
-
.nav-section-active {
|
|
526
|
+
:deep(.nav-section-active) {
|
|
606
527
|
color: var(--p-primary-300, #93c5fd);
|
|
607
528
|
}
|
|
608
529
|
|
|
609
|
-
.nav-section-chevron {
|
|
530
|
+
:deep(.nav-section-chevron) {
|
|
610
531
|
font-size: 0.5rem;
|
|
611
532
|
transition: transform var(--fad-transition-fast);
|
|
612
533
|
opacity: 0.6;
|
|
613
534
|
}
|
|
614
535
|
|
|
615
|
-
.nav-section-items {
|
|
536
|
+
:deep(.nav-section-items) {
|
|
616
537
|
max-height: 500px;
|
|
617
538
|
overflow: hidden;
|
|
618
539
|
transition: max-height var(--fad-transition-normal), opacity var(--fad-transition-fast);
|
|
619
540
|
}
|
|
620
541
|
|
|
621
|
-
.nav-section-collapsed {
|
|
542
|
+
:deep(.nav-section-collapsed) {
|
|
622
543
|
max-height: 0;
|
|
623
544
|
opacity: 0;
|
|
624
545
|
}
|
|
@@ -902,12 +823,12 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
902
823
|
opacity: 1;
|
|
903
824
|
}
|
|
904
825
|
|
|
905
|
-
.sidebar--collapsed .sidebar-nav {
|
|
826
|
+
.sidebar--collapsed :deep(.sidebar-nav) {
|
|
906
827
|
padding: 0.25rem 0;
|
|
907
828
|
overflow-y: hidden;
|
|
908
829
|
}
|
|
909
830
|
|
|
910
|
-
.sidebar--collapsed .nav-section-title {
|
|
831
|
+
.sidebar--collapsed :deep(.nav-section-title) {
|
|
911
832
|
height: 0;
|
|
912
833
|
padding-top: 0;
|
|
913
834
|
padding-bottom: 0;
|
|
@@ -917,7 +838,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
917
838
|
|
|
918
839
|
/* In collapsed mode, slot stays visible but content is hidden via child styles */
|
|
919
840
|
|
|
920
|
-
.sidebar--collapsed .nav-section-items {
|
|
841
|
+
.sidebar--collapsed :deep(.nav-section-items) {
|
|
921
842
|
max-height: none !important;
|
|
922
843
|
opacity: 1 !important;
|
|
923
844
|
}
|
|
@@ -1026,7 +947,7 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
1026
947
|
width: auto;
|
|
1027
948
|
}
|
|
1028
949
|
|
|
1029
|
-
.sidebar.sidebar--collapsed .nav-section-title {
|
|
950
|
+
.sidebar.sidebar--collapsed :deep(.nav-section-title) {
|
|
1030
951
|
opacity: 1;
|
|
1031
952
|
height: auto;
|
|
1032
953
|
padding: var(--fad-nav-item-padding-y) var(--fad-nav-item-padding-x);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
|
-
* QdFavoriteStar (#5349): follow this page. A
|
|
4
|
-
*
|
|
3
|
+
* QdFavoriteStar (#5349): follow this page. A symbol beside the page's title,
|
|
4
|
+
* the bookmark by default (#5402, `features.favorites.icon`): filled when the
|
|
5
|
+
* page is a favourite, saying so in words too (aria-label, tooltip).
|
|
5
6
|
*
|
|
6
7
|
* PageHeader draws it on list, show and edit pages; a page of the app's own
|
|
7
8
|
* puts it where it wants. It shows only when the app declares the favorites
|
|
@@ -14,6 +15,7 @@ import { useRoute } from 'vue-router'
|
|
|
14
15
|
import { useI18n } from '../../i18n/useI18n'
|
|
15
16
|
import { useFavorites } from '../../favorites/useFavorites'
|
|
16
17
|
import type { Favorite } from '../../favorites/store'
|
|
18
|
+
import { useFavoritesLook } from '../../favorites/look'
|
|
17
19
|
|
|
18
20
|
const props = withDefaults(
|
|
19
21
|
defineProps<{
|
|
@@ -25,13 +27,21 @@ const props = withDefaults(
|
|
|
25
27
|
itemId?: string | number | null
|
|
26
28
|
/** The page, as a path; default the current route's path, without its query */
|
|
27
29
|
to?: string | null
|
|
30
|
+
/** Its symbol, and once a favourite; default the app's (`features.favorites`) */
|
|
31
|
+
icon?: string | null
|
|
32
|
+
iconOn?: string | null
|
|
33
|
+
/** Its text beside it; default the app's `features.favorites.labels` */
|
|
34
|
+
labelled?: boolean | null
|
|
28
35
|
}>(),
|
|
29
|
-
{ kind: 'item', entity: null, itemId: null, to: null }
|
|
36
|
+
{ kind: 'item', entity: null, itemId: null, to: null, icon: null, iconOn: null, labelled: null }
|
|
30
37
|
)
|
|
31
38
|
|
|
32
39
|
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
33
40
|
const { tOr } = useI18n()
|
|
34
41
|
const favorites = useFavorites()
|
|
42
|
+
const look = useFavoritesLook()
|
|
43
|
+
const symbol = computed(() => (on.value ? props.iconOn ?? look.iconActive : props.icon ?? look.icon))
|
|
44
|
+
const withText = computed(() => props.labelled ?? look.labels)
|
|
35
45
|
|
|
36
46
|
const target = computed(() => props.to ?? route?.path ?? '')
|
|
37
47
|
const isItem = computed(() => !!props.entity && props.itemId !== null && props.itemId !== undefined && props.itemId !== '')
|
|
@@ -66,6 +76,7 @@ function toggle(): void {
|
|
|
66
76
|
data-favorite-star
|
|
67
77
|
@click="toggle"
|
|
68
78
|
>
|
|
69
|
-
<i :class="
|
|
79
|
+
<i :class="symbol" aria-hidden="true"></i>
|
|
80
|
+
<span v-if="withText" class="qd-favorite-star-text">{{ text }}</span>
|
|
70
81
|
</button>
|
|
71
82
|
</template>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* QdSidebarMenus: the side menu's sections, collapsible, the current entry
|
|
4
|
+
* marked; and, when the app declares one (#5401), the settings menu behind
|
|
5
|
+
* the gear: the main menu slides up and the settings take its place, the
|
|
6
|
+
* closed one inert. AppLayout and DefaultMenu draw it; the gear is theirs.
|
|
7
|
+
*/
|
|
8
|
+
import { computed, inject, onMounted, ref, watch } from 'vue'
|
|
9
|
+
import { RouterLink, useRoute } from 'vue-router'
|
|
10
|
+
import type { NavSection } from '../../composables/useNavigation'
|
|
11
|
+
import { SETTINGS_MENU_IDS, type UseSettingsMenuReturn } from '../../composables/useSettingsMenu'
|
|
12
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{ settings: UseSettingsMenuReturn }>()
|
|
15
|
+
|
|
16
|
+
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
17
|
+
const { tOr } = useI18n()
|
|
18
|
+
const nav = props.settings.nav
|
|
19
|
+
const { isNavActive, sectionHasActiveItem, handleNavClick } = nav
|
|
20
|
+
|
|
21
|
+
// The sections each person folded, kept per app
|
|
22
|
+
const app = inject<{ shortName: string }>('qdadmApp', { shortName: 'qdadm' })
|
|
23
|
+
const STORAGE_KEY = computed(() => `${app.shortName.toLowerCase()}_nav_collapsed`)
|
|
24
|
+
const collapsedSections = ref<Record<string, boolean>>({})
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
try {
|
|
27
|
+
const stored = localStorage.getItem(STORAGE_KEY.value)
|
|
28
|
+
if (stored) collapsedSections.value = JSON.parse(stored) as Record<string, boolean>
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.warn('Failed to load nav state:', e)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
function toggleSection(title: string): void {
|
|
34
|
+
collapsedSections.value[title] = !collapsedSections.value[title]
|
|
35
|
+
try {
|
|
36
|
+
localStorage.setItem(STORAGE_KEY.value, JSON.stringify(collapsedSections.value))
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn('Failed to save nav state:', e)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const titleOf = (section: NavSection) => section.title || section.label || ''
|
|
42
|
+
/** Never folded while it holds the current entry */
|
|
43
|
+
const isSectionExpanded = (section: NavSection) => sectionHasActiveItem(section) || !collapsedSections.value[titleOf(section)]
|
|
44
|
+
|
|
45
|
+
// The section of the current page unfolds (not saved: the person may fold it again)
|
|
46
|
+
watch(
|
|
47
|
+
() => route?.path,
|
|
48
|
+
() => {
|
|
49
|
+
for (const section of [...nav.navSections.value, ...nav.settingsSections.value]) {
|
|
50
|
+
if (sectionHasActiveItem(section) && collapsedSections.value[titleOf(section)]) collapsedSections.value[titleOf(section)] = false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
const panes = computed(() => [
|
|
56
|
+
{ key: 'main' as const, id: SETTINGS_MENU_IDS.main, sections: nav.navSections.value },
|
|
57
|
+
{ key: 'settings' as const, id: SETTINGS_MENU_IDS.settings, sections: nav.settingsSections.value },
|
|
58
|
+
])
|
|
59
|
+
const shownPane = computed(() => (props.settings.open.value ? 'settings' : 'main'))
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div
|
|
64
|
+
class="sidebar-menus"
|
|
65
|
+
:class="{ 'sidebar-menus--two': settings.available.value, 'sidebar-menus--settings': settings.open.value }"
|
|
66
|
+
>
|
|
67
|
+
<template v-for="pane in panes" :key="pane.key">
|
|
68
|
+
<nav
|
|
69
|
+
v-if="pane.key === 'main' || settings.available.value"
|
|
70
|
+
:id="pane.id"
|
|
71
|
+
class="sidebar-nav"
|
|
72
|
+
:class="`sidebar-menu sidebar-menu--${pane.key}`"
|
|
73
|
+
:aria-label="pane.key === 'settings' ? settings.label : undefined"
|
|
74
|
+
:inert="settings.available.value && pane.key !== shownPane ? true : undefined"
|
|
75
|
+
:aria-hidden="settings.available.value && pane.key !== shownPane ? 'true' : undefined"
|
|
76
|
+
:data-menu="pane.key"
|
|
77
|
+
>
|
|
78
|
+
<!-- The settings' own head: back to the main menu -->
|
|
79
|
+
<button
|
|
80
|
+
v-if="pane.key === 'settings'"
|
|
81
|
+
type="button"
|
|
82
|
+
class="nav-item sidebar-menu-back"
|
|
83
|
+
:aria-label="tOr('core.settingsMenu.back', 'Back to the menu')"
|
|
84
|
+
:title="tOr('core.settingsMenu.back', 'Back to the menu')"
|
|
85
|
+
data-settings-back
|
|
86
|
+
@click="settings.close()"
|
|
87
|
+
>
|
|
88
|
+
<i class="pi pi-arrow-left" aria-hidden="true"></i>
|
|
89
|
+
<span>{{ settings.label }}</span>
|
|
90
|
+
</button>
|
|
91
|
+
<div v-for="section in pane.sections" :key="titleOf(section)" class="nav-section">
|
|
92
|
+
<div
|
|
93
|
+
class="nav-section-title"
|
|
94
|
+
:class="{ 'nav-section-active': sectionHasActiveItem(section) }"
|
|
95
|
+
@click="toggleSection(titleOf(section))"
|
|
96
|
+
>
|
|
97
|
+
<span>{{ section.title }}</span>
|
|
98
|
+
<i class="nav-section-chevron pi" :class="isSectionExpanded(section) ? 'pi-chevron-down' : 'pi-chevron-right'"></i>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="nav-section-items" :class="{ 'nav-section-collapsed': !isSectionExpanded(section) }">
|
|
101
|
+
<template v-for="item in section.items" :key="item.route ?? item.href">
|
|
102
|
+
<a v-if="item.href" :href="item.href" :target="item.target" :rel="item.rel" class="nav-item nav-item-link">
|
|
103
|
+
<i :class="item.icon"></i>
|
|
104
|
+
<span>{{ item.label }}</span>
|
|
105
|
+
<span v-if="item.external" class="pi pi-external-link nav-item-external" aria-label="opens in a new tab"></span>
|
|
106
|
+
</a>
|
|
107
|
+
<RouterLink
|
|
108
|
+
v-else
|
|
109
|
+
:to="{ name: item.route }"
|
|
110
|
+
class="nav-item"
|
|
111
|
+
:class="{ 'nav-item-active': isNavActive(item) }"
|
|
112
|
+
@click="handleNavClick($event, item)"
|
|
113
|
+
>
|
|
114
|
+
<i :class="item.icon"></i>
|
|
115
|
+
<span>{{ item.label }}</span>
|
|
116
|
+
</RouterLink>
|
|
117
|
+
</template>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</nav>
|
|
121
|
+
</template>
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** One tab of QdTabs (#5398) */
|
|
2
|
+
export interface QdTab {
|
|
3
|
+
/** Its name in the address and its slot's name */
|
|
4
|
+
key: string
|
|
5
|
+
label: string
|
|
6
|
+
icon?: string
|
|
7
|
+
/** A count, or a count with its tone; hidden at zero */
|
|
8
|
+
badge?: number | { count: number; tone?: 'critical' | 'watch' | null } | null
|
|
9
|
+
/** Not drawn for a user without it */
|
|
10
|
+
permission?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* QdTabs (#5398): tabs on a page of the app's own, not an entity's. A thin
|
|
4
|
+
* layer over PrimeVue's Tabs, the same parts FieldGroups uses, so the same
|
|
5
|
+
* look and the same ARIA; what it adds is what every page would redo by hand:
|
|
6
|
+
*
|
|
7
|
+
* - the current tab in the address (`?tab=groups`): a link opens it, a reload
|
|
8
|
+
* keeps it; set with router.replace, so it adds no history entry;
|
|
9
|
+
* - a badge per tab (QdBadge, as in the domain bar), hidden at zero;
|
|
10
|
+
* - a tab the user may not see (`permission`) is not drawn;
|
|
11
|
+
* - a panel is mounted the first time it is opened, then kept (`lazy`).
|
|
12
|
+
*
|
|
13
|
+
* <QdTabs :tabs="[
|
|
14
|
+
* { key: 'profile', label: 'Profile', icon: 'pi pi-user' },
|
|
15
|
+
* { key: 'groups', label: 'Groups', badge: groups.length, permission: 'entity:groups:list' },
|
|
16
|
+
* ]">
|
|
17
|
+
* <template #profile>…</template>
|
|
18
|
+
* <template #groups>…</template>
|
|
19
|
+
* </QdTabs>
|
|
20
|
+
*
|
|
21
|
+
* A record's pages as tabs are `ctx.itemTabs`; an entity's fields in tabs,
|
|
22
|
+
* `FieldGroups` with `layout="tabs"`.
|
|
23
|
+
*/
|
|
24
|
+
import { computed, ref, watch } from 'vue'
|
|
25
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
26
|
+
import Tabs from 'primevue/tabs'
|
|
27
|
+
import TabList from 'primevue/tablist'
|
|
28
|
+
import Tab from 'primevue/tab'
|
|
29
|
+
import TabPanels from 'primevue/tabpanels'
|
|
30
|
+
import TabPanel from 'primevue/tabpanel'
|
|
31
|
+
import QdBadge from '../../domain/QdBadge.vue'
|
|
32
|
+
import { useSecurity } from '../../composables/useSecurity'
|
|
33
|
+
import type { QdTab } from './QdTabs.types'
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const props = withDefaults(
|
|
37
|
+
defineProps<{
|
|
38
|
+
tabs: QdTab[]
|
|
39
|
+
/** The current tab's key (v-model) */
|
|
40
|
+
modelValue?: string | null
|
|
41
|
+
/** The query parameter that holds it; `false`: not in the address */
|
|
42
|
+
query?: string | false
|
|
43
|
+
/** Mount a panel when first opened, then keep it */
|
|
44
|
+
lazy?: boolean
|
|
45
|
+
}>(),
|
|
46
|
+
{ modelValue: null, query: 'tab', lazy: true }
|
|
47
|
+
)
|
|
48
|
+
const emit = defineEmits<{ 'update:modelValue': [key: string] }>()
|
|
49
|
+
|
|
50
|
+
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
51
|
+
const router = useRouter() as ReturnType<typeof useRouter> | undefined
|
|
52
|
+
const { isGranted } = useSecurity()
|
|
53
|
+
|
|
54
|
+
const shown = computed(() => props.tabs.filter((t) => !t.permission || isGranted(t.permission)))
|
|
55
|
+
const known = (key: unknown): key is string => typeof key === 'string' && shown.value.some((t) => t.key === key && !t.disabled)
|
|
56
|
+
const firstKey = () => shown.value.find((t) => !t.disabled)?.key ?? shown.value[0]?.key ?? ''
|
|
57
|
+
|
|
58
|
+
/** The key the address asks for, if any */
|
|
59
|
+
const fromAddress = (): string | null => {
|
|
60
|
+
if (!props.query || !route) return null
|
|
61
|
+
const v = route.query[props.query]
|
|
62
|
+
return typeof v === 'string' ? v : null
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const local = ref<string>(known(props.modelValue) ? props.modelValue! : known(fromAddress()) ? fromAddress()! : firstKey())
|
|
66
|
+
const current = computed(() => (known(local.value) ? local.value : firstKey()))
|
|
67
|
+
|
|
68
|
+
// What was opened once stays mounted
|
|
69
|
+
const opened = ref(new Set<string>([current.value]))
|
|
70
|
+
watch(current, (k) => opened.value.add(k))
|
|
71
|
+
|
|
72
|
+
watch(
|
|
73
|
+
() => props.modelValue,
|
|
74
|
+
(k) => {
|
|
75
|
+
if (known(k) && k !== local.value) local.value = k
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
// Back, forward, or a link to another tab of the same page
|
|
79
|
+
watch(
|
|
80
|
+
() => (props.query && route ? route.query[props.query] : undefined),
|
|
81
|
+
() => {
|
|
82
|
+
const k = fromAddress()
|
|
83
|
+
if (known(k) && k !== local.value) local.value = k
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
function select(value: string | number): void {
|
|
88
|
+
const key = String(value)
|
|
89
|
+
if (!known(key) || key === local.value) return
|
|
90
|
+
local.value = key
|
|
91
|
+
emit('update:modelValue', key)
|
|
92
|
+
if (props.query && route && router) {
|
|
93
|
+
const query = { ...route.query }
|
|
94
|
+
// The first tab is the page itself: no parameter for it
|
|
95
|
+
if (key === firstKey()) delete query[props.query]
|
|
96
|
+
else query[props.query] = key
|
|
97
|
+
void router.replace({ query, hash: route.hash })
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const badgeOf = (t: QdTab) => (t.badge === null || t.badge === undefined ? null : typeof t.badge === 'number' ? { count: t.badge, tone: null } : { count: t.badge.count, tone: t.badge.tone ?? null })
|
|
102
|
+
</script>
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<Tabs v-if="shown.length" :value="current" class="qd-tabs" @update:value="select">
|
|
106
|
+
<TabList>
|
|
107
|
+
<Tab v-for="t in shown" :key="t.key" :value="t.key" :disabled="t.disabled" :data-tab="t.key">
|
|
108
|
+
<i v-if="t.icon" :class="t.icon" class="qd-tabs-icon" aria-hidden="true"></i>
|
|
109
|
+
<span class="qd-tabs-label">{{ t.label }}</span>
|
|
110
|
+
<QdBadge v-if="badgeOf(t)" :count="badgeOf(t)!.count" :title="t.label" :tone="badgeOf(t)!.tone" />
|
|
111
|
+
</Tab>
|
|
112
|
+
</TabList>
|
|
113
|
+
<TabPanels>
|
|
114
|
+
<TabPanel v-for="t in shown" :key="t.key" :value="t.key" :data-tab-panel="t.key">
|
|
115
|
+
<slot v-if="!lazy || opened.has(t.key)" :name="t.key" :tab="t"></slot>
|
|
116
|
+
</TabPanel>
|
|
117
|
+
</TabPanels>
|
|
118
|
+
</Tabs>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<style scoped>
|
|
122
|
+
.qd-tabs-icon {
|
|
123
|
+
margin-right: 0.5rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.qd-tabs :deep(.qd-badge) {
|
|
127
|
+
margin-left: 0.5rem;
|
|
128
|
+
}
|
|
129
|
+
</style>
|