@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
|
@@ -9,133 +9,35 @@
|
|
|
9
9
|
* This is the default component rendered in the "menu" zone
|
|
10
10
|
* when no blocks are registered.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const route = useRoute()
|
|
22
|
-
const { navSections, isNavActive, sectionHasActiveItem, handleNavClick } = useNavigation()
|
|
23
|
-
|
|
24
|
-
// App config for storage key namespacing
|
|
25
|
-
const app = inject<AppConfig>('qdadmApp', { shortName: 'qdadm' })
|
|
26
|
-
|
|
27
|
-
// LocalStorage key for collapsed sections state
|
|
28
|
-
const STORAGE_KEY = computed<string>(() => `${app.shortName.toLowerCase()}_nav_collapsed`)
|
|
29
|
-
|
|
30
|
-
// Collapsed sections state (section title -> boolean)
|
|
31
|
-
const collapsedSections = ref<Record<string, boolean>>({})
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Load collapsed state from localStorage
|
|
35
|
-
*/
|
|
36
|
-
function loadCollapsedState(): void {
|
|
37
|
-
try {
|
|
38
|
-
const stored = localStorage.getItem(STORAGE_KEY.value)
|
|
39
|
-
if (stored) {
|
|
40
|
-
collapsedSections.value = JSON.parse(stored) as Record<string, boolean>
|
|
41
|
-
}
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.warn('Failed to load nav state:', e)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Save collapsed state to localStorage
|
|
49
|
-
*/
|
|
50
|
-
function saveCollapsedState(): void {
|
|
51
|
-
try {
|
|
52
|
-
localStorage.setItem(STORAGE_KEY.value, JSON.stringify(collapsedSections.value))
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.warn('Failed to save nav state:', e)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Toggle section collapsed state
|
|
60
|
-
*/
|
|
61
|
-
function toggleSection(sectionTitle: string): void {
|
|
62
|
-
collapsedSections.value[sectionTitle] = !collapsedSections.value[sectionTitle]
|
|
63
|
-
saveCollapsedState()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Check if section should be shown expanded
|
|
68
|
-
* - Never collapsed if it contains active item
|
|
69
|
-
* - Otherwise respect user preference
|
|
70
|
-
*/
|
|
71
|
-
function isSectionExpanded(section: NavSection): boolean {
|
|
72
|
-
if (sectionHasActiveItem(section)) {
|
|
73
|
-
return true
|
|
74
|
-
}
|
|
75
|
-
const title = section.title || section.label || ''
|
|
76
|
-
return !collapsedSections.value[title]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Load state on mount
|
|
80
|
-
onMounted(() => {
|
|
81
|
-
loadCollapsedState()
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
// Auto-expand section when navigating to an item in it
|
|
85
|
-
watch(() => route?.path, () => {
|
|
86
|
-
if (!route) return
|
|
87
|
-
for (const section of navSections.value) {
|
|
88
|
-
const title = section.title || section.label || ''
|
|
89
|
-
if (sectionHasActiveItem(section) && collapsedSections.value[title]) {
|
|
90
|
-
// Auto-expand but don't save (user can collapse again if they want)
|
|
91
|
-
collapsedSections.value[title] = false
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
})
|
|
12
|
+
import { useNavigation } from '../../../composables/useNavigation'
|
|
13
|
+
import { useSettingsMenu, SETTINGS_MENU_IDS } from '../../../composables/useSettingsMenu'
|
|
14
|
+
import { useI18n } from '../../../i18n/useI18n'
|
|
15
|
+
import QdSidebarMenus from '../QdSidebarMenus.vue'
|
|
16
|
+
|
|
17
|
+
// The sections, and the settings menu behind the gear at the bottom (#5401)
|
|
18
|
+
const settingsMenu = useSettingsMenu(useNavigation())
|
|
19
|
+
const { tOr } = useI18n()
|
|
95
20
|
</script>
|
|
96
21
|
|
|
97
22
|
<template>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
:href="item.href"
|
|
117
|
-
:target="item.target"
|
|
118
|
-
:rel="item.rel"
|
|
119
|
-
class="nav-item nav-item-link"
|
|
120
|
-
>
|
|
121
|
-
<i :class="item.icon"></i>
|
|
122
|
-
<span>{{ item.label }}</span>
|
|
123
|
-
<span v-if="item.external" class="pi pi-external-link nav-item-external" aria-label="opens in a new tab"></span>
|
|
124
|
-
</a>
|
|
125
|
-
<RouterLink
|
|
126
|
-
v-else
|
|
127
|
-
:to="{ name: item.route }"
|
|
128
|
-
class="nav-item"
|
|
129
|
-
:class="{ 'nav-item-active': isNavActive(item) }"
|
|
130
|
-
@click="handleNavClick($event, item)"
|
|
131
|
-
>
|
|
132
|
-
<i :class="item.icon"></i>
|
|
133
|
-
<span>{{ item.label }}</span>
|
|
134
|
-
</RouterLink>
|
|
135
|
-
</template>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</nav>
|
|
23
|
+
<div class="default-menu">
|
|
24
|
+
<QdSidebarMenus :settings="settingsMenu" />
|
|
25
|
+
<button
|
|
26
|
+
v-if="settingsMenu.available.value"
|
|
27
|
+
:id="SETTINGS_MENU_IDS.toggle"
|
|
28
|
+
type="button"
|
|
29
|
+
class="sidebar-settings-toggle"
|
|
30
|
+
:class="{ 'sidebar-settings-toggle--open': settingsMenu.open.value }"
|
|
31
|
+
:aria-expanded="settingsMenu.open.value ? 'true' : 'false'"
|
|
32
|
+
:aria-controls="SETTINGS_MENU_IDS.settings"
|
|
33
|
+
:aria-label="settingsMenu.open.value ? tOr('core.settingsMenu.back', 'Back to the menu') : settingsMenu.label"
|
|
34
|
+
data-settings-toggle
|
|
35
|
+
@click="settingsMenu.toggle()"
|
|
36
|
+
>
|
|
37
|
+
<i :class="settingsMenu.open.value ? 'pi pi-arrow-left' : settingsMenu.icon" aria-hidden="true"></i>
|
|
38
|
+
<span>{{ settingsMenu.open.value ? tOr('core.settingsMenu.back', 'Back to the menu') : settingsMenu.label }}</span>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
139
41
|
</template>
|
|
140
42
|
|
|
141
43
|
<style scoped>
|
|
@@ -143,20 +45,28 @@ watch(() => route?.path, () => {
|
|
|
143
45
|
* Only keep styles here that REQUIRE scoping (:deep, dynamic binding, component-specific overrides).
|
|
144
46
|
* Generic/reusable styles belong in src/styles/ partials (see _forms.scss, _cards.scss, etc.).
|
|
145
47
|
*/
|
|
48
|
+
/* The menus fill the zone; the gear sits at their foot */
|
|
49
|
+
.default-menu {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
flex: 1;
|
|
53
|
+
min-height: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
146
56
|
/* DefaultMenu uses sidebar-nav class to inherit global nav-item styles from _sidebar.scss
|
|
147
57
|
Only component-specific styles remain here */
|
|
148
58
|
|
|
149
|
-
.sidebar-nav {
|
|
59
|
+
.default-menu :deep(.sidebar-nav) {
|
|
150
60
|
flex: 1;
|
|
151
61
|
overflow-y: auto;
|
|
152
62
|
padding: 1rem 0;
|
|
153
63
|
}
|
|
154
64
|
|
|
155
|
-
.nav-section {
|
|
65
|
+
.default-menu :deep(.nav-section) {
|
|
156
66
|
margin-bottom: 0.5rem;
|
|
157
67
|
}
|
|
158
68
|
|
|
159
|
-
.nav-section-title {
|
|
69
|
+
.default-menu :deep(.nav-section-title) {
|
|
160
70
|
padding: 0.5rem 1.5rem;
|
|
161
71
|
font-size: 0.75rem;
|
|
162
72
|
font-weight: 600;
|
|
@@ -171,26 +81,26 @@ watch(() => route?.path, () => {
|
|
|
171
81
|
transition: color 0.15s;
|
|
172
82
|
}
|
|
173
83
|
|
|
174
|
-
.nav-section-title:hover {
|
|
84
|
+
.default-menu :deep(.nav-section-title:hover) {
|
|
175
85
|
color: var(--p-surface-200, #e2e8f0);
|
|
176
86
|
}
|
|
177
87
|
|
|
178
|
-
.nav-section-active {
|
|
88
|
+
.default-menu :deep(.nav-section-active) {
|
|
179
89
|
color: var(--p-primary-400, #60a5fa);
|
|
180
90
|
}
|
|
181
91
|
|
|
182
|
-
.nav-section-chevron {
|
|
92
|
+
.default-menu :deep(.nav-section-chevron) {
|
|
183
93
|
font-size: 0.625rem;
|
|
184
94
|
transition: transform 0.2s;
|
|
185
95
|
}
|
|
186
96
|
|
|
187
|
-
.nav-section-items {
|
|
97
|
+
.default-menu :deep(.nav-section-items) {
|
|
188
98
|
max-height: 500px;
|
|
189
99
|
overflow: hidden;
|
|
190
100
|
transition: max-height 0.2s ease-out, opacity 0.15s;
|
|
191
101
|
}
|
|
192
102
|
|
|
193
|
-
.nav-section-collapsed {
|
|
103
|
+
.default-menu :deep(.nav-section-collapsed) {
|
|
194
104
|
max-height: 0;
|
|
195
105
|
opacity: 0;
|
|
196
106
|
}
|
|
@@ -23,6 +23,7 @@ import DataTable from 'primevue/datatable'
|
|
|
23
23
|
import Column from 'primevue/column'
|
|
24
24
|
import QdButton from '../base/QdButton.vue'
|
|
25
25
|
import QdSaveSearch from './QdSaveSearch.vue'
|
|
26
|
+
import { useFavoritesLook } from '../../favorites/look'
|
|
26
27
|
import SeverityTag from '../SeverityTag.vue'
|
|
27
28
|
import { useI18n } from '../../i18n/useI18n'
|
|
28
29
|
import ShowDisplay from '../show/ShowDisplay.vue'
|
|
@@ -89,6 +90,8 @@ const props = defineProps({
|
|
|
89
90
|
favorite: { type: Boolean, default: true },
|
|
90
91
|
/** The filter in words while one is on: offers "Save this search" (#5349) */
|
|
91
92
|
searchLabel: { type: String as PropType<string | null>, default: null },
|
|
93
|
+
/** Where the search's bookmark goes (#5402): 'filters', 'header', or false; default the app's `features.favorites.saveSearch` */
|
|
94
|
+
saveSearch: { type: [String, Boolean] as PropType<'filters' | 'header' | false | null>, default: null },
|
|
92
95
|
|
|
93
96
|
// Cards
|
|
94
97
|
cards: { type: Array as PropType<CardConfig[]>, default: () => [] },
|
|
@@ -145,6 +148,10 @@ const props = defineProps({
|
|
|
145
148
|
hasRowTapAction: { type: Boolean, default: false }
|
|
146
149
|
})
|
|
147
150
|
|
|
151
|
+
// Where the search's bookmark goes (#5402): this list's say, else the app's
|
|
152
|
+
const favoritesLook = useFavoritesLook()
|
|
153
|
+
const saveSearchAt = computed(() => (props.saveSearch === null ? favoritesLook.saveSearch : props.saveSearch))
|
|
154
|
+
|
|
148
155
|
const { tOr } = useI18n()
|
|
149
156
|
|
|
150
157
|
// `{ name, label }` is read as `{ field, header }`; a column without either is skipped
|
|
@@ -360,7 +367,7 @@ function getFilterClass(filter: FilterConfig): Record<string, boolean> {
|
|
|
360
367
|
<PageHeader :title="title" :subtitle="subtitle" :favorite="favorite ? { kind: 'list', entity } : null">
|
|
361
368
|
<template #actions>
|
|
362
369
|
<slot name="header-actions" ></slot>
|
|
363
|
-
<QdSaveSearch v-if="searchLabel" :default-name="searchLabel" :entity="entity" />
|
|
370
|
+
<QdSaveSearch v-if="searchLabel && saveSearchAt === 'header'" :default-name="searchLabel" :entity="entity" />
|
|
364
371
|
<!-- Mobile: split button (primary action + dropdown) -->
|
|
365
372
|
<template v-if="isMobile && headerActions.length > 0 && primaryHeaderAction">
|
|
366
373
|
<!-- Single action: just a button -->
|
|
@@ -458,6 +465,8 @@ function getFilterClass(filter: FilterConfig): Record<string, boolean> {
|
|
|
458
465
|
@click="clearAllFilters"
|
|
459
466
|
v-tooltip.top="'Clear filters'"
|
|
460
467
|
/>
|
|
468
|
+
<!-- The search's bookmark, beside what it saves (#5402) -->
|
|
469
|
+
<QdSaveSearch v-if="searchLabel && saveSearchAt === 'filters'" :default-name="searchLabel" :entity="entity" />
|
|
461
470
|
</FilterBar>
|
|
462
471
|
|
|
463
472
|
<!-- Data Table -->
|
|
@@ -4,14 +4,30 @@
|
|
|
4
4
|
* name (by default the filter in words) and keeps the list's route with its
|
|
5
5
|
* query as a favourite of kind `search`: the list writes its filters in the
|
|
6
6
|
* URL, so the favourite opens it filtered again.
|
|
7
|
+
*
|
|
8
|
+
* Its look (#5402): the app's favourite symbol (`features.favorites`), the
|
|
9
|
+
* bookmark by default, alone, its text in aria-label and tooltip; filled once
|
|
10
|
+
* saved, and then a click takes the search out of the favourites again.
|
|
7
11
|
*/
|
|
8
12
|
import { computed, nextTick, ref } from 'vue'
|
|
9
13
|
import { useRoute } from 'vue-router'
|
|
10
14
|
import QdButton from '../base/QdButton.vue'
|
|
11
15
|
import { useI18n } from '../../i18n/useI18n'
|
|
12
16
|
import { useFavorites } from '../../favorites/useFavorites'
|
|
17
|
+
import { useFavoritesLook } from '../../favorites/look'
|
|
13
18
|
|
|
14
|
-
const props = withDefaults(
|
|
19
|
+
const props = withDefaults(
|
|
20
|
+
defineProps<{
|
|
21
|
+
defaultName: string
|
|
22
|
+
entity?: string | null
|
|
23
|
+
/** Its symbol, and once saved; default the app's (`features.favorites`) */
|
|
24
|
+
icon?: string | null
|
|
25
|
+
iconOn?: string | null
|
|
26
|
+
/** Its text beside it; default the app's `features.favorites.labels` */
|
|
27
|
+
labelled?: boolean | null
|
|
28
|
+
}>(),
|
|
29
|
+
{ entity: null, icon: null, iconOn: null, labelled: null }
|
|
30
|
+
)
|
|
15
31
|
|
|
16
32
|
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
17
33
|
const { tOr } = useI18n()
|
|
@@ -29,13 +45,24 @@ const target = computed(() => {
|
|
|
29
45
|
return q ? `${route.path}?${q}` : route.path
|
|
30
46
|
})
|
|
31
47
|
const saved = computed(() => favorites.has(target.value))
|
|
48
|
+
const look = useFavoritesLook()
|
|
49
|
+
const symbol = computed(() => (saved.value ? props.iconOn ?? look.iconActive : props.icon ?? look.icon))
|
|
50
|
+
const withText = computed(() => props.labelled ?? look.labels)
|
|
51
|
+
const text = computed(() =>
|
|
52
|
+
saved.value ? tOr('core.favorites.removeSearch', 'Search saved: remove it from favourites') : tOr('core.favorites.saveSearch', 'Save this search')
|
|
53
|
+
)
|
|
32
54
|
|
|
33
55
|
const asking = ref(false)
|
|
34
56
|
const name = ref('')
|
|
35
57
|
const input = ref<HTMLInputElement | null>(null)
|
|
36
58
|
|
|
37
59
|
async function ask(): Promise<void> {
|
|
38
|
-
|
|
60
|
+
// Saved already: the same symbol takes it out again, as the page's does
|
|
61
|
+
if (saved.value) {
|
|
62
|
+
const fav = favorites.find(target.value)
|
|
63
|
+
if (fav) await favorites.remove(fav.id)
|
|
64
|
+
return
|
|
65
|
+
}
|
|
39
66
|
name.value = props.defaultName
|
|
40
67
|
asking.value = true
|
|
41
68
|
await nextTick()
|
|
@@ -69,9 +96,15 @@ function save(): void {
|
|
|
69
96
|
type="button"
|
|
70
97
|
size="small"
|
|
71
98
|
text
|
|
72
|
-
:
|
|
73
|
-
|
|
74
|
-
:
|
|
99
|
+
:rounded="!withText"
|
|
100
|
+
severity="secondary"
|
|
101
|
+
:icon="symbol"
|
|
102
|
+
:label="withText ? text : undefined"
|
|
103
|
+
:aria-label="text"
|
|
104
|
+
:aria-pressed="saved ? 'true' : 'false'"
|
|
105
|
+
v-tooltip.top="withText ? undefined : text"
|
|
106
|
+
class="qd-save-search-toggle"
|
|
107
|
+
:class="{ 'qd-save-search-toggle--on': saved }"
|
|
75
108
|
data-save-search
|
|
76
109
|
@click="ask"
|
|
77
110
|
/>
|
package/src/composables/index.ts
CHANGED
|
@@ -82,6 +82,7 @@ export {
|
|
|
82
82
|
type BreadcrumbModeToggle,
|
|
83
83
|
} from './useNavContext'
|
|
84
84
|
export { useNavigation, type UseNavigationReturn, type NavItem, type NavSection } from './useNavigation'
|
|
85
|
+
export { useSettingsMenu, SETTINGS_MENU_IDS, type UseSettingsMenuReturn } from './useSettingsMenu'
|
|
85
86
|
export {
|
|
86
87
|
useUnsavedChangesGuard,
|
|
87
88
|
type UseUnsavedChangesGuardOptions,
|
|
@@ -14,6 +14,7 @@ import { computed, inject, ref, onMounted, type ComputedRef, type Ref } from 'vu
|
|
|
14
14
|
import { useRoute, useRouter } from 'vue-router'
|
|
15
15
|
import { getNavSections, alterMenuSections, isMenuAltered } from '../module/moduleRegistry'
|
|
16
16
|
import { useSemanticBreadcrumb } from './useSemanticBreadcrumb'
|
|
17
|
+
import { useAuth } from './useAuth'
|
|
17
18
|
import { useI18n } from '../i18n/useI18n'
|
|
18
19
|
import type { HookRegistry } from '../hooks/HookRegistry'
|
|
19
20
|
import type { OrchestratorLike } from '../entity/EntityManager.interface'
|
|
@@ -43,6 +44,8 @@ export interface NavItem {
|
|
|
43
44
|
icon?: string
|
|
44
45
|
entity?: string
|
|
45
46
|
exact?: boolean
|
|
47
|
+
/** The menu it belongs to (#5401): the main one, or the settings behind the gear */
|
|
48
|
+
menu?: 'main' | 'settings'
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
/**
|
|
@@ -66,8 +69,16 @@ export interface NavSection {
|
|
|
66
69
|
* Return type for useNavigation
|
|
67
70
|
*/
|
|
68
71
|
export interface UseNavigationReturn {
|
|
69
|
-
/**
|
|
72
|
+
/** The main menu's sections (filtered by permissions) */
|
|
70
73
|
navSections: ComputedRef<NavSection[]>
|
|
74
|
+
/** The settings menu's sections, behind the gear (#5401); empty for whoever may not see it */
|
|
75
|
+
settingsSections: ComputedRef<NavSection[]>
|
|
76
|
+
/** There is a settings menu for this user */
|
|
77
|
+
hasSettingsMenu: ComputedRef<boolean>
|
|
78
|
+
/** The page on screen is one of the settings menu's */
|
|
79
|
+
settingsActive: ComputedRef<boolean>
|
|
80
|
+
/** The settings menu's name and icon (`features.settingsMenu`) */
|
|
81
|
+
settingsMenu: { label: string; icon: string }
|
|
71
82
|
/** Whether menu:alter has completed */
|
|
72
83
|
isReady: Ref<boolean>
|
|
73
84
|
/** Check if nav item is active */
|
|
@@ -185,7 +196,22 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
185
196
|
// Get nav sections from registry, filtering items based on permissions
|
|
186
197
|
// Depends on alterVersion + i18nLocale to trigger re-computation after
|
|
187
198
|
// alteration or locale change.
|
|
188
|
-
|
|
199
|
+
// The settings menu (#5401): its entries say `menu: 'settings'`; the app
|
|
200
|
+
// may narrow who sees it beyond its entries' permissions
|
|
201
|
+
const features = inject<{ settingsMenu?: { visible?: (user: unknown) => boolean; label?: string; icon?: string; sections?: string[] } } | null>('qdadmFeatures', null)
|
|
202
|
+
const { user } = useAuth()
|
|
203
|
+
const settingsConfig = features?.settingsMenu ?? {}
|
|
204
|
+
const settingsSectionNames = new Set(settingsConfig.sections ?? [])
|
|
205
|
+
const settingsAllowed = computed(() => {
|
|
206
|
+
if (typeof settingsConfig.visible !== 'function') return true
|
|
207
|
+
try {
|
|
208
|
+
return !!settingsConfig.visible(user.value)
|
|
209
|
+
} catch {
|
|
210
|
+
return false
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
const sectionsOf = (menu: 'main' | 'settings') => {
|
|
189
215
|
// Force dependencies for reactivity
|
|
190
216
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
191
217
|
alterVersion.value
|
|
@@ -198,6 +224,8 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
198
224
|
...section,
|
|
199
225
|
title: resolveNavLabel(`nav.sections.${section.title}`, section.title),
|
|
200
226
|
items: section.items
|
|
227
|
+
// An entry's own `menu`, else its section's (`settingsMenu.sections`)
|
|
228
|
+
.filter((item) => (item.menu ?? (settingsSectionNames.has(section.title) ? 'settings' : 'main')) === menu)
|
|
201
229
|
.filter((item) => canAccessNavItem(item))
|
|
202
230
|
.map((item) => (item.href ? linkItem(item) : {
|
|
203
231
|
...item,
|
|
@@ -205,7 +233,10 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
205
233
|
})),
|
|
206
234
|
}))
|
|
207
235
|
.filter((section) => section.items.length > 0) // Hide empty sections
|
|
208
|
-
}
|
|
236
|
+
}
|
|
237
|
+
const navSections = computed(() => sectionsOf('main'))
|
|
238
|
+
const settingsSections = computed(() => (settingsAllowed.value ? sectionsOf('settings') : []))
|
|
239
|
+
const hasSettingsMenu = computed(() => settingsSections.value.length > 0)
|
|
209
240
|
|
|
210
241
|
/**
|
|
211
242
|
* Check if a nav item is currently active
|
|
@@ -254,9 +285,18 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
254
285
|
}
|
|
255
286
|
}
|
|
256
287
|
|
|
288
|
+
const settingsActive = computed(() => settingsSections.value.some((section) => sectionHasActiveItem(section)))
|
|
289
|
+
|
|
257
290
|
return {
|
|
258
291
|
// Data (from moduleRegistry)
|
|
259
292
|
navSections,
|
|
293
|
+
settingsSections,
|
|
294
|
+
hasSettingsMenu,
|
|
295
|
+
settingsActive,
|
|
296
|
+
settingsMenu: {
|
|
297
|
+
label: settingsConfig.label ?? resolveNavLabel('core.settingsMenu.label', 'Settings'),
|
|
298
|
+
icon: settingsConfig.icon ?? 'pi pi-cog',
|
|
299
|
+
},
|
|
260
300
|
|
|
261
301
|
// Ready state (menu:alter completed)
|
|
262
302
|
isReady,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSettingsMenu (#5401): the side menu's second menu, the settings, behind
|
|
3
|
+
* a gear. Open on a settings page by itself (a link, a reload), closed on a
|
|
4
|
+
* page of the main menu; opened and closed by the gear or the back row, the
|
|
5
|
+
* focus following: to the first entry of the menu opened, back to the gear.
|
|
6
|
+
*
|
|
7
|
+
* const settings = useSettingsMenu()
|
|
8
|
+
* <QdSidebarMenus :settings="settings" />
|
|
9
|
+
* <button v-if="settings.available.value" :aria-expanded="settings.open.value" @click="settings.toggle()">
|
|
10
|
+
*/
|
|
11
|
+
import { computed, nextTick, ref, watch, type ComputedRef, type Ref } from 'vue'
|
|
12
|
+
import { useRoute } from 'vue-router'
|
|
13
|
+
import { useNavigation, type UseNavigationReturn } from './useNavigation'
|
|
14
|
+
|
|
15
|
+
/** The ids the side menu's parts carry, for aria-controls and the focus */
|
|
16
|
+
export const SETTINGS_MENU_IDS = {
|
|
17
|
+
main: 'qd-menu-main',
|
|
18
|
+
settings: 'qd-menu-settings',
|
|
19
|
+
toggle: 'qd-settings-toggle',
|
|
20
|
+
} as const
|
|
21
|
+
|
|
22
|
+
export interface UseSettingsMenuReturn {
|
|
23
|
+
nav: UseNavigationReturn
|
|
24
|
+
/** There is a settings menu for this user */
|
|
25
|
+
available: ComputedRef<boolean>
|
|
26
|
+
/** The settings menu is the one shown */
|
|
27
|
+
open: Ref<boolean>
|
|
28
|
+
toggle: () => void
|
|
29
|
+
/** Back to the main menu */
|
|
30
|
+
close: () => void
|
|
31
|
+
label: string
|
|
32
|
+
icon: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function focusIn(id: string): Promise<void> {
|
|
36
|
+
await nextTick()
|
|
37
|
+
if (typeof document === 'undefined') return
|
|
38
|
+
const el = document.getElementById(id)
|
|
39
|
+
const target = el?.matches('button, a') ? el : el?.querySelector<HTMLElement>('a.nav-item')
|
|
40
|
+
;(target as HTMLElement | null | undefined)?.focus()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function useSettingsMenu(given: UseNavigationReturn = useNavigation()): UseSettingsMenuReturn {
|
|
44
|
+
// A navigation of its own (a test, an app's stand-in) may know nothing of the settings
|
|
45
|
+
const nav: UseNavigationReturn = {
|
|
46
|
+
...given,
|
|
47
|
+
settingsSections: given.settingsSections ?? computed(() => []),
|
|
48
|
+
hasSettingsMenu: given.hasSettingsMenu ?? computed(() => false),
|
|
49
|
+
settingsActive: given.settingsActive ?? computed(() => false),
|
|
50
|
+
settingsMenu: given.settingsMenu ?? { label: 'Settings', icon: 'pi pi-cog' },
|
|
51
|
+
}
|
|
52
|
+
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
53
|
+
const available = computed(() => nav.hasSettingsMenu.value)
|
|
54
|
+
const open = ref(available.value && nav.settingsActive.value)
|
|
55
|
+
|
|
56
|
+
// The page decides: a settings page opens the settings, a main page the main menu
|
|
57
|
+
const follow = () => (open.value = available.value && nav.settingsActive.value)
|
|
58
|
+
watch(() => route?.path, follow)
|
|
59
|
+
watch(() => nav.settingsActive.value, follow)
|
|
60
|
+
watch(available, (yes) => {
|
|
61
|
+
if (!yes) open.value = false
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
function close(): void {
|
|
65
|
+
if (!open.value) return
|
|
66
|
+
open.value = false
|
|
67
|
+
// Back to the gear; without it, to the main menu
|
|
68
|
+
const gear = typeof document !== 'undefined' && document.getElementById(SETTINGS_MENU_IDS.toggle)
|
|
69
|
+
void focusIn(gear ? SETTINGS_MENU_IDS.toggle : SETTINGS_MENU_IDS.main)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toggle(): void {
|
|
73
|
+
if (open.value) return close()
|
|
74
|
+
if (!available.value) return
|
|
75
|
+
open.value = true
|
|
76
|
+
void focusIn(SETTINGS_MENU_IDS.settings)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return { nav, available, open, toggle, close, label: nav.settingsMenu.label, icon: nav.settingsMenu.icon }
|
|
80
|
+
}
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* an indicator) and its indicators: mini cards, each read from its own source
|
|
6
6
|
* and drawn as a pill whose count is a badge.
|
|
7
7
|
*
|
|
8
|
-
* Its look (#
|
|
9
|
-
*
|
|
10
|
-
* `features.domainBar.look`. Both are
|
|
11
|
-
* (`--qd-domain-bar-*`, `--qd-
|
|
8
|
+
* Its look (#5400): a toolbox, one low line glued to the top edge of the
|
|
9
|
+
* content in the side menu's style (the default), or a card above the page:
|
|
10
|
+
* the domain's `look`, else the app's `features.domainBar.look`. Both are
|
|
11
|
+
* drawn from CSS custom properties (`--qd-domain-bar-*`, `--qd-toolbox-*`),
|
|
12
|
+
* to change in the app's own CSS.
|
|
12
13
|
*
|
|
13
14
|
* Compact: one line of icons and badges, on its own once the page scrolls, or
|
|
14
15
|
* by the person's choice, kept per account.
|
|
@@ -25,9 +26,18 @@ import { badgeTone, type DomainDefinition, type DomainIndicator, type DomainLook
|
|
|
25
26
|
|
|
26
27
|
const props = defineProps<{ domain: DomainDefinition }>()
|
|
27
28
|
|
|
28
|
-
// The look (#
|
|
29
|
+
// The look (#5400): the domain's, else the app's, else the toolbox
|
|
29
30
|
const features = inject<{ domainBar?: { look?: DomainLook } } | null>('qdadmFeatures', null)
|
|
30
|
-
|
|
31
|
+
let warned = false
|
|
32
|
+
const look = computed<'toolbox' | 'card'>(() => {
|
|
33
|
+
const asked = props.domain.look ?? features?.domainBar?.look ?? 'toolbox'
|
|
34
|
+
if (asked === 'card') return 'card'
|
|
35
|
+
if (asked === 'ribbon' && !warned && (import.meta as unknown as { env?: { DEV?: boolean } }).env?.DEV === true) {
|
|
36
|
+
warned = true
|
|
37
|
+
console.warn(`[qdadm] domain('${props.domain.name}'): the 'ribbon' look is withdrawn; it draws the default toolbox. Leave look out, or say 'card'.`)
|
|
38
|
+
}
|
|
39
|
+
return 'toolbox'
|
|
40
|
+
})
|
|
31
41
|
|
|
32
42
|
const { locale, tOr } = useI18n()
|
|
33
43
|
const route = useRoute()
|
package/src/domain/registry.ts
CHANGED
|
@@ -46,16 +46,17 @@ export interface DomainNavEntry {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* How the bar sits (#
|
|
50
|
-
*
|
|
49
|
+
* How the bar sits (#5400): `toolbox` (the default), one low line glued to the
|
|
50
|
+
* top edge of the content, drawn like the side menu; `card`, a card above the
|
|
51
|
+
* page. `ribbon` (#5396) is withdrawn: it draws the toolbox, with a warning.
|
|
51
52
|
*/
|
|
52
|
-
export type DomainLook = 'card' | 'ribbon'
|
|
53
|
+
export type DomainLook = 'toolbox' | 'card' | 'ribbon'
|
|
53
54
|
|
|
54
55
|
/** What `ctx.domain(name, …)` declares */
|
|
55
56
|
export interface DomainConfig {
|
|
56
57
|
label: string
|
|
57
58
|
icon?: string
|
|
58
|
-
/** Default: the app's `features.domainBar.look`, else `
|
|
59
|
+
/** Default: the app's `features.domainBar.look`, else `toolbox` */
|
|
59
60
|
look?: DomainLook
|
|
60
61
|
/** Where the domain's title leads (its board) */
|
|
61
62
|
to?: RouteLocationRaw
|
package/src/favorites/index.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { useFavorites, useRecent, type UseFavoritesReturn, type UseRecentReturn
|
|
|
5
5
|
export { RECENT_MAX, resetFavoriteLists, configureFavorites, getFavoritesConfig, type Favorite, type RecentItem, type FavoritesOptions, type FavoritesManager } from './store'
|
|
6
6
|
export { default as QdFavoriteStar } from '../components/layout/QdFavoriteStar.vue'
|
|
7
7
|
export { default as QdSaveSearch } from '../components/lists/QdSaveSearch.vue'
|
|
8
|
+
export { useFavoritesLook, DEFAULT_FAVORITES_LOOK, type FavoritesLook } from './look'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The favourites' look (#5402), an app setting: `features.favorites` in the
|
|
3
|
+
* kernel's options. The bookmark by default, icons alone, a list's search
|
|
4
|
+
* bookmark in its filter zone. Each use may still say otherwise by its props.
|
|
5
|
+
*/
|
|
6
|
+
import { inject } from 'vue'
|
|
7
|
+
|
|
8
|
+
export interface FavoritesLook {
|
|
9
|
+
/** The symbol (default `pi pi-bookmark`) */
|
|
10
|
+
icon: string
|
|
11
|
+
/** The symbol once a favourite (default `pi pi-bookmark-fill`) */
|
|
12
|
+
iconActive: string
|
|
13
|
+
/** Where a list's search bookmark goes: its filter zone, its header, or nowhere */
|
|
14
|
+
saveSearch: 'filters' | 'header' | false
|
|
15
|
+
/** The text beside the icons (default: icons alone, the text in aria-label and tooltip) */
|
|
16
|
+
labels: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_FAVORITES_LOOK: FavoritesLook = {
|
|
20
|
+
icon: 'pi pi-bookmark',
|
|
21
|
+
iconActive: 'pi pi-bookmark-fill',
|
|
22
|
+
saveSearch: 'filters',
|
|
23
|
+
labels: false,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Inside a component's setup */
|
|
27
|
+
export function useFavoritesLook(): FavoritesLook {
|
|
28
|
+
const features = inject<{ favorites?: Partial<FavoritesLook> } | null>('qdadmFeatures', null)
|
|
29
|
+
return { ...DEFAULT_FAVORITES_LOOK, ...(features?.favorites ?? {}) }
|
|
30
|
+
}
|
|
@@ -484,6 +484,10 @@ export default `core:
|
|
|
484
484
|
urgent: urgent
|
|
485
485
|
todo: to do
|
|
486
486
|
# Favourites and recents: the star, "Save this search", the two cards (#5349)
|
|
487
|
+
# The settings menu behind the gear (#5401)
|
|
488
|
+
settingsMenu:
|
|
489
|
+
label: Settings
|
|
490
|
+
back: Back to the menu
|
|
487
491
|
favorites:
|
|
488
492
|
add: "Add {label} to favourites"
|
|
489
493
|
remove: "Remove {label} from favourites"
|
|
@@ -492,6 +496,7 @@ export default `core:
|
|
|
492
496
|
undoLabel: "Put {label} back in favourites"
|
|
493
497
|
saveSearch: Save this search
|
|
494
498
|
searchSaved: Search saved
|
|
499
|
+
removeSearch: "Search saved: remove it from favourites"
|
|
495
500
|
searchName: Name of the search
|
|
496
501
|
save: Save
|
|
497
502
|
title: Favourites
|