@quazardous/qdadm 2.51.0 → 2.53.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.
Files changed (129) hide show
  1. package/dist/node/cards/tools/cardsTool.d.ts +32 -0
  2. package/dist/node/cards/tools/cardsTool.js +151 -0
  3. package/dist/node/cards/tools/cli.d.ts +2 -0
  4. package/dist/node/cards/tools/cli.js +38 -0
  5. package/dist/node/cards/validate.d.ts +35 -0
  6. package/dist/node/cards/validate.js +94 -0
  7. package/dist/styles/qdadm.css +1 -1
  8. package/package.json +7 -2
  9. package/src/board/QdBoardBlock.vue +67 -0
  10. package/src/board/QdDomainBoard.vue +64 -0
  11. package/src/board/blocks/BreakdownBlock.vue +44 -0
  12. package/src/board/blocks/KpiBlock.vue +31 -0
  13. package/src/board/blocks/TimelineBlock.vue +63 -0
  14. package/src/board/blocks/TopBlock.vue +57 -0
  15. package/src/board/blocks/schemas.ts +107 -0
  16. package/src/board/index.ts +31 -0
  17. package/src/board/registry.ts +33 -0
  18. package/src/board/types.ts +32 -0
  19. package/src/cards/QdCard.vue +175 -0
  20. package/src/cards/QdCardView.vue +53 -0
  21. package/src/cards/QdCardsGallery.vue +103 -0
  22. package/src/cards/QdFavoritesCard.vue +50 -0
  23. package/src/cards/QdRecentCard.vue +44 -0
  24. package/src/cards/builtin/agenda/AgendaCard.vue +37 -0
  25. package/src/cards/builtin/agenda/meta.json +60 -0
  26. package/src/cards/builtin/agenda/schema.json +48 -0
  27. package/src/cards/builtin/bullet/BulletCard.vue +76 -0
  28. package/src/cards/builtin/bullet/meta.json +38 -0
  29. package/src/cards/builtin/bullet/schema.json +18 -0
  30. package/src/cards/builtin/cards-index.json +1694 -0
  31. package/src/cards/builtin/compare/CompareCard.vue +47 -0
  32. package/src/cards/builtin/compare/meta.json +79 -0
  33. package/src/cards/builtin/compare/schema.json +40 -0
  34. package/src/cards/builtin/favorites/FavoritesCard.vue +50 -0
  35. package/src/cards/builtin/favorites/meta.json +33 -0
  36. package/src/cards/builtin/favorites/schema.json +20 -0
  37. package/src/cards/builtin/feed/FeedCard.vue +39 -0
  38. package/src/cards/builtin/feed/meta.json +64 -0
  39. package/src/cards/builtin/feed/schema.json +54 -0
  40. package/src/cards/builtin/funnel/FunnelCard.vue +44 -0
  41. package/src/cards/builtin/funnel/meta.json +53 -0
  42. package/src/cards/builtin/funnel/schema.json +37 -0
  43. package/src/cards/builtin/goal/GoalCard.vue +73 -0
  44. package/src/cards/builtin/goal/meta.json +43 -0
  45. package/src/cards/builtin/goal/schema.json +12 -0
  46. package/src/cards/builtin/heat/HeatCard.vue +46 -0
  47. package/src/cards/builtin/heat/meta.json +101 -0
  48. package/src/cards/builtin/heat/schema.json +39 -0
  49. package/src/cards/builtin/index.ts +71 -0
  50. package/src/cards/builtin/metric/MetricCard.vue +82 -0
  51. package/src/cards/builtin/metric/meta.json +109 -0
  52. package/src/cards/builtin/metric/schema.json +35 -0
  53. package/src/cards/builtin/pills.ts +36 -0
  54. package/src/cards/builtin/queue/QueueCard.vue +65 -0
  55. package/src/cards/builtin/queue/meta.json +47 -0
  56. package/src/cards/builtin/queue/schema.json +32 -0
  57. package/src/cards/builtin/ranking/RankingCard.vue +37 -0
  58. package/src/cards/builtin/ranking/meta.json +71 -0
  59. package/src/cards/builtin/ranking/schema.json +35 -0
  60. package/src/cards/builtin/recent/RecentCard.vue +41 -0
  61. package/src/cards/builtin/recent/meta.json +32 -0
  62. package/src/cards/builtin/recent/schema.json +21 -0
  63. package/src/cards/builtin/shared.ts +83 -0
  64. package/src/cards/builtin/split/SplitCard.vue +52 -0
  65. package/src/cards/builtin/split/meta.json +72 -0
  66. package/src/cards/builtin/split/schema.json +40 -0
  67. package/src/cards/builtin/trend/TrendCard.vue +75 -0
  68. package/src/cards/builtin/trend/meta.json +81 -0
  69. package/src/cards/builtin/trend/schema.json +58 -0
  70. package/src/cards/index.ts +29 -0
  71. package/src/cards/registry.ts +57 -0
  72. package/src/cards/tools/cardsTool.ts +181 -0
  73. package/src/cards/tools/cli.ts +35 -0
  74. package/src/cards/types.ts +111 -0
  75. package/src/cards/validate.ts +111 -0
  76. package/src/components/edit/FormActions.vue +9 -5
  77. package/src/components/edit/FormPage.vue +17 -2
  78. package/src/components/layout/AppLayout.vue +4 -0
  79. package/src/components/layout/BaseLayout.vue +4 -0
  80. package/src/components/layout/CardParamsForm.vue +157 -0
  81. package/src/components/layout/CardsDashboard.vue +276 -57
  82. package/src/components/layout/PageHeader.vue +22 -1
  83. package/src/components/layout/QdFavoriteStar.vue +71 -0
  84. package/src/components/layout/Zone.vue +2 -1
  85. package/src/components/lists/ListPage.vue +9 -1
  86. package/src/components/lists/QdSaveSearch.vue +79 -0
  87. package/src/components/pages/NotFoundPage.vue +5 -2
  88. package/src/components/run/QdRunBar.vue +99 -0
  89. package/src/components/show/ShowPage.vue +10 -1
  90. package/src/composables/useBreadcrumb.ts +1 -1
  91. package/src/composables/useCardsArrangement.ts +297 -27
  92. package/src/composables/useEntityItemFormPage.ts +39 -3
  93. package/src/composables/useEntityItemFormPage.types.ts +8 -0
  94. package/src/composables/useEntityItemShowPage.ts +22 -0
  95. package/src/composables/useListPage.ts +71 -0
  96. package/src/composables/useListPage.types.ts +6 -0
  97. package/src/composables/useUnsavedChangesGuard.ts +17 -1
  98. package/src/domain/QdBadge.vue +36 -0
  99. package/src/domain/QdDomainBar.vue +213 -0
  100. package/src/domain/QdDomainBarZone.vue +19 -0
  101. package/src/domain/index.ts +6 -0
  102. package/src/domain/registry.ts +122 -0
  103. package/src/favorites/index.ts +7 -0
  104. package/src/favorites/store.ts +172 -0
  105. package/src/favorites/useFavorites.ts +217 -0
  106. package/src/i18n/defaults/core.en.generated.ts +132 -0
  107. package/src/i18n/defaults/core.en.yml +132 -0
  108. package/src/i18n/defaults/core.fr.generated.ts +132 -0
  109. package/src/i18n/defaults/core.fr.yml +132 -0
  110. package/src/index.ts +23 -0
  111. package/src/kernel/Kernel.routing.ts +4 -15
  112. package/src/kernel/Kernel.types.ts +5 -1
  113. package/src/kernel/Kernel.vue.ts +2 -2
  114. package/src/kernel/KernelContext.routing.ts +10 -1
  115. package/src/kernel/KernelContext.ts +7 -0
  116. package/src/kernel/KernelContext.types.ts +2 -0
  117. package/src/kernel/homeRoute.ts +45 -0
  118. package/src/module/moduleRegistry.ts +4 -0
  119. package/src/run/index.ts +6 -0
  120. package/src/run/run.ts +162 -0
  121. package/src/run/useRun.ts +207 -0
  122. package/src/styles/_cards-dashboard.scss +190 -0
  123. package/src/styles/_qd-board.scss +359 -0
  124. package/src/styles/_qd-cards.scss +1197 -0
  125. package/src/styles/_qd-domain-bar.scss +159 -0
  126. package/src/styles/_qd-run.scss +135 -0
  127. package/src/styles/index.scss +4 -0
  128. package/src/zones/ZoneRegistry.ts +16 -0
  129. package/src/zones/index.ts +1 -0
