@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.
- package/dist/node/cards/tools/cardsTool.d.ts +32 -0
- package/dist/node/cards/tools/cardsTool.js +151 -0
- package/dist/node/cards/tools/cli.d.ts +2 -0
- package/dist/node/cards/tools/cli.js +38 -0
- package/dist/node/cards/validate.d.ts +35 -0
- package/dist/node/cards/validate.js +94 -0
- package/dist/styles/qdadm.css +1 -1
- package/package.json +7 -2
- package/src/board/QdBoardBlock.vue +67 -0
- package/src/board/QdDomainBoard.vue +64 -0
- package/src/board/blocks/BreakdownBlock.vue +44 -0
- package/src/board/blocks/KpiBlock.vue +31 -0
- package/src/board/blocks/TimelineBlock.vue +63 -0
- package/src/board/blocks/TopBlock.vue +57 -0
- package/src/board/blocks/schemas.ts +107 -0
- package/src/board/index.ts +31 -0
- package/src/board/registry.ts +33 -0
- package/src/board/types.ts +32 -0
- package/src/cards/QdCard.vue +175 -0
- package/src/cards/QdCardView.vue +53 -0
- package/src/cards/QdCardsGallery.vue +103 -0
- package/src/cards/QdFavoritesCard.vue +50 -0
- package/src/cards/QdRecentCard.vue +44 -0
- package/src/cards/builtin/agenda/AgendaCard.vue +37 -0
- package/src/cards/builtin/agenda/meta.json +60 -0
- package/src/cards/builtin/agenda/schema.json +48 -0
- package/src/cards/builtin/bullet/BulletCard.vue +76 -0
- package/src/cards/builtin/bullet/meta.json +38 -0
- package/src/cards/builtin/bullet/schema.json +18 -0
- package/src/cards/builtin/cards-index.json +1694 -0
- package/src/cards/builtin/compare/CompareCard.vue +47 -0
- package/src/cards/builtin/compare/meta.json +79 -0
- package/src/cards/builtin/compare/schema.json +40 -0
- package/src/cards/builtin/favorites/FavoritesCard.vue +50 -0
- package/src/cards/builtin/favorites/meta.json +33 -0
- package/src/cards/builtin/favorites/schema.json +20 -0
- package/src/cards/builtin/feed/FeedCard.vue +39 -0
- package/src/cards/builtin/feed/meta.json +64 -0
- package/src/cards/builtin/feed/schema.json +54 -0
- package/src/cards/builtin/funnel/FunnelCard.vue +44 -0
- package/src/cards/builtin/funnel/meta.json +53 -0
- package/src/cards/builtin/funnel/schema.json +37 -0
- package/src/cards/builtin/goal/GoalCard.vue +73 -0
- package/src/cards/builtin/goal/meta.json +43 -0
- package/src/cards/builtin/goal/schema.json +12 -0
- package/src/cards/builtin/heat/HeatCard.vue +46 -0
- package/src/cards/builtin/heat/meta.json +101 -0
- package/src/cards/builtin/heat/schema.json +39 -0
- package/src/cards/builtin/index.ts +71 -0
- package/src/cards/builtin/metric/MetricCard.vue +82 -0
- package/src/cards/builtin/metric/meta.json +109 -0
- package/src/cards/builtin/metric/schema.json +35 -0
- package/src/cards/builtin/pills.ts +36 -0
- package/src/cards/builtin/queue/QueueCard.vue +65 -0
- package/src/cards/builtin/queue/meta.json +47 -0
- package/src/cards/builtin/queue/schema.json +32 -0
- package/src/cards/builtin/ranking/RankingCard.vue +37 -0
- package/src/cards/builtin/ranking/meta.json +71 -0
- package/src/cards/builtin/ranking/schema.json +35 -0
- package/src/cards/builtin/recent/RecentCard.vue +41 -0
- package/src/cards/builtin/recent/meta.json +32 -0
- package/src/cards/builtin/recent/schema.json +21 -0
- package/src/cards/builtin/shared.ts +83 -0
- package/src/cards/builtin/split/SplitCard.vue +52 -0
- package/src/cards/builtin/split/meta.json +72 -0
- package/src/cards/builtin/split/schema.json +40 -0
- package/src/cards/builtin/trend/TrendCard.vue +75 -0
- package/src/cards/builtin/trend/meta.json +81 -0
- package/src/cards/builtin/trend/schema.json +58 -0
- package/src/cards/index.ts +29 -0
- package/src/cards/registry.ts +57 -0
- package/src/cards/tools/cardsTool.ts +181 -0
- package/src/cards/tools/cli.ts +35 -0
- package/src/cards/types.ts +111 -0
- package/src/cards/validate.ts +111 -0
- package/src/components/edit/FormActions.vue +9 -5
- package/src/components/edit/FormPage.vue +17 -2
- package/src/components/layout/AppLayout.vue +4 -0
- package/src/components/layout/BaseLayout.vue +4 -0
- package/src/components/layout/CardParamsForm.vue +157 -0
- package/src/components/layout/CardsDashboard.vue +276 -57
- package/src/components/layout/PageHeader.vue +22 -1
- package/src/components/layout/QdFavoriteStar.vue +71 -0
- package/src/components/layout/Zone.vue +2 -1
- package/src/components/lists/ListPage.vue +9 -1
- package/src/components/lists/QdSaveSearch.vue +79 -0
- package/src/components/pages/NotFoundPage.vue +5 -2
- package/src/components/run/QdRunBar.vue +99 -0
- package/src/components/show/ShowPage.vue +10 -1
- package/src/composables/useBreadcrumb.ts +1 -1
- package/src/composables/useCardsArrangement.ts +297 -27
- package/src/composables/useEntityItemFormPage.ts +39 -3
- package/src/composables/useEntityItemFormPage.types.ts +8 -0
- package/src/composables/useEntityItemShowPage.ts +22 -0
- package/src/composables/useListPage.ts +71 -0
- package/src/composables/useListPage.types.ts +6 -0
- package/src/composables/useUnsavedChangesGuard.ts +17 -1
- package/src/domain/QdBadge.vue +36 -0
- package/src/domain/QdDomainBar.vue +213 -0
- package/src/domain/QdDomainBarZone.vue +19 -0
- package/src/domain/index.ts +6 -0
- package/src/domain/registry.ts +122 -0
- package/src/favorites/index.ts +7 -0
- package/src/favorites/store.ts +172 -0
- package/src/favorites/useFavorites.ts +217 -0
- package/src/i18n/defaults/core.en.generated.ts +132 -0
- package/src/i18n/defaults/core.en.yml +132 -0
- package/src/i18n/defaults/core.fr.generated.ts +132 -0
- package/src/i18n/defaults/core.fr.yml +132 -0
- package/src/index.ts +23 -0
- package/src/kernel/Kernel.routing.ts +4 -15
- package/src/kernel/Kernel.types.ts +5 -1
- package/src/kernel/Kernel.vue.ts +2 -2
- package/src/kernel/KernelContext.routing.ts +10 -1
- package/src/kernel/KernelContext.ts +7 -0
- package/src/kernel/KernelContext.types.ts +2 -0
- package/src/kernel/homeRoute.ts +45 -0
- package/src/module/moduleRegistry.ts +4 -0
- package/src/run/index.ts +6 -0
- package/src/run/run.ts +162 -0
- package/src/run/useRun.ts +207 -0
- package/src/styles/_cards-dashboard.scss +190 -0
- package/src/styles/_qd-board.scss +359 -0
- package/src/styles/_qd-cards.scss +1197 -0
- package/src/styles/_qd-domain-bar.scss +159 -0
- package/src/styles/_qd-run.scss +135 -0
- package/src/styles/index.scss +4 -0
- package/src/zones/ZoneRegistry.ts +16 -0
- package/src/zones/index.ts +1 -0
package/src/run/run.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs (#5343): an ordered set of items of one entity, walked one item after
|
|
3
|
+
* the other from its show or form page, with where it came from.
|
|
4
|
+
*
|
|
5
|
+
* A run lives in the tab's sessionStorage under a short key, which the URL
|
|
6
|
+
* carries as `?run=<key>`: a reload keeps it, another tab does not see it.
|
|
7
|
+
* Nothing here knows Vue or the router: `useRun` does the navigation.
|
|
8
|
+
*/
|
|
9
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
10
|
+
|
|
11
|
+
/** One item of a run */
|
|
12
|
+
export interface RunItem {
|
|
13
|
+
/** The item's id, as its route takes it */
|
|
14
|
+
id: string
|
|
15
|
+
/** Shown warm in the strip until it is done */
|
|
16
|
+
urgent?: boolean
|
|
17
|
+
/** What the strip's segment says about it ("575806 · Amazon FR") */
|
|
18
|
+
label?: string
|
|
19
|
+
/** Done since the run started: it leaves what remains */
|
|
20
|
+
done?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The page every item of a run opens on */
|
|
24
|
+
export interface RunRoute {
|
|
25
|
+
/** The route's name, e.g. `book-edit` */
|
|
26
|
+
name: string
|
|
27
|
+
/** The route param holding the item's id, e.g. `id` */
|
|
28
|
+
param: string
|
|
29
|
+
/** The route's other params (a parent's id) */
|
|
30
|
+
params?: Record<string, string>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** What a run is started with */
|
|
34
|
+
export interface RunInit {
|
|
35
|
+
/** The entity the items belong to */
|
|
36
|
+
entity: string
|
|
37
|
+
/** The items, in the order they are walked: ids, or items with their marks */
|
|
38
|
+
items: Array<string | number | (Omit<RunItem, 'id'> & { id: string | number })>
|
|
39
|
+
/** What the items are, after "3 of 14": "to process" */
|
|
40
|
+
label?: string
|
|
41
|
+
/** How they were chosen, in words: "status: to process" */
|
|
42
|
+
filter?: string
|
|
43
|
+
/** How they were ordered, in words: "by urgency" */
|
|
44
|
+
order?: string
|
|
45
|
+
/** Where to go back at the end; by default where the run was started */
|
|
46
|
+
returnTo?: RouteLocationRaw
|
|
47
|
+
/** The page the items open on; by default the entity's edit page, or its show page */
|
|
48
|
+
route?: RunRoute
|
|
49
|
+
/** The item to start with; by default the first one */
|
|
50
|
+
start?: string | number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A run as it is kept */
|
|
54
|
+
export interface Run {
|
|
55
|
+
key: string
|
|
56
|
+
entity: string
|
|
57
|
+
route: RunRoute
|
|
58
|
+
items: RunItem[]
|
|
59
|
+
label?: string
|
|
60
|
+
filter?: string
|
|
61
|
+
order?: string
|
|
62
|
+
returnTo?: RouteLocationRaw
|
|
63
|
+
startedAt: number
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const PREFIX = 'qdadm.run.'
|
|
67
|
+
/** Runs kept per tab: the oldest go first */
|
|
68
|
+
const MAX_RUNS = 20
|
|
69
|
+
|
|
70
|
+
function storage(): Storage | null {
|
|
71
|
+
try {
|
|
72
|
+
return typeof sessionStorage === 'undefined' ? null : sessionStorage
|
|
73
|
+
} catch {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A short key for the URL */
|
|
79
|
+
export function newRunKey(): string {
|
|
80
|
+
return Math.random().toString(36).slice(2, 8)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A run from what it is started with */
|
|
84
|
+
export function createRun(init: RunInit, route: RunRoute, returnTo?: RouteLocationRaw): Run {
|
|
85
|
+
return {
|
|
86
|
+
key: newRunKey(),
|
|
87
|
+
entity: init.entity,
|
|
88
|
+
route,
|
|
89
|
+
items: init.items.map((item) =>
|
|
90
|
+
typeof item === 'object' ? { ...item, id: String(item.id) } : { id: String(item) }
|
|
91
|
+
),
|
|
92
|
+
...(init.label ? { label: init.label } : {}),
|
|
93
|
+
...(init.filter ? { filter: init.filter } : {}),
|
|
94
|
+
...(init.order ? { order: init.order } : {}),
|
|
95
|
+
...(init.returnTo ?? returnTo ? { returnTo: init.returnTo ?? returnTo } : {}),
|
|
96
|
+
startedAt: Date.now(),
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function saveRun(run: Run): void {
|
|
101
|
+
const store = storage()
|
|
102
|
+
if (!store) return
|
|
103
|
+
try {
|
|
104
|
+
store.setItem(PREFIX + run.key, JSON.stringify(run))
|
|
105
|
+
// Keep the tab's storage small: drop the oldest runs
|
|
106
|
+
const keys: Array<{ key: string; at: number }> = []
|
|
107
|
+
for (let i = 0; i < store.length; i++) {
|
|
108
|
+
const key = store.key(i)
|
|
109
|
+
if (!key?.startsWith(PREFIX)) continue
|
|
110
|
+
try {
|
|
111
|
+
keys.push({ key, at: (JSON.parse(store.getItem(key) ?? '{}') as Run).startedAt ?? 0 })
|
|
112
|
+
} catch {
|
|
113
|
+
keys.push({ key, at: 0 })
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
keys.sort((a, b) => b.at - a.at).slice(MAX_RUNS).forEach(({ key }) => store.removeItem(key))
|
|
117
|
+
} catch {
|
|
118
|
+
// A full or blocked storage: the run lasts as long as the page
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function loadRun(key: string | null | undefined): Run | null {
|
|
123
|
+
if (!key) return null
|
|
124
|
+
const store = storage()
|
|
125
|
+
if (!store) return null
|
|
126
|
+
try {
|
|
127
|
+
const raw = store.getItem(PREFIX + key)
|
|
128
|
+
if (!raw) return null
|
|
129
|
+
const run = JSON.parse(raw) as Run
|
|
130
|
+
return Array.isArray(run?.items) && run.route?.name ? run : null
|
|
131
|
+
} catch {
|
|
132
|
+
return null
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function forgetRun(key: string): void {
|
|
137
|
+
try {
|
|
138
|
+
storage()?.removeItem(PREFIX + key)
|
|
139
|
+
} catch {
|
|
140
|
+
// nothing kept, nothing to forget
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Where an item is in the run, or -1 */
|
|
145
|
+
export function runIndexOf(run: Run, id: string | number | null | undefined): number {
|
|
146
|
+
if (id === null || id === undefined) return -1
|
|
147
|
+
return run.items.findIndex((item) => item.id === String(id))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The next item still to do after `from`, going round to the start: null when
|
|
152
|
+
* all are done. `from` -1 looks from the start.
|
|
153
|
+
*/
|
|
154
|
+
export function nextPending(run: Run, from: number): number | null {
|
|
155
|
+
const n = run.items.length
|
|
156
|
+
for (let step = 1; step <= n; step++) {
|
|
157
|
+
const i = (from + step + n) % n
|
|
158
|
+
if (i === from) continue
|
|
159
|
+
if (!run.items[i]!.done) return i
|
|
160
|
+
}
|
|
161
|
+
return from >= 0 && from < n && !run.items[from]!.done ? from : null
|
|
162
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useRun (#5343): the run the current page is walking, if its URL carries
|
|
3
|
+
* `?run=<key>`, and the gestures to walk it.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const run = useRun()
|
|
7
|
+
* // A card's or a list's gesture: open the first item, with the bar
|
|
8
|
+
* await run.start({ entity: 'orders', items: ids, label: 'to process', order: 'by urgency' })
|
|
9
|
+
* // The page's main gesture, once it did its work
|
|
10
|
+
* await run.doneAndNext()
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* `QdRunBar` shows it on show and form pages; a page needs nothing else.
|
|
14
|
+
*/
|
|
15
|
+
import { computed, inject, reactive, ref, watch, type ComputedRef, type Ref } from 'vue'
|
|
16
|
+
import { useRoute, useRouter, type RouteLocationRaw } from 'vue-router'
|
|
17
|
+
import { useI18n } from '../i18n/useI18n'
|
|
18
|
+
import { createOrchestratorToast } from '../composables/useOrchestratorToast'
|
|
19
|
+
import type { Orchestrator } from '../orchestrator/Orchestrator'
|
|
20
|
+
import {
|
|
21
|
+
createRun,
|
|
22
|
+
loadRun,
|
|
23
|
+
nextPending,
|
|
24
|
+
runIndexOf,
|
|
25
|
+
saveRun,
|
|
26
|
+
type Run,
|
|
27
|
+
type RunInit,
|
|
28
|
+
type RunItem,
|
|
29
|
+
type RunRoute,
|
|
30
|
+
} from './run'
|
|
31
|
+
|
|
32
|
+
// One live object per run, shared by every useRun of the tab: the bar sees
|
|
33
|
+
// what the page marks done
|
|
34
|
+
const live = new Map<string, Run>()
|
|
35
|
+
function sharedRun(key: string | null): Run | null {
|
|
36
|
+
if (!key) return null
|
|
37
|
+
const known = live.get(key)
|
|
38
|
+
if (known) return known
|
|
39
|
+
const loaded = loadRun(key)
|
|
40
|
+
if (!loaded) return null
|
|
41
|
+
const shared = reactive(loaded) as Run
|
|
42
|
+
live.set(key, shared)
|
|
43
|
+
return shared
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface UseRunReturn {
|
|
47
|
+
/** The run this page walks, or null */
|
|
48
|
+
run: Ref<Run | null>
|
|
49
|
+
/** Whether this page walks a run and its item is in it */
|
|
50
|
+
active: ComputedRef<boolean>
|
|
51
|
+
/** The item on screen, and where it is */
|
|
52
|
+
current: ComputedRef<RunItem | null>
|
|
53
|
+
index: ComputedRef<number>
|
|
54
|
+
/** 1-based, for "3 of 14" */
|
|
55
|
+
position: ComputedRef<number>
|
|
56
|
+
total: ComputedRef<number>
|
|
57
|
+
doneCount: ComputedRef<number>
|
|
58
|
+
remaining: ComputedRef<number>
|
|
59
|
+
/** The neighbours, done or not, or null at an end */
|
|
60
|
+
prev: ComputedRef<RunItem | null>
|
|
61
|
+
next: ComputedRef<RunItem | null>
|
|
62
|
+
goPrev: () => Promise<void>
|
|
63
|
+
goNext: () => Promise<void>
|
|
64
|
+
goTo: (index: number) => Promise<void>
|
|
65
|
+
/** Mark the item on screen done (or the one given) */
|
|
66
|
+
markDone: (id?: string | number) => void
|
|
67
|
+
/** Mark it done and open the next one still to do; at the end, say so and go back */
|
|
68
|
+
doneAndNext: () => Promise<void>
|
|
69
|
+
/** Leave the run: back where it started */
|
|
70
|
+
end: () => Promise<void>
|
|
71
|
+
/** Start a run and open its first item */
|
|
72
|
+
start: (init: RunInit) => Promise<void>
|
|
73
|
+
/** Start a run and give the route of its first item, without going there */
|
|
74
|
+
startRun: (init: RunInit) => RouteLocationRaw | null
|
|
75
|
+
/** The route of one of the run's items, with the run kept */
|
|
76
|
+
routeOf: (index: number) => RouteLocationRaw | null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function useRun(): UseRunReturn {
|
|
80
|
+
// Without a router (a page mounted on its own, in a test) there is no run
|
|
81
|
+
const route = useRoute() as ReturnType<typeof useRoute> | undefined
|
|
82
|
+
const router = useRouter() as ReturnType<typeof useRouter> | undefined
|
|
83
|
+
const orchestrator = inject<Orchestrator | null>('qdadmOrchestrator', null)
|
|
84
|
+
const toast = createOrchestratorToast(orchestrator)
|
|
85
|
+
const { t } = useI18n()
|
|
86
|
+
|
|
87
|
+
const run = ref<Run | null>(null)
|
|
88
|
+
watch(
|
|
89
|
+
() => route?.query?.run,
|
|
90
|
+
(key) => {
|
|
91
|
+
run.value = sharedRun(typeof key === 'string' ? key : null)
|
|
92
|
+
},
|
|
93
|
+
{ immediate: true }
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const index = computed(() => {
|
|
97
|
+
if (!route || !run.value || route.name !== run.value.route.name) return -1
|
|
98
|
+
return runIndexOf(run.value, route.params?.[run.value.route.param] as string | undefined)
|
|
99
|
+
})
|
|
100
|
+
const active = computed(() => index.value >= 0)
|
|
101
|
+
const current = computed(() => (active.value ? run.value!.items[index.value]! : null))
|
|
102
|
+
const total = computed(() => run.value?.items.length ?? 0)
|
|
103
|
+
const position = computed(() => index.value + 1)
|
|
104
|
+
const doneCount = computed(() => run.value?.items.filter((i) => i.done).length ?? 0)
|
|
105
|
+
const remaining = computed(() => total.value - doneCount.value)
|
|
106
|
+
const prev = computed(() => (active.value && index.value > 0 ? run.value!.items[index.value - 1]! : null))
|
|
107
|
+
const next = computed(() => (active.value && index.value < total.value - 1 ? run.value!.items[index.value + 1]! : null))
|
|
108
|
+
|
|
109
|
+
function routeOf(i: number): RouteLocationRaw | null {
|
|
110
|
+
const r = run.value
|
|
111
|
+
const item = r?.items[i]
|
|
112
|
+
if (!r || !item) return null
|
|
113
|
+
const params = route?.name === r.route.name ? { ...(route.params as Record<string, string>) } : { ...(r.route.params ?? {}) }
|
|
114
|
+
return { name: r.route.name, params: { ...params, [r.route.param]: item.id }, query: { run: r.key } }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function goTo(i: number): Promise<void> {
|
|
118
|
+
const target = routeOf(i)
|
|
119
|
+
if (target) await router?.push(target)
|
|
120
|
+
}
|
|
121
|
+
const goPrev = () => (prev.value ? goTo(index.value - 1) : Promise.resolve())
|
|
122
|
+
const goNext = () => (next.value ? goTo(index.value + 1) : Promise.resolve())
|
|
123
|
+
|
|
124
|
+
function markDone(id?: string | number): void {
|
|
125
|
+
const r = run.value
|
|
126
|
+
if (!r) return
|
|
127
|
+
const i = id === undefined ? index.value : runIndexOf(r, id)
|
|
128
|
+
const item = r.items[i]
|
|
129
|
+
if (!item || item.done) return
|
|
130
|
+
item.done = true
|
|
131
|
+
saveRun(r)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function end(): Promise<void> {
|
|
135
|
+
const r = run.value
|
|
136
|
+
if (!r) return
|
|
137
|
+
run.value = null
|
|
138
|
+
if (r.returnTo) await router?.push(r.returnTo)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function doneAndNext(): Promise<void> {
|
|
142
|
+
const r = run.value
|
|
143
|
+
if (!r) return
|
|
144
|
+
markDone()
|
|
145
|
+
const n = nextPending(r, index.value)
|
|
146
|
+
if (n !== null) return goTo(n)
|
|
147
|
+
toast.add({ severity: 'success', summary: t('core.run.finished', { count: r.items.length }) })
|
|
148
|
+
await end()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The page the entity's items open on: its edit page, else its show page */
|
|
152
|
+
function itemRoute(entity: string): RunRoute | null {
|
|
153
|
+
const manager = orchestrator?.get?.(entity)
|
|
154
|
+
const prefix = manager?.routePrefix
|
|
155
|
+
if (!prefix) return null
|
|
156
|
+
const name = [`${prefix}-edit`, `${prefix}-show`].find((n) => router?.hasRoute(n))
|
|
157
|
+
return name ? { name, param: manager.idField ?? 'id' } : null
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function startRun(init: RunInit): RouteLocationRaw | null {
|
|
161
|
+
const target = init.route ?? itemRoute(init.entity)
|
|
162
|
+
if (!target) {
|
|
163
|
+
console.warn(`[qdadm] useRun: no page to open "${init.entity}" items on; pass route: { name, param }`)
|
|
164
|
+
return null
|
|
165
|
+
}
|
|
166
|
+
// Back where the run was started: this page, without its own run
|
|
167
|
+
const { run: _ownRun, ...query } = route?.query ?? {}
|
|
168
|
+
const here: RouteLocationRaw | undefined = route ? { path: route.path, query } : undefined
|
|
169
|
+
const created = createRun(init, target, here)
|
|
170
|
+
if (!created.items.length) return null
|
|
171
|
+
saveRun(created)
|
|
172
|
+
const shared = reactive(created) as Run
|
|
173
|
+
live.set(created.key, shared)
|
|
174
|
+
run.value = shared
|
|
175
|
+
const first = init.start !== undefined ? runIndexOf(created, init.start) : -1
|
|
176
|
+
const i = first >= 0 ? first : 0
|
|
177
|
+
const item = created.items[i]!
|
|
178
|
+
return { name: target.name, params: { ...(target.params ?? {}), [target.param]: item.id }, query: { run: created.key } }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function start(init: RunInit): Promise<void> {
|
|
182
|
+
const target = startRun(init)
|
|
183
|
+
if (target) await router?.push(target)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
run,
|
|
188
|
+
active,
|
|
189
|
+
current,
|
|
190
|
+
index,
|
|
191
|
+
position,
|
|
192
|
+
total,
|
|
193
|
+
doneCount,
|
|
194
|
+
remaining,
|
|
195
|
+
prev,
|
|
196
|
+
next,
|
|
197
|
+
goPrev,
|
|
198
|
+
goNext,
|
|
199
|
+
goTo,
|
|
200
|
+
markDone,
|
|
201
|
+
doneAndNext,
|
|
202
|
+
end,
|
|
203
|
+
start,
|
|
204
|
+
startRun,
|
|
205
|
+
routeOf,
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -193,3 +193,193 @@
|
|
|
193
193
|
clip: rect(0 0 0 0);
|
|
194
194
|
white-space: nowrap;
|
|
195
195
|
}
|
|
196
|
+
|
|
197
|
+
// ── #5348: sections, size and section choices, the catalogue ───────────────
|
|
198
|
+
|
|
199
|
+
.qd-cards-toolbar {
|
|
200
|
+
flex-wrap: wrap;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.qd-cards-group {
|
|
204
|
+
display: flex;
|
|
205
|
+
flex-direction: column;
|
|
206
|
+
gap: 0.5rem;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.qd-cards-section-head {
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
gap: 0.5rem;
|
|
213
|
+
margin-top: 0.5rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.qd-cards-section-title {
|
|
217
|
+
margin: 0;
|
|
218
|
+
font-size: 1rem;
|
|
219
|
+
font-weight: 600;
|
|
220
|
+
color: var(--p-text-color);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.qd-cards-section-input,
|
|
224
|
+
.qd-card-params input[type='text'],
|
|
225
|
+
.qd-card-params input[type='number'],
|
|
226
|
+
.qd-card-params select {
|
|
227
|
+
height: 2.25rem;
|
|
228
|
+
padding: 0 0.6rem;
|
|
229
|
+
border: 1px solid var(--p-content-border-color, #d1d5db);
|
|
230
|
+
border-radius: var(--p-content-border-radius, 6px);
|
|
231
|
+
background: var(--p-content-background, #fff);
|
|
232
|
+
color: var(--p-text-color);
|
|
233
|
+
font: inherit;
|
|
234
|
+
|
|
235
|
+
&:focus-visible {
|
|
236
|
+
outline: 2px solid var(--p-primary-color);
|
|
237
|
+
outline-offset: 1px;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.qd-cards-section-input {
|
|
242
|
+
width: 100%;
|
|
243
|
+
max-width: 20rem;
|
|
244
|
+
font-weight: 600;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// The bar wraps rather than crush the card's title between its choices
|
|
248
|
+
.qd-cards-bar {
|
|
249
|
+
flex-wrap: wrap;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.qd-cards-bar .qd-cards-title {
|
|
253
|
+
min-width: 6rem;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.qd-cards-size,
|
|
257
|
+
.qd-cards-section {
|
|
258
|
+
max-width: 8rem;
|
|
259
|
+
height: 2rem;
|
|
260
|
+
padding: 0 0.35rem;
|
|
261
|
+
border: 1px solid var(--p-content-border-color, #d1d5db);
|
|
262
|
+
border-radius: var(--p-content-border-radius, 6px);
|
|
263
|
+
background: var(--p-content-background, #fff);
|
|
264
|
+
color: var(--p-text-color);
|
|
265
|
+
font: inherit;
|
|
266
|
+
font-size: 0.8125rem;
|
|
267
|
+
|
|
268
|
+
&:focus-visible {
|
|
269
|
+
outline: 2px solid var(--p-primary-color);
|
|
270
|
+
outline-offset: 1px;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.qd-cards-catalogue {
|
|
275
|
+
display: flex;
|
|
276
|
+
flex-direction: column;
|
|
277
|
+
gap: 0.75rem;
|
|
278
|
+
padding: 1rem;
|
|
279
|
+
border: 1px solid var(--p-content-border-color, #d1d5db);
|
|
280
|
+
border-radius: var(--p-content-border-radius, 6px);
|
|
281
|
+
background: var(--p-content-background, #fff);
|
|
282
|
+
|
|
283
|
+
h2 {
|
|
284
|
+
margin: 0;
|
|
285
|
+
font-size: 1rem;
|
|
286
|
+
font-weight: 600;
|
|
287
|
+
|
|
288
|
+
// Focused by the code when the catalogue opens, for screen readers: no ring
|
|
289
|
+
&:focus {
|
|
290
|
+
outline: none;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
h3 {
|
|
295
|
+
margin: 0;
|
|
296
|
+
font-size: 0.9375rem;
|
|
297
|
+
font-weight: 600;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.qd-cards-catalogue-desc {
|
|
302
|
+
margin: 0;
|
|
303
|
+
color: var(--p-text-muted-color, #6b7280);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.qd-cards-catalogue-list {
|
|
307
|
+
display: grid;
|
|
308
|
+
grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
|
|
309
|
+
gap: 0.5rem;
|
|
310
|
+
margin: 0;
|
|
311
|
+
padding: 0;
|
|
312
|
+
list-style: none;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.qd-cards-catalogue-item {
|
|
316
|
+
display: flex;
|
|
317
|
+
align-items: center;
|
|
318
|
+
justify-content: space-between;
|
|
319
|
+
gap: 0.75rem;
|
|
320
|
+
padding: 0.6rem 0.75rem;
|
|
321
|
+
border: 1px solid var(--p-content-border-color, #d1d5db);
|
|
322
|
+
border-radius: var(--p-content-border-radius, 6px);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.qd-cards-catalogue-text {
|
|
326
|
+
display: flex;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
gap: 0.15rem;
|
|
329
|
+
min-width: 0;
|
|
330
|
+
font-size: 0.875rem;
|
|
331
|
+
|
|
332
|
+
span {
|
|
333
|
+
color: var(--p-text-muted-color, #6b7280);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.qd-cards-catalogue-question {
|
|
338
|
+
font-style: italic;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.qd-card-params {
|
|
342
|
+
display: flex;
|
|
343
|
+
flex-direction: column;
|
|
344
|
+
gap: 0.75rem;
|
|
345
|
+
max-width: 28rem;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.qd-card-params-field {
|
|
349
|
+
display: flex;
|
|
350
|
+
flex-direction: column;
|
|
351
|
+
gap: 0.25rem;
|
|
352
|
+
|
|
353
|
+
label {
|
|
354
|
+
font-weight: 500;
|
|
355
|
+
font-size: 0.875rem;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
&.qd-card-params-check {
|
|
359
|
+
flex-direction: row;
|
|
360
|
+
flex-wrap: wrap;
|
|
361
|
+
align-items: center;
|
|
362
|
+
gap: 0.5rem;
|
|
363
|
+
|
|
364
|
+
small {
|
|
365
|
+
flex-basis: 100%;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.qd-card-params-help {
|
|
371
|
+
color: var(--p-text-muted-color, #6b7280);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.qd-card-params-error {
|
|
375
|
+
color: var(--p-red-600, #b42318);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.dark-mode .qd-card-params-error {
|
|
379
|
+
color: var(--p-red-300, #ff8a7a);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.qd-card-params-actions {
|
|
383
|
+
display: flex;
|
|
384
|
+
gap: 0.5rem;
|
|
385
|
+
}
|