@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
@@ -2,47 +2,123 @@
2
2
  * useCardsArrangement — the user's arrangement of a card dashboard (#4320):
3
3
  * order, hidden, pinned, kept per dashboard and per user in a storage the app
4
4
  * may provide (#4338: the server, per account); localStorage by default.
5
+ * Since #5348: cards added from a repeatable block with their parameters
6
+ * (instances), the size each person picks, named sections.
5
7
  *
6
8
  * The saved arrangement is reconciled with the cards the app declares on every
7
9
  * load: unknown ids are dropped, a new card takes its default place, a
8
- * required card is never hidden, a fixed card keeps its default place.
10
+ * required card is never hidden, a fixed card keeps its default place, an
11
+ * instance whose block is gone or whose parameters no longer fit is dropped.
9
12
  *
10
13
  * The functions are pure; the composable wraps them with a ref and storage.
11
14
  */
12
15
  import { computed, onScopeDispose, ref, watch, type ComputedRef, type Ref } from 'vue'
13
- import type { BlockCard } from '../zones/ZoneRegistry'
16
+ import type { BlockCard, CardSizeName } from '../zones/ZoneRegistry'
17
+ import { validateCardData } from '../cards/validate'
14
18
 
15
- /** A card as the dashboard knows it: its id and its declaration, in default order. */
19
+ /**
20
+ * A card as the dashboard knows it: its id and its declaration, in default
21
+ * order. A repeatable block is declared too (`card.repeatable`): it is not
22
+ * shown, it is what instances are added from.
23
+ */
16
24
  export interface CardDef {
17
25
  id: string
18
26
  card: BlockCard & { title: string }
27
+ /** An instance: the repeatable block it comes from, and its parameters */
28
+ block?: string
29
+ params?: Record<string, unknown>
30
+ }
31
+
32
+ /** A card added from a repeatable block, with its parameters */
33
+ export interface CardInstance {
34
+ id: string
35
+ block: string
36
+ params: Record<string, unknown>
37
+ /** Its own title; default the block's */
38
+ title?: string
39
+ }
40
+
41
+ export interface CardsSection {
42
+ id: string
43
+ title: string
19
44
  }
20
45
 
21
46
  export interface CardsArrangement {
22
- v: 1
47
+ v: 2
23
48
  /** Every known card, hidden ones included: a restored card comes back where it was */
24
49
  order: string[]
25
50
  hidden: string[]
26
51
  pinned: string[]
52
+ /** The size each person picked, by card */
53
+ sizes: Record<string, CardSizeName>
54
+ /** Named sections, in order; none: one unnamed group, as before */
55
+ sections: CardsSection[]
56
+ /** The section of each card; a card without one is in the first */
57
+ sectionOf: Record<string, string>
58
+ instances: CardInstance[]
59
+ }
60
+
61
+ export interface CardsSectionGroup {
62
+ /** null: the one unnamed group of a board without sections */
63
+ section: CardsSection | null
64
+ cards: CardDef[]
27
65
  }
28
66
 
29
67
  export interface CardsGroups {
30
68
  pinned: CardDef[]
31
69
  rest: CardDef[]
32
70
  hidden: CardDef[]
71
+ /** `rest`, by section */
72
+ sections: CardsSectionGroup[]
73
+ }
74
+
75
+ export const CARDS_ARRANGEMENT_VERSION = 2
76
+
77
+ export const CARD_SIZES: readonly CardSizeName[] = ['s', 'm', 'l']
78
+ const SPAN: Record<CardSizeName, number> = { s: 1, m: 2, l: 3 }
79
+
80
+ /** Migrations from an older saved version to the next */
81
+ const MIGRATIONS: Record<number, (old: Record<string, unknown>) => Record<string, unknown>> = {
82
+ // v1 had order, hidden, pinned: nothing else to carry over
83
+ 1: (old) => ({ ...old, v: 2, sizes: {}, sections: [], sectionOf: {}, instances: [] }),
33
84
  }
34
85
 
35
- export const CARDS_ARRANGEMENT_VERSION = 1
86
+ /** The sizes a card may take */
87
+ export function cardSizes(c: CardDef): CardSizeName[] {
88
+ const allowed = (c.card.sizes ?? CARD_SIZES).filter((s) => CARD_SIZES.includes(s))
89
+ return allowed.length ? allowed : [...CARD_SIZES]
90
+ }
36
91
 
37
- /** Migrations from an older saved version to the next; none yet. */
38
- const MIGRATIONS: Record<number, (old: Record<string, unknown>) => Record<string, unknown>> = {}
92
+ /** Columns a card spans: the size picked, else its declared span */
93
+ export function cardSpan(arrangement: CardsArrangement, c: CardDef): number {
94
+ const size = arrangement.sizes[c.id]
95
+ if (size && cardSizes(c).includes(size)) return SPAN[size]
96
+ return Math.max(1, Math.min(3, Math.round(c.card.span ?? 1)))
97
+ }
98
+
99
+ /** The cards shown or hidden: the declared ones, without the repeatable blocks, then the instances */
100
+ export function effectiveCards(arrangement: Pick<CardsArrangement, 'instances'>, cards: CardDef[]): CardDef[] {
101
+ const templates = new Map(cards.filter((c) => c.card.repeatable).map((c) => [c.id, c]))
102
+ const instances = (arrangement.instances ?? []).flatMap((inst): CardDef[] => {
103
+ const t = templates.get(inst.block)
104
+ if (!t) return []
105
+ const { repeatable: _r, params: _p, required: _q, fixed: _f, pinned: _n, ...rest } = t.card
106
+ return [{ id: inst.id, card: { ...rest, title: inst.title || t.card.title }, block: t.id, params: inst.params }]
107
+ })
108
+ return [...cards.filter((c) => !c.card.repeatable), ...instances]
109
+ }
39
110
 
40
111
  export function defaultArrangement(cards: CardDef[]): CardsArrangement {
112
+ const shown = cards.filter((c) => !c.card.repeatable)
41
113
  return {
42
- v: 1,
43
- order: cards.map((c) => c.id),
114
+ v: 2,
115
+ order: shown.map((c) => c.id),
44
116
  hidden: [],
45
- pinned: cards.filter((c) => c.card.pinned).map((c) => c.id),
117
+ pinned: shown.filter((c) => c.card.pinned).map((c) => c.id),
118
+ sizes: {},
119
+ sections: [],
120
+ sectionOf: {},
121
+ instances: [],
46
122
  }
47
123
  }
48
124
 
@@ -56,26 +132,55 @@ function placeFixed(order: string[], cards: CardDef[]): string[] {
56
132
  return out
57
133
  }
58
134
 
135
+ const isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v)
136
+
137
+ /** The instances still worth keeping: their block is there, their parameters fit its schema */
138
+ function keptInstances(list: unknown, cards: CardDef[]): CardInstance[] {
139
+ if (!Array.isArray(list)) return []
140
+ const templates = new Map(cards.filter((c) => c.card.repeatable).map((c) => [c.id, c]))
141
+ const seen = new Set(cards.map((c) => c.id))
142
+ const kept: CardInstance[] = []
143
+ for (const raw of list) {
144
+ if (!isRecord(raw) || typeof raw.id !== 'string' || typeof raw.block !== 'string' || seen.has(raw.id)) continue
145
+ const t = templates.get(raw.block)
146
+ if (!t) continue
147
+ const params = isRecord(raw.params) ? raw.params : {}
148
+ if (t.card.params) {
149
+ const problems = validateCardData(params, t.card.params, 'params')
150
+ if (problems.length) {
151
+ console.warn(`[qdadm] CardsDashboard: card "${raw.id}" dropped, its parameters no longer fit "${raw.block}": ${problems[0]!.path} ${problems[0]!.message}`)
152
+ continue
153
+ }
154
+ }
155
+ seen.add(raw.id)
156
+ kept.push({ id: raw.id, block: raw.block, params, ...(typeof raw.title === 'string' && raw.title ? { title: raw.title } : {}) })
157
+ }
158
+ return kept
159
+ }
160
+
59
161
  /** Bring a saved arrangement (any shape, any version) in line with the declared cards. */