@@ -109,6 +109,8 @@ import { useListFilters } from './useListPage.filters'
109
109
  import { useListAlterHooks } from './useListPage.alterHooks'
110
110
  import { useOrchestrator } from '../orchestrator/useOrchestrator.js'
111
111
  import { createOrchestratorToast } from './useOrchestratorToast'
112
+ import { useRun } from '../run/useRun'
113
+ import type { RunInit } from '../run/run'
112
114
 
113
115
  // Re-export PAGE_SIZE_OPTIONS so existing consumers (qdadm/index.ts,
114
116
  // composables/index.ts) keep their import path.
@@ -1029,17 +1031,83 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1029
1031
  }
1030
1032
 
1031
1033
  function goToEdit(item: unknown): void {
1034
+ if (openInRun('edit', item)) return
1032
1035
  pushNamedRoute(`${routePrefix}-edit`, {
1033
1036
  [manager.idField]: (item as Record<string, unknown>)[resolvedDataKey] as string,
1034
1037
  })
1035
1038
  }
1036
1039
 
1037
1040
  function goToShow(item: unknown): void {
1041
+ if (openInRun('show', item)) return
1038
1042
  pushNamedRoute(`${routePrefix}-show`, {
1039
1043
  [manager.idField]: (item as Record<string, unknown>)[resolvedDataKey] as string,
1040
1044
  })
1041
1045
  }
1042
1046
 
1047
+ // ============ RUNS (#5343) ============
1048
+
1049
+ const run = useRun()
1050
+
1051
+ /** The list's filter, in words: the values chosen, and the search */
1052
+ function filterText(): string | undefined {
1053
+ const parts: string[] = []
1054
+ for (const [name, def] of filtersMap.value.entries()) {
1055
+ const value = filterValues.value[name]
1056
+ if (value === null || value === undefined || value === '' || value === (def.default ?? null)) continue
1057
+ const values = Array.isArray(value) ? value : [value]
1058
+ parts.push(values.map((v) => String(def.options?.find((o) => o.value === v)?.label ?? v)).join(', '))
1059
+ }
1060
+ if (searchQuery.value) parts.push(`"${searchQuery.value}"`)
1061
+ return parts.length ? parts.join(', ') : undefined
1062
+ }
1063
+
1064
+ /** The list's order, in words: "Title ↑" */
1065
+ function orderText(): string | undefined {
1066
+ if (!sortField.value) return undefined
1067
+ return `${column(sortField.value).header ?? sortField.value} ${sortOrder.value === -1 ? '↓' : '↑'}`
1068
+ }
1069
+
1070
+ /**
1071
+ * A run over the list's rows, in their order, with its filter and order in
1072
+ * words; the route of `start` (or of the first row), or null when the
1073
+ * entity has no such page.
1074
+ */
1075
+ function runRoute(target: 'edit' | 'show', start?: unknown, init: Partial<RunInit> = {}) {
1076
+ const name = `${routePrefix}-${target}`
1077
+ if (!router.hasRoute(name)) return null
1078
+ const ids = (items.value as Array<Record<string, unknown>>).map((row) => String(row[resolvedDataKey]))
1079
+ if (!ids.length) return null
1080
+ const params = { ...(route.params as Record<string, string>) }
1081
+ delete params[manager.idField]
1082
+ return run.startRun({
1083
+ entity,
1084
+ items: ids,
1085
+ filter: filterText(),
1086
+ order: orderText(),
1087
+ route: { name, param: manager.idField, params },
1088
+ ...(start !== undefined ? { start: String((start as Record<string, unknown>)[resolvedDataKey]) } : {}),
1089
+ ...init,
1090
+ })
1091
+ }
1092
+
1093
+ /** Opening a row of a filtered list walks that list (#5343) */
1094
+ function openInRun(target: 'edit' | 'show', item: unknown): boolean {
1095
+ if (!hasActiveFilters.value || items.value.length < 2) return false
1096
+ const to = runRoute(target, item)
1097
+ if (!to) return false
1098
+ router.push(to)
1099
+ return true
1100
+ }
1101
+
1102
+ /**
1103
+ * Walk the list's rows one after the other, from the first: its edit page,
1104
+ * else its show page, with the run bar (#5343)
1105
+ */
1106
+ async function startRun(init: Partial<RunInit> = {}): Promise<void> {
1107
+ const to = runRoute(router.hasRoute(`${routePrefix}-edit`) ? 'edit' : 'show', undefined, init)
1108
+ if (to) await router.push(to)
1109
+ }
1110
+
1043
1111
  // ============ MOBILE ROW TAP ============
1044
1112
 