60
162
  export function reconcileArrangement(saved: unknown, cards: CardDef[]): CardsArrangement {
61
163
  const fallback = defaultArrangement(cards)
62
- let data = saved && typeof saved === 'object' ? (saved as Record<string, unknown>) : null
164
+ let data = isRecord(saved) ? saved : null
63
165
  if (!data) return fallback
64
166
  for (let v = Number(data.v); v < CARDS_ARRANGEMENT_VERSION && MIGRATIONS[v]; v = Number(data.v)) data = MIGRATIONS[v]!(data)
65
167
  if (data.v !== CARDS_ARRANGEMENT_VERSION) return fallback
66
168
 
67
- const byId = new Map(cards.map((c) => [c.id, c]))
169
+ const instances = keptInstances(data.instances, cards)
170
+ const all = effectiveCards({ instances }, cards)
171
+ const instanceIds = new Set(instances.map((i) => i.id))
172
+ const byId = new Map(all.map((c) => [c.id, c]))
68
173
  const ids = (list: unknown): string[] => (Array.isArray(list) ? list.filter((id): id is string => typeof id === 'string' && byId.has(id)) : [])
69
174
  const savedOrder = [...new Set(ids(data.order))]
70
175
  const known = new Set(savedOrder)
71
176
 
72
177
  // A new card goes after its nearest earlier neighbour in the default order
73
178
  const order = [...savedOrder]
74
- cards.forEach((c, i) => {
179
+ all.forEach((c, i) => {
75
180
  if (known.has(c.id)) return
76
- let at = 0
77
- for (let j = i - 1; j >= 0; j--) {
78
- const k = order.indexOf(cards[j]!.id)
181
+ let at = instanceIds.has(c.id) ? order.length : 0
182
+ for (let j = i - 1; j >= 0 && !instanceIds.has(c.id); j--) {
183
+ const k = order.indexOf(all[j]!.id)
79
184
  if (k !== -1) {
80
185
  at = k + 1
81
186
  break
@@ -87,27 +192,75 @@ export function reconcileArrangement(saved: unknown, cards: CardDef[]): CardsArr
87
192
  const hidden = ids(data.hidden).filter((id) => !byId.get(id)!.card.required)
88
193
  // A fixed card keeps its declared pin; a new card takes its default
89
194
  const pinned = new Set(ids(data.pinned).filter((id) => !byId.get(id)!.card.fixed))
90
- for (const c of cards) if (c.card.pinned && (c.card.fixed || !known.has(c.id))) pinned.add(c.id)
91
- return { v: 1, order: placeFixed(order, cards), hidden: [...new Set(hidden)], pinned: order.filter((id) => pinned.has(id)) }
195
+ for (const c of all) if (c.card.pinned && (c.card.fixed || !known.has(c.id))) pinned.add(c.id)
196
+
197
+ const sizes: Record<string, CardSizeName> = {}
198
+ if (isRecord(data.sizes)) {
199
+ for (const [id, size] of Object.entries(data.sizes)) {
200
+ const c = byId.get(id)
201
+ if (c && cardSizes(c).includes(size as CardSizeName)) sizes[id] = size as CardSizeName
202
+ }
203
+ }
204
+ const sections: CardsSection[] = []
205
+ if (Array.isArray(data.sections)) {
206
+ for (const s of data.sections) {
207
+ if (isRecord(s) && typeof s.id === 'string' && typeof s.title === 'string' && !sections.some((x) => x.id === s.id)) sections.push({ id: s.id, title: s.title })
208
+ }
209
+ }
210
+ const sectionIds = new Set(sections.map((s) => s.id))
211
+ const sectionOf: Record<string, string> = {}
212
+ if (isRecord(data.sectionOf)) {
213
+ for (const [id, sid] of Object.entries(data.sectionOf)) if (byId.has(id) && typeof sid === 'string' && sectionIds.has(sid)) sectionOf[id] = sid
214
+ }
215
+
216
+ return {
217
+ v: 2,
218
+ order: placeFixed(order, all),
219
+ hidden: [...new Set(hidden)],
220
+ pinned: order.filter((id) => pinned.has(id)),
221
+ sizes,
222
+ sections,
223
+ sectionOf,
224
+ instances,
225
+ }
226
+ }
227
+
228
+ /** The section a card is in: its own, else the first; null on a board without sections */
229
+ export function sectionOfCard(arrangement: CardsArrangement, id: string): string | null {
230
+ const own = arrangement.sectionOf[id]
231
+ if (own && arrangement.sections.some((s) => s.id === own)) return own
232
+ return arrangement.sections[0]?.id ?? null
92
233
  }
93
234
 
94
235
  export function groupCards(arrangement: CardsArrangement, cards: CardDef[]): CardsGroups {
95
- const byId = new Map(cards.map((c) => [c.id, c]))
236
+ const all = effectiveCards(arrangement, cards)
237
+ const byId = new Map(all.map((c) => [c.id, c]))
96
238
  const hidden = new Set(arrangement.hidden)
97
239
  const pinned = new Set(arrangement.pinned)
98
240
  const inOrder = arrangement.order.map((id) => byId.get(id)).filter((c): c is CardDef => !!c)
241
+ const rest = inOrder.filter((c) => !pinned.has(c.id) && !hidden.has(c.id))
242
+ const sections: CardsSectionGroup[] = arrangement.sections.length
243
+ ? arrangement.sections.map((section) => ({ section, cards: rest.filter((c) => sectionOfCard(arrangement, c.id) === section.id) }))
244
+ : [{ section: null, cards: rest }]
99
245
  return {
100
246
  pinned: inOrder.filter((c) => pinned.has(c.id) && !hidden.has(c.id)),
101
- rest: inOrder.filter((c) => !pinned.has(c.id) && !hidden.has(c.id)),
247
+ rest,
102
248
  hidden: inOrder.filter((c) => hidden.has(c.id)),
249
+ sections,
103
250
  }
104
251
  }
105
252
 
106
- /** The visible group a card is in, as ids. */
253
+ /** The visible group a card moves in, as ids: the pinned ones, or its section */
107
254
  function groupOf(arrangement: CardsArrangement, cards: CardDef[], id: string): string[] {
108
255
  const g = groupCards(arrangement, cards)
109
- const group = g.pinned.some((c) => c.id === id) ? g.pinned : g.rest
110
- return group.map((c) => c.id)
256
+ if (g.pinned.some((c) => c.id === id)) return g.pinned.map((c) => c.id)
257
+ return (g.sections.find((s) => s.cards.some((c) => c.id === id))?.cards ?? []).map((c) => c.id)
258
+ }
259
+
260
+ /** The cards a card moves among, as the dashboard shows them */
261
+ export function cardGroup(arrangement: CardsArrangement, cards: CardDef[], id: string): CardDef[] {
262
+ const byId = new Map(effectiveCards(arrangement, cards).map((c) => [c.id, c]))
263
+ return groupOf(arrangement, cards, id).map((gid) => byId.get(gid)!)
111
264
  }
112
265
 
113
266
  /**
@@ -116,7 +269,7 @@ function groupOf(arrangement: CardsArrangement, cards: CardDef[], id: string): s
116
269
  * nothing moves.
117
270
  */
118
271
  export function moveCard(arrangement: CardsArrangement, cards: CardDef[], id: string, toIndex: number): CardsArrangement {
119
- const byId = new Map(cards.map((c) => [c.id, c]))
272
+ const byId = new Map(effectiveCards(arrangement, cards).map((c) => [c.id, c]))
120
273
  if (byId.get(id)?.card.fixed) return arrangement
121
274
  const group = groupOf(arrangement, cards, id)
122
275
  const from = group.indexOf(id)
@@ -137,22 +290,111 @@ export function moveCard(arrangement: CardsArrangement, cards: CardDef[], id: st
137
290
  }
138
291
 
139
292
  export function setPinned(arrangement: CardsArrangement, cards: CardDef[], id: string, pinned: boolean): CardsArrangement {
140
- const card = cards.find((c) => c.id === id)
293
+ const all = effectiveCards(arrangement, cards)
294
+ const card = all.find((c) => c.id === id)
141
295
  if (!card || card.card.fixed || arrangement.pinned.includes(id) === pinned) return arrangement
142
296
  // It joins the end of its new group
143
297
  const order = [...arrangement.order.filter((oid) => oid !== id), id]
144
298
  const pinnedSet = new Set(arrangement.pinned)
145
299
  if (pinned) pinnedSet.add(id)
146
300
  else pinnedSet.delete(id)
147
- return { ...arrangement, order: placeFixed(order, cards), pinned: order.filter((oid) => pinnedSet.has(oid)) }
301
+ return { ...arrangement, order: placeFixed(order, all), pinned: order.filter((oid) => pinnedSet.has(oid)) }
148
302
  }
149
303
 
150
304
  export function setHidden(arrangement: CardsArrangement, cards: CardDef[], id: string, hidden: boolean): CardsArrangement {
151
- const card = cards.find((c) => c.id === id)
305
+ const card = effectiveCards(arrangement, cards).find((c) => c.id === id)
152
306
  if (!card || (hidden && card.card.required) || arrangement.hidden.includes(id) === hidden) return arrangement
153
307
  return { ...arrangement, hidden: hidden ? [...arrangement.hidden, id] : arrangement.hidden.filter((h) => h !== id) }
154
308
  }
155
309
 
310
+ /** The size a person picked for a card, among the ones it allows; null: back to its default */
311
+ export function setSize(arrangement: CardsArrangement, cards: CardDef[], id: string, size: CardSizeName | null): CardsArrangement {
312
+ const card = effectiveCards(arrangement, cards).find((c) => c.id === id)
313
+ if (!card || (size && !cardSizes(card).includes(size)) || (arrangement.sizes[id] ?? null) === size) return arrangement
314
+ const sizes = { ...arrangement.sizes }
315
+ if (size) sizes[id] = size
316
+ else delete sizes[id]
317
+ return { ...arrangement, sizes }
318
+ }
319
+
320
+ const newId = (prefix: string, taken: Set<string>): string => {
321
+ let id: string
322
+ do id = `${prefix}${Math.random().toString(36).slice(2, 8)}`
323
+ while (taken.has(id))
324
+ return id
325
+ }
326
+
327
+ /** A card added from a repeatable block, at the end of a section (default the first) */
328
+ export function addInstance(
329
+ arrangement: CardsArrangement,
330
+ cards: CardDef[],
331
+ block: string,
332
+ params: Record<string, unknown>,
333
+ { title, section }: { title?: string; section?: string | null } = {}
334
+ ): { arrangement: CardsArrangement; id: string | null } {
335
+ const template = cards.find((c) => c.id === block && c.card.repeatable)
336
+ if (!template) return { arrangement, id: null }
337
+ if (template.card.params && validateCardData(params, template.card.params, 'params').length) return { arrangement, id: null }
338
+ const id = newId(`${block}~`, new Set([...cards.map((c) => c.id), ...arrangement.order]))
339
+ const sectionOf = { ...arrangement.sectionOf }
340
+ const sid = section && arrangement.sections.some((s) => s.id === section) ? section : null
341
+ if (sid) sectionOf[id] = sid
342
+ return {
343
+ id,
344
+ arrangement: {
345
+ ...arrangement,
346
+ order: [...arrangement.order, id],
347
+ instances: [...arrangement.instances, { id, block, params: { ...params }, ...(title ? { title } : {}) }],
348
+ sectionOf,
349
+ },
350
+ }
351
+ }
352
+
353
+ /** An added card, gone for good */
354
+ export function removeInstance(arrangement: CardsArrangement, id: string): CardsArrangement {
355
+ if (!arrangement.instances.some((i) => i.id === id)) return arrangement
356
+ const { [id]: _size, ...sizes } = arrangement.sizes
357
+ const { [id]: _section, ...sectionOf } = arrangement.sectionOf
358
+ return {
359
+ ...arrangement,
360
+ order: arrangement.order.filter((o) => o !== id),
361
+ hidden: arrangement.hidden.filter((o) => o !== id),
362
+ pinned: arrangement.pinned.filter((o) => o !== id),
363
+ instances: arrangement.instances.filter((i) => i.id !== id),
364
+ sizes,
365
+ sectionOf,
366
+ }
367
+ }
368
+
369
+ /** A new named section, at the end */
370
+ export function addSection(arrangement: CardsArrangement, title: string): { arrangement: CardsArrangement; id: string } {
371
+ const id = newId('section-', new Set(arrangement.sections.map((s) => s.id)))
372
+ return { id, arrangement: { ...arrangement, sections: [...arrangement.sections, { id, title }] } }
373
+ }
374
+
375
+ export function renameSection(arrangement: CardsArrangement, id: string, title: string): CardsArrangement {
376
+ if (!arrangement.sections.some((s) => s.id === id && s.title !== title)) return arrangement
377
+ return { ...arrangement, sections: arrangement.sections.map((s) => (s.id === id ? { ...s, title } : s)) }
378
+ }
379
+
380
+ /** A section gone: its cards go back to the first section */
381
+ export function removeSection(arrangement: CardsArrangement, id: string): CardsArrangement {
382
+ if (!arrangement.sections.some((s) => s.id === id)) return arrangement
383
+ const sectionOf = Object.fromEntries(Object.entries(arrangement.sectionOf).filter(([, sid]) => sid !== id))
384
+ return { ...arrangement, sections: arrangement.sections.filter((s) => s.id !== id), sectionOf }
385
+ }
386
+
387
+ /** Move a card to another section, at its end */
388
+ export function setSection(arrangement: CardsArrangement, cards: CardDef[], id: string, section: string): CardsArrangement {
389
+ const card = effectiveCards(arrangement, cards).find((c) => c.id === id)
390
+ if (!card || card.card.fixed || !arrangement.sections.some((s) => s.id === section) || sectionOfCard(arrangement, id) === section) return arrangement
391
+ return {
392
+ ...arrangement,
393
+ order: [...arrangement.order.filter((o) => o !== id), id],
394
+ sectionOf: { ...arrangement.sectionOf, [id]: section },
395
+ }
396
+ }
397
+
156
398
  /**
157
399
  * Where arrangements are kept (#4338). `load` may answer at once (localStorage)
158
400
  * or with a promise (a server); whatever it gives back is reconciled with the
@@ -205,9 +447,21 @@ export interface UseCardsArrangementReturn {
205
447
  saving: Ref<boolean>
206
448
  /** What is shown differs from what the storage holds */
207
449
  dirty: ComputedRef<boolean>
450
+ /** The cards shown or hidden: the declared ones, then the instances */
451
+ allCards: ComputedRef<CardDef[]>
208
452
  move: (id: string, toIndex: number) => boolean
209
453
  pin: (id: string, pinned: boolean) => boolean
210
454
  hide: (id: string, hidden: boolean) => boolean
455
+ /** The size picked for a card; null: its default */
456
+ resize: (id: string, size: CardSizeName | null) => boolean
457
+ /** Add a card from a repeatable block; its id, or null when the block or the parameters do not fit */
458
+ add: (block: string, params: Record<string, unknown>, options?: { title?: string; section?: string | null }) => string | null
459
+ /** Remove an added card */
460
+ remove: (id: string) => boolean
461
+ addSection: (title: string) => string
462
+ renameSection: (id: string, title: string) => boolean
463
+ removeSection: (id: string) => boolean
464
+ moveToSection: (id: string, section: string) => boolean
211
465
  /** Replace the arrangement without saving (a drag in progress) */
212
466
  preview: (next: CardsArrangement) => void
213
467
  /** Save what is shown; false when the storage failed */
@@ -339,9 +593,25 @@ export function useCardsArrangement(
339
593
  loading,
340
594
  saving,
341
595
  dirty,
596
+ allCards: computed(() => effectiveCards(arrangement.value, cards.value)),
342
597
  move: (id, toIndex) => apply(moveCard(arrangement.value, cards.value, id, toIndex)),
343
598
  pin: (id, pinned) => apply(setPinned(arrangement.value, cards.value, id, pinned)),
344
599
  hide: (id, hidden) => apply(setHidden(arrangement.value, cards.value, id, hidden)),
600
+ resize: (id, size) => apply(setSize(arrangement.value, cards.value, id, size)),
601
+ add: (block, params, opts) => {
602
+ const r = addInstance(arrangement.value, cards.value, block, params, opts)
603
+ if (r.id) apply(r.arrangement)
604
+ return r.id
605
+ },
606
+ remove: (id) => apply(removeInstance(arrangement.value, id)),
607
+ addSection: (title) => {
608
+ const r = addSection(arrangement.value, title)
609
+ apply(r.arrangement)
610
+ return r.id
611
+ },
612
+ renameSection: (id, title) => apply(renameSection(arrangement.value, id, title)),
613
+ removeSection: (id) => apply(removeSection(arrangement.value, id)),
614
+ moveToSection: (id, section) => apply(setSection(arrangement.value, cards.value, id, section)),
345
615
  preview: (next) => {
346
616
  touched = true
347
617
  arrangement.value = next
@@ -55,6 +55,8 @@ import type {
55
55
  PageTitleParts,
56
56
  } from './useEntityItemFormPage.types'
57
57
  import { createOrchestratorToast } from './useOrchestratorToast'
58
+ import { useRun } from '../run/useRun'
59
+ import { useFavorites, useRecent } from '../favorites/useFavorites'
58
60
  import { useActionRegistry } from './useActionRegistry'
59
61
  import { TYPE_MAPPINGS, TYPE_VALIDATORS, snakeCaseToTitle, isEmpty } from './useEntityItemFormPage.types'
60
62
 
@@ -309,6 +311,9 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
309
311
  // Update active stack
310
312
  hydrator.setCurrentData(transformed)
311
313
 
314
+ // The item pages seen lately (#5349): this one, now
315
+ if (route?.path) void recent.record({ entity, itemId: String(entityId.value), label: manager.getEntityLabel(transformed as never) || `#${entityId.value}`, to: route.path })
316
+
312
317
  if (onLoadSuccess) {
313
318
  await onLoadSuccess(transformed as T)
314
319
  }
@@ -329,6 +334,12 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
329
334
  // ============ SUBMIT ============
330
335
 
331
336
  async function submit(andClose = true): Promise<unknown> {
337
+ // In a run (#5343), Save & Close goes to the next item: with nothing to save, straight there
338
+ if (andClose && inRun.value && !dirty.value) {
339
+ await run.doneAndNext()
340
+ return null
341
+ }
342
+
332
343
  // Mark as submitted (shows all errors in UI)
333
344
  submitted.value = true
334
345
 
@@ -397,7 +408,10 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
397
408
  await onSaveSuccess(responseData, andClose)
398
409
  }
399
410
 
400
- if (andClose) {
411
+ if (andClose && inRun.value) {
412
+ // A run (#5343): this item is done, on to the next one still to do
413
+ await run.doneAndNext()
414
+ } else if (andClose) {
401
415
  // Navigate to list route (or previous page)
402
416
  const listRoute = findListRoute()
403
417
  router.push(listRoute as { name: string })
@@ -429,6 +443,17 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
429
443
  }
430
444
  }
431
445
 
446
+ // ============ RECENTS AND FAVOURITES (#5349) ============
447
+
448
+ const recent = useRecent()
449
+ const favorites = useFavorites()
450
+
451
+ // ============ RUN (#5343) ============
452
+
453
+ // The run this page walks, if its URL carries one
454
+ const run = useRun()
455
+ const inRun = computed(() => isEdit.value && run.active.value)
456
+
432
457
  // ============ VALUES SHOWN ONCE (#5319) ============
433
458
 
434
459
  // Component memory only: never in data, the snapshot, a payload or a store
@@ -455,6 +480,10 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
455
480
 
456
481
  try {
457
482
  await manager.delete(entityId.value!)
483
+ // A deleted record leaves the recents and the favourites (#5349)
484
+ void recent.forget(entity, entityId.value!)
485
+ void favorites.forgetItem(entity, entityId.value!)
486
+ if (route?.path) void favorites.forgetPath(route.path)
458
487
  toast.add({
459
488
  severity: 'success',
460
489
  summary: 'Deleted',
@@ -804,7 +833,9 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
804
833
  const { label, andClose = true } = options
805
834
  // The catalogue's, by mode: Create / Update, and & Close (#4686)
806
835
  const saveLabel = () =>
807
- andClose
836
+ andClose && inRun.value
837
+ ? tOr('core.run.saveAndNext', 'Save and go to the next')
838
+ : andClose
808
839
  ? isEdit.value ? tOr('core.actions.updateAndClose', 'Save & Close') : tOr('core.actions.createAndClose', 'Save & Close')
809
840
  : tOr('core.actions.save', 'Save')
810
841
 
@@ -814,7 +845,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
814
845
  severity: andClose ? 'success' : 'primary',
815
846
  onClick: async () => { await submit(andClose) },
816
847
  visible: () => (isEdit.value ? manager.canUpdate() : manager.canCreate()),
817
- disabled: ({ dirty, saving }) => !dirty || saving,
848
+ disabled: ({ dirty, saving }) => (!dirty && !(andClose && inRun.value)) || saving,
818
849
  loading: () => saving.value,
819
850
  })
820
851
  }
@@ -904,6 +935,8 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
904
935
  submitted: submitted.value,
905
936
  guardDialog,
906
937
  revealed: revealed.value,
938
+ entity,
939
+ entityId: entityId.value ?? null,
907
940
  }))
908
941
 
909
942
  const formEvents: FormPageEvents = {
@@ -1012,6 +1045,9 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
1012
1045
  revealed,
1013
1046
  confirmRevealed,
1014
1047
 
1048
+ // The run this page walks (#5343)
1049
+ run,
1050
+
1015
1051
  // Title helpers
1016
1052
  entityLabel,
1017
1053
  pageTitle,
@@ -11,6 +11,7 @@ import type { ParentConfig, EntityManager } from './useEntityItemPage'
11
11
  import type { FieldGroup, GroupDefinition, GroupOptions, MoveFieldPosition } from './useFieldManager'
12
12
  import type { StackHydratorReturn } from '../chain/useStackHydrator'
13
13
  import type { OrchestratorLike } from '../entity/EntityManager.interface'
14
+ import type { UseRunReturn } from '../run/useRun'
14
15
 
15
16
  /**
16
17
  * Orchestrator interface
@@ -112,6 +113,9 @@ export interface PageTitleParts {
112
113
  * Form props for FormPage component
113
114
  */
114
115
  export interface FormPageProps {
116
+ /** The entity and the record, for the favourite (#5349) */
117
+ entity?: string
118
+ entityId?: string | number | null
115
119
  isEdit: boolean
116
120
  mode: 'create' | 'edit'
117
121
  loading: boolean
@@ -379,6 +383,10 @@ export interface UseEntityItemFormPageReturn<T extends Record<string, unknown> =
379
383
  revealed: Ref<RevealedValues | null>
380
384
  confirmRevealed: () => void
381
385
 
386
+ // The run this page walks, if its URL carries `?run=` (#5343): in one,
387
+ // Save & Close saves and opens the next item still to do
388
+ run: UseRunReturn
389
+
382
390
  // Title helpers
383
391
  entityLabel: ComputedRef<string>
384
392
  pageTitle: ComputedRef<string>
@@ -63,6 +63,7 @@ import type { LiveEntityPolicy } from '../entity/EntityManager.types'
63
63
  import type { ButtonSeverity, EntityRecord } from '../types'
64
64
  import { useActionRegistry } from './useActionRegistry'
65
65
  import { useLiveEntity } from './useLiveEntity'
66
+ import { useFavorites, useRecent } from '../favorites/useFavorites'
66
67
 
67
68
  // #1191 — shared structural view (manager tier from useEntityItemPage)
68
69
  type Orchestrator = OrchestratorLike<EntityManager>
@@ -140,6 +141,9 @@ interface PageTitleParts {
140
141
  * Show props for ShowPage component
141
142
  */
142
143
  export interface ShowPageProps {
144
+ /** The entity and the record, for the favourite (#5349) */
145
+ entity?: string
146
+ entityId?: string | number | null
143
147
  loading: boolean
144
148
  title: string
145
149
  titleParts: PageTitleParts
@@ -306,12 +310,24 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
306
310
  lazyResolvedStates.value = newStates
307
311
  }
308
312
 
313
+ // The item pages seen lately (#5349): this one, now
314
+ const recent = useRecent()
315
+ const favorites = useFavorites()
316
+ function rememberSeen(record: T): void {
317
+ if (!route?.path) return
318
+ const id = route.params?.[(manager as { idField?: string }).idField ?? 'id'] ?? null
319
+ if (id === null || Array.isArray(id)) return
320
+ const label = manager.getEntityLabel(record as never) || `#${id}`
321
+ void recent.record({ entity, itemId: String(id), label: String(label), to: route.path })
322
+ }
323
+
309
324
  // Use base composable — wrap onLoadSuccess to run lazy resolvers after entity load
310
325
  const base = useEntityItemPage<T>({
311
326
  entity,
312
327
  loadOnMount,
313
328
  transformLoad,
314
329
  onLoadSuccess: async (entityData) => {
330
+ rememberSeen(entityData)
315
331
  await runLazyResolvers(entityData)
316
332
  if (onLoadSuccess) await onLoadSuccess(entityData)
317
333
  },
@@ -585,6 +601,10 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
585
601
 
586
602
  try {
587
603
  await manager.delete(entityId.value)
604
+ // A deleted record leaves the recents and the favourites (#5349)
605
+ void recent.forget(entity, entityId.value)
606
+ void favorites.forgetItem(entity, entityId.value)
607
+ if (route?.path) void favorites.forgetPath(route.path)
588
608
  orchestrator.toast?.success(`${manager.label || entity} deleted`)
589
609
  goBack()
590
610
  } catch (err) {
@@ -608,6 +628,8 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
608
628
  data: data.value as Record<string, unknown> | null,
609
629
  actions: actions.value,
610
630
  fetchError: error.value,
631
+ entity,
632
+ entityId: entityId.value ?? null,
611
633
  }))
612
634
 
613
635
  const events: ShowPageEvents = {