1045
1113
  function getPrimaryRowAction(): 'edit' | 'show' | null {
@@ -1349,6 +1417,8 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1349
1417
 
1350
1418
  const listProps = computed<ListPageProps>(() => ({
1351
1419
  title: manager.labelPlural,
1420
+ entity,
1421
+ searchLabel: hasActiveFilters.value ? (filterText() ?? null) : null,
1352
1422
  subtitle: config.subtitle !== undefined ? config.subtitle : (manager.description ?? null),
1353
1423
  headerActions: headerActions.value,
1354
1424
  cards: cards.value,
@@ -1497,6 +1567,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
1497
1567
  goToCreate,
1498
1568
  goToEdit,
1499
1569
  goToShow,
1570
+ startRun,
1500
1571
 
1501
1572
  // Mobile row tap
1502
1573
  isMobile,
@@ -324,6 +324,10 @@ export interface UseListPageOptions<T = unknown> {
324
324
  */
325
325
  export interface ListPageProps {
326
326
  title: string | undefined
327
+ /** The entity listed, for its favourites (#5349) */
328
+ entity?: string
329
+ /** The filter in words while one is on: offers "Save this search" (#5349) */
330
+ searchLabel?: string | null
327
331
  subtitle: string | null
328
332
  headerActions: ResolvedHeaderAction[]
329
333
  cards: CardConfig[]
@@ -492,6 +496,8 @@ export interface UseListPageReturn<T = unknown> {
492
496
  goToCreate: () => void
493
497
  goToEdit: (item: unknown) => void
494
498
  goToShow: (item: unknown) => void
499
+ /** Walk the rows one after the other, with the run bar (#5343) */
500
+ startRun: (init?: Partial<import('../run/run').RunInit>) => Promise<void>
495
501
 
496
502
  // Mobile row tap
497
503
  isMobile: Ref<boolean>
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import { onBeforeUnmount, ref, type Ref } from 'vue'
13
- import { onBeforeRouteLeave, type NavigationGuardNext } from 'vue-router'
13
+ import { onBeforeRouteLeave, onBeforeRouteUpdate, type NavigationGuardNext } from 'vue-router'
14
14
 
15
15
  /**
16
16
  * Guard dialog state
@@ -137,6 +137,22 @@ export function useUnsavedChangesGuard(
137
137
  showDialog.value = true
138
138
  })
139
139
 
140
+ // The same page on another record (a run's next item, #5343) leaves this one too
141
+ // (Guarded: a test mocking vue-router may not provide it)
142
+ try {
143
+ onBeforeRouteUpdate((to, from, next) => {
144
+ const sameRecord = JSON.stringify(to.params) === JSON.stringify(from.params)
145
+ if (sameRecord || !dirty.value) {
146
+ next()
147
+ return
148
+ }
149
+ pendingNext.value = next
150
+ showDialog.value = true
151
+ })
152
+ } catch {
153
+ // no router hook to register: nothing to guard
154
+ }
155
+
140
156
  return {
141
157
  dirty,
142
158
  // Dialog state and handlers for custom dialog component
@@ -0,0 +1,36 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * QdBadge (#5389): a number on a pill, like a notification count. Its tone
4
+ * comes from how things stand (critical, watch, or none); it hides at zero and
5
+ * says what it counts to screen readers.
6
+ */
7
+ import { computed } from 'vue'
8
+ import { useI18n } from '../i18n/useI18n'
9
+
10
+ const props = defineProps<{
11
+ count: number | null | undefined
12
+ /** What it counts, for screen readers */
13
+ title?: string
14
+ tone?: 'critical' | 'watch' | null
15
+ }>()
16
+
17
+ const { locale, tOr } = useI18n()
18
+ const shown = computed(() => typeof props.count === 'number' && props.count > 0)
19
+ const text = computed(() => {
20
+ const n = props.count ?? 0
21
+ return n > 99 ? '99+' : new Intl.NumberFormat(locale.value).format(n)
22
+ })
23
+ </script>
24
+
25
+ <template>
26
+ <span
27
+ v-if="shown"
28
+ class="qd-badge"
29
+ :class="tone ? `qd-badge--${tone}` : null"
30
+ :data-tone="tone || 'neutral'"
31
+ :title="title ? tOr('core.domainBar.badge', '{count} — {title}', { count: count!, title }) : undefined"
32
+ >
33
+ <span aria-hidden="true">{{ text }}</span>
34
+ <span class="qd-card-sr">{{ title ? tOr('core.domainBar.badge', '{count} — {title}', { count: count!, title }) : count }}</span>
35
+ </span>
36
+ </template>
@@ -0,0 +1,213 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * QdDomainBar (#5389): the bar on top of every page of a domain. Its title,
4
+ * its navigation (the current entry marked, a badge on each entry that names
5
+ * an indicator) and its indicators: mini cards, each read from its own source
6
+ * and drawn as a pill whose count is a badge.
7
+ *
8
+ * Compact: one line of icons and badges, on its own once the page scrolls, or
9
+ * by the person's choice, kept per account.
10
+ */
11
+ import { computed, onBeforeUnmount, onMounted, ref, watch, type Ref } from 'vue'
12
+ import { RouterLink, useRoute, useRouter, type RouteLocationRaw } from 'vue-router'
13
+ import { useI18n } from '../i18n/useI18n'
14
+ import { useAuth } from '../composables/useAuth'
15
+ import { useAsyncRead } from '../composables/useAsyncRead'
16
+ import { getCard, checkCardInput, resolveCardOptions } from '../cards/registry'
17
+ import type { CardStatus } from '../cards/types'
18
+ import QdBadge from './QdBadge.vue'
19
+ import { badgeTone, type DomainDefinition, type DomainIndicator, type DomainNavEntry } from './registry'
20
+
21
+ const props = defineProps<{ domain: DomainDefinition }>()
22
+
23
+ const { locale, tOr } = useI18n()
24
+ const route = useRoute()
25
+ const router = useRouter()
26
+
27
+ // ── The indicators: each its own read, its own state ──────────────────────────
28
+ interface IndicatorView {
29
+ def: DomainIndicator
30
+ /** The value says more than the badge: a unit, a target, no count, or a zero the badge hides */
31
+ showValue: boolean
32
+ state: 'loading' | 'unreachable' | 'invalid' | 'ready'
33
+ value: string
34
+ count: number | null
35
+ status: CardStatus | null
36
+ reason: string | null
37
+ }
38
+
39
+ function watchIndicator(def: DomainIndicator): Ref<IndicatorView> {
40
+ const read = def.load ? useAsyncRead(() => def.load!()) : null
41
+ let timer: ReturnType<typeof setInterval> | null = null
42
+ if (read && def.refresh && def.refresh > 0) {
43
+ onMounted(() => (timer = setInterval(() => void read.load(), def.refresh! * 1000)))
44
+ onBeforeUnmount(() => timer && clearInterval(timer))
45
+ }
46
+ return computed<IndicatorView>(() => {
47
+ const base = { def, value: '', count: null, status: null, reason: null, showValue: false }
48
+ if (read && !read.ready.value) {
49
+ return read.error.value ? { ...base, state: 'unreachable', reason: read.error.value } : { ...base, state: 'loading' }
50
+ }
51
+ const data = read ? read.data.value : def.data
52
+ const card = getCard(def.card)
53
+ if (!card?.pill) return { ...base, state: 'invalid', reason: `no card type '${def.card}' with a pill` }
54
+ const problems = checkCardInput(card, data, def.options ?? {})
55
+ if (problems.length) return { ...base, state: 'invalid', reason: problems.map((p) => `${p.path}: ${p.message}`).join('; ') }
56
+ const pill = card.pill(data, resolveCardOptions(card.meta, def.options ?? {}), locale.value)
57
+ const status = typeof def.status === 'function' ? def.status(data) ?? null : def.status ?? null
58
+ const plain = pill.count !== null && pill.count > 0 && pill.value === new Intl.NumberFormat(locale.value).format(pill.count)
59
+ return { ...base, state: 'ready', value: pill.value, count: pill.count, status, showValue: !plain }
60
+ })
61
+ }
62
+
63
+ const indicators = (props.domain.indicators ?? []).map(watchIndicator)
64
+ const byId = computed(() => new Map(indicators.map((i) => [i.value.def.id, i.value])))
65
+
66
+ // ── The navigation ────────────────────────────────────────────────────────────
67
+ function targetOf(entry: DomainNavEntry): RouteLocationRaw | null {
68
+ if (entry.to) return entry.to
69
+ if (entry.route && router.hasRoute(entry.route)) return { name: entry.route }
70
+ return null
71
+ }
72
+ const nav = computed(() =>
73
+ (props.domain.nav ?? [])
74
+ .map((entry) => ({ entry, to: targetOf(entry), badge: entry.badge ? byId.value.get(entry.badge) ?? null : null }))
75
+ .filter((n) => n.to !== null)
76
+ )
77
+ /** The current entry: the one whose route is the deepest matched one */
78
+ const current = computed(() => {
79
+ const matched = route.matched.map((r) => r.path)
80
+ let best = -1
81
+ let bestLen = -1
82
+ nav.value.forEach((n, i) => {
83
+ let path: string
84
+ try {
85
+ path = router.resolve(n.to!).matched.at(-1)?.path ?? ''
86
+ } catch {
87
+ return
88
+ }
89
+ if (!path) return
90
+ const hit = matched.some((m) => m === path || m.startsWith(path.endsWith('/') ? path : path + '/'))
91
+ if (hit && path.length > bestLen) {
92
+ best = i
93
+ bestLen = path.length
94
+ }
95
+ })
96
+ return best
97
+ })
98
+
99
+ // ── Compact ───────────────────────────────────────────────────────────────────
100
+ const { user } = useAuth()
101
+ const key = computed(() => {
102
+ const u = user.value as { id?: unknown; username?: unknown } | null
103
+ return `qdadm.domainBar.${props.domain.name}.${String(u?.id ?? u?.username ?? 'anonymous')}.compact`
104
+ })
105
+ function readChoice(): boolean {
106
+ try {
107
+ return globalThis.localStorage?.getItem(key.value) === '1'
108
+ } catch {
109
+ return false
110
+ }
111
+ }
112
+ const chosen = ref(readChoice())
113
+ watch(key, () => (chosen.value = readChoice()))
114
+ function toggle(): void {
115
+ chosen.value = !chosen.value
116
+ try {
117
+ if (chosen.value) globalThis.localStorage?.setItem(key.value, '1')
118
+ else globalThis.localStorage?.removeItem(key.value)
119
+ } catch {
120
+ // Blocked storage: the choice lasts the page
121
+ }
122
+ }
123
+
124
+ // Scrolled past the top: compact on its own, the person's choice untouched
125
+ const sentinel = ref<HTMLElement | null>(null)
126
+ const scrolled = ref(false)
127
+ let observer: IntersectionObserver | null = null
128
+ onMounted(() => {
129
+ if (typeof IntersectionObserver === 'undefined' || !sentinel.value) return
130
+ observer = new IntersectionObserver(([e]) => (scrolled.value = !!e && !e.isIntersecting))
131
+ observer.observe(sentinel.value)
132
+ })
133
+ onBeforeUnmount(() => observer?.disconnect())
134
+ const compact = computed(() => chosen.value || scrolled.value)
135
+
136
+ const label = computed(() => tOr('core.domainBar.label', '{domain}: its pages and indicators', { domain: props.domain.label }))
137
+ function pillTitle(i: IndicatorView): string {
138
+ const title = i.def.title
139
+ if (i.state === 'unreachable') return tOr('core.domainBar.unreachable', '{title}: unreachable ({error})', { title, error: i.reason ?? '' })
140
+ if (i.state === 'invalid') return tOr('core.domainBar.invalid', '{title}: data that does not fit', { title }) + (i.reason ? ` (${i.reason})` : '')
141
+ if (i.state === 'loading') return tOr('core.domainBar.loading', '{title}: loading', { title })
142
+ return `${title}: ${i.value}`
143
+ }
144
+ </script>
145
+
146
+ <template>
147
+ <div ref="sentinel" class="qd-domain-bar-sentinel" aria-hidden="true"></div>
148
+ <section
149
+ class="qd-domain-bar"
150
+ :class="{ 'qd-domain-bar--compact': compact }"
151
+ :aria-label="label"
152
+ :data-domain="domain.name"
153
+ :data-compact="compact ? (chosen ? 'chosen' : 'scrolled') : undefined"
154
+ >
155
+ <component :is="domain.to ? RouterLink : 'span'" :to="domain.to" class="qd-domain-bar-title">
156
+ <i v-if="domain.icon" :class="domain.icon" aria-hidden="true"></i>
157
+ <span class="qd-domain-bar-name">{{ domain.label }}</span>
158
+ </component>
159
+
160
+ <nav v-if="nav.length" class="qd-domain-bar-nav" :aria-label="tOr('core.domainBar.nav', '{domain} pages', { domain: domain.label })">
161
+ <RouterLink
162
+ v-for="(n, i) in nav"
163
+ :key="n.entry.label"
164
+ :to="n.to!"
165
+ class="qd-domain-bar-entry"
166
+ :class="{ 'qd-domain-bar-entry--current': i === current }"
167
+ :aria-current="i === current ? 'page' : undefined"
168
+ :title="compact ? n.entry.label : undefined"
169
+ data-domain-nav
170
+ >
171
+ <i v-if="n.entry.icon" :class="n.entry.icon" aria-hidden="true"></i>
172
+ <span class="qd-domain-bar-entry-label" :class="{ 'qd-card-sr': compact && n.entry.icon }">{{ n.entry.label }}</span>
173
+ <QdBadge v-if="n.badge && n.badge.state === 'ready'" :count="n.badge.count" :title="n.badge.def.title" :tone="badgeTone(n.badge.status)" />
174
+ </RouterLink>
175
+ </nav>
176
+
177
+ <ul v-if="indicators.length" class="qd-domain-bar-indicators" :aria-label="tOr('core.domainBar.indicators', '{domain} indicators', { domain: domain.label })">
178
+ <li
179
+ v-for="ind in indicators"
180
+ :key="ind.value.def.id"
181
+ class="qd-domain-pill"
182
+ :data-indicator="ind.value.def.id"
183
+ :data-state="ind.value.state"
184
+ :data-status="ind.value.status || undefined"
185
+ :title="pillTitle(ind.value)"
186
+ >
187
+ <component :is="ind.value.def.to ? RouterLink : 'span'" :to="ind.value.def.to" class="qd-domain-pill-body">
188
+ <i v-if="ind.value.def.icon" :class="ind.value.def.icon" aria-hidden="true"></i>
189
+ <span class="qd-domain-pill-title" :class="{ 'qd-card-sr': compact && ind.value.def.icon }">{{ ind.value.def.title }}</span>
190
+ <template v-if="ind.value.state === 'ready'">
191
+ <QdBadge v-if="ind.value.count !== null" :count="ind.value.count" :title="ind.value.def.title" :tone="badgeTone(ind.value.status)" />
192
+ <span v-if="ind.value.showValue" class="qd-domain-pill-value" :class="{ 'qd-domain-pill-value--zero': ind.value.count === 0 }">{{ ind.value.value }}</span>
193
+ </template>
194
+ <i v-else-if="ind.value.state === 'loading'" class="pi pi-spin pi-spinner qd-domain-pill-mark" aria-hidden="true"></i>
195
+ <i v-else class="pi pi-exclamation-triangle qd-domain-pill-mark" aria-hidden="true"></i>
196
+ <span v-if="ind.value.state !== 'ready'" class="qd-card-sr">{{ pillTitle(ind.value) }}</span>
197
+ </component>
198
+ </li>
199
+ </ul>
200
+
201
+ <button
202
+ type="button"
203
+ class="qd-domain-bar-toggle"
204
+ :aria-pressed="chosen ? 'true' : 'false'"
205
+ :aria-label="chosen ? tOr('core.domainBar.expand', 'Full bar') : tOr('core.domainBar.compact', 'Compact bar')"
206
+ :title="chosen ? tOr('core.domainBar.expand', 'Full bar') : tOr('core.domainBar.compact', 'Compact bar')"
207
+ data-domain-toggle
208
+ @click="toggle"
209
+ >
210
+ <i :class="chosen ? 'pi pi-window-maximize' : 'pi pi-window-minimize'" aria-hidden="true"></i>
211
+ </button>
212
+ </section>
213
+ </template>
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Where the layouts draw the domain bar (#5389): the `_app:domain-bar` zone,
4
+ * on the pages of a domain only, with QdDomainBar as its default. An app
5
+ * replaces it with a block in that zone; the block receives `domain`.
6
+ */
7
+ import { computed } from 'vue'
8
+ import { useRoute } from 'vue-router'
9
+ import Zone from '../components/layout/Zone.vue'
10
+ import QdDomainBar from './QdDomainBar.vue'
11
+ import { domainOfRoute } from './registry'
12
+
13
+ const route = useRoute()
14
+ const domain = computed(() => domainOfRoute(route))
15
+ </script>
16
+
17
+ <template>
18
+ <Zone v-if="domain" :key="domain.name" class="qd-domain-bar-zone" name="_app:domain-bar" :default-component="QdDomainBar" :block-props="{ domain }" />
19
+ </template>
@@ -0,0 +1,6 @@
1
+ /** Domains and their bar (#5389) */
2
+ export { default as QdDomainBar } from './QdDomainBar.vue'
3
+ export { default as QdDomainBarZone } from './QdDomainBarZone.vue'
4
+ export { default as QdBadge } from './QdBadge.vue'
5
+ export { registerDomain, getDomain, listDomains, domainOfRoute, badgeTone } from './registry'
6
+ export type { DomainConfig, DomainDefinition, DomainIndicator, DomainNavEntry } from './registry'
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Domains (#5389): a part of the app with a bar of its own on top of every
3
+ * one of its pages: its navigation and a row of indicators, mini cards each
4
+ * read from its own source, their counts as badges.
5
+ *
6
+ * A page belongs to a domain:
7
+ * 1. when its route says so (`meta.domain`);
8
+ * 2. when its entity is one the domain lists (`entities`), from any module;
9
+ * 3. when the module that declared the domain declared the route too.
10
+ */
11
+ import type { RouteLocationNormalizedLoaded, RouteLocationRaw } from 'vue-router'
12
+ import type { CardStatus } from '../cards/types'
13
+
14
+ /** One permanent indicator: a card of a registered type, drawn as a pill */
15
+ export interface DomainIndicator {
16
+ /** Named by the nav entries that show its badge */
17
+ id: string
18
+ /** The card type (metric, queue, goal, compare, split, or one of the app's) */
19
+ card: string
20
+ /** Its name, read beside the pill and by screen readers */
21
+ title: string
22
+ icon?: string
23
+ /** The data, as the card type takes it */
24
+ data?: unknown
25
+ /** Or read it: called at once, then every `refresh` seconds */
26
+ load?: () => unknown | Promise<unknown>
27
+ /** Seconds between two reads (default: none) */
28
+ refresh?: number
29
+ /** The card type's options */
30
+ options?: Record<string, unknown>
31
+ /** How things stand: fixed, or from the data */
32
+ status?: CardStatus | ((data: unknown) => CardStatus | undefined | null)
33
+ /** Where the pill leads */
34
+ to?: RouteLocationRaw
35
+ }
36
+
37
+ /** One entry of the domain's navigation */
38
+ export interface DomainNavEntry {
39
+ label: string
40
+ icon?: string
41
+ /** A route name, or `to` */
42
+ route?: string
43
+ to?: RouteLocationRaw
44
+ /** The id of the indicator whose count shows as this entry's badge */
45
+ badge?: string
46
+ }
47
+
48
+ /** What `ctx.domain(name, …)` declares */
49
+ export interface DomainConfig {
50
+ label: string
51
+ icon?: string
52
+ /** Where the domain's title leads (its board) */
53
+ to?: RouteLocationRaw
54
+ nav?: DomainNavEntry[]
55
+ indicators?: DomainIndicator[]
56
+ /** Entities of other modules whose pages join the domain */
57
+ entities?: string[]
58
+ }
59
+
60
+ export interface DomainDefinition extends DomainConfig {
61
+ name: string
62
+ /** The module that declared it: its routes join the domain */
63
+ module: string | null
64
+ }
65
+
66
+ const domains = new Map<string, DomainDefinition>()
67
+
68
+ export function registerDomain(name: string, config: DomainConfig, module: string | null = null): void {
69
+ if (!name) throw new Error('[qdadm] domain: a domain needs a name')
70
+ if (domains.has(name)) console.warn(`[qdadm] domain('${name}'): replaces the domain already declared`)
71
+ const ids = new Set<string>()
72
+ for (const i of config.indicators ?? []) {
73
+ if (ids.has(i.id)) console.warn(`[qdadm] domain('${name}'): two indicators are named '${i.id}'`)
74
+ ids.add(i.id)
75
+ }
76
+ for (const n of config.nav ?? []) {
77
+ if (n.badge && !ids.has(n.badge)) console.warn(`[qdadm] domain('${name}'): the entry '${n.label}' shows the badge of '${n.badge}', which no indicator is`)
78
+ }
79
+ domains.set(name, { ...config, name, module })
80
+ }
81
+
82
+ export function getDomain(name: string): DomainDefinition | null {
83
+ return domains.get(name) ?? null
84
+ }
85
+
86
+ export function listDomains(): DomainDefinition[] {
87
+ return [...domains.values()]
88
+ }
89
+
90
+ /** Tests only */
91
+ export function resetDomains(): void {
92
+ domains.clear()
93
+ }
94
+
95
+ type RouteLike = Pick<RouteLocationNormalizedLoaded, 'meta' | 'matched'>
96
+
97
+ /**
98
+ * The domain a route belongs to, or null. `meta.domain: false` keeps a page
99
+ * out of its module's domain.
100
+ */
101
+ export function domainOfRoute(route: RouteLike | null | undefined): DomainDefinition | null {
102
+ if (!route || domains.size === 0) return null
103
+ const meta = route.meta ?? {}
104
+ if (meta.domain === false) return null
105
+ if (typeof meta.domain === 'string') return getDomain(meta.domain)
106
+ const entity = typeof meta.entity === 'string' ? meta.entity : null
107
+ if (entity) {
108
+ for (const d of domains.values()) if (d.entities?.includes(entity)) return d
109
+ }
110
+ // The deepest matched route with a module wins (a frame route's children carry theirs)
111
+ const modules = (route.matched ?? []).map((r) => r.meta?.module).filter((m): m is string => typeof m === 'string')
112
+ const module = modules.at(-1) ?? (typeof meta.module === 'string' ? meta.module : null)
113
+ if (module) {
114
+ for (const d of domains.values()) if (d.module === module) return d
115
+ }
116
+ return null
117
+ }
118
+
119
+ /** The tone of a badge: only bad news is coloured */
120
+ export function badgeTone(status: CardStatus | null | undefined): 'critical' | 'watch' | null {
121
+ return status === 'critical' || status === 'watch' ? status : null
122
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Favourites and recents (#5349): the star, "Save this search", and what was seen lately.
3
+ */
4
+ export { useFavorites, useRecent, type UseFavoritesReturn, type UseRecentReturn } from './useFavorites'
5
+ export { RECENT_MAX, resetFavoriteLists, configureFavorites, getFavoritesConfig, type Favorite, type RecentItem, type FavoritesOptions, type FavoritesManager } from './store'
6
+ export { default as QdFavoriteStar } from '../components/layout/QdFavoriteStar.vue'
7
+ export { default as QdSaveSearch } from '../components/lists/QdSaveSearch.vue'