@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Favourites and recents (#5349): what a person follows, and the records they
|
|
3
|
+
* just opened, kept as two entities the app declares, `favorites` and
|
|
4
|
+
* `recents` by default (`configureFavorites` names others), through their
|
|
5
|
+
* EntityManager and storage. Whose they are is the storage's business: a
|
|
6
|
+
* server answers the current user's; a local storage keeps the browser's.
|
|
7
|
+
*
|
|
8
|
+
* What qdadm writes in them:
|
|
9
|
+
* - favorites: `{ kind, label, to, entity?, itemId?, at }`
|
|
10
|
+
* - recents: `{ entity, itemId, label, to, at }`
|
|
11
|
+
* `at` is an ISO date. Any other field the app adds is kept.
|
|
12
|
+
*
|
|
13
|
+
* One live list per entity, shared by every component of the tab: a star
|
|
14
|
+
* clicked in a header shows at once in the favorites card. Without the
|
|
15
|
+
* entity, there is nothing to show: the star and "Save this search" hide,
|
|
16
|
+
* nothing is recorded.
|
|
17
|
+
*/
|
|
18
|
+
import { reactive } from 'vue'
|
|
19
|
+
import { getEntityConfig } from '../module/moduleRegistry'
|
|
20
|
+
|
|
21
|
+
/** A page someone follows */
|
|
22
|
+
export interface Favorite {
|
|
23
|
+
/** The record's id in the favorites entity */
|
|
24
|
+
id: string
|
|
25
|
+
kind: 'item' | 'list' | 'search' | 'board'
|
|
26
|
+
label: string
|
|
27
|
+
/** The page, as a path (with its query for a search) */
|
|
28
|
+
to: string
|
|
29
|
+
entity?: string
|
|
30
|
+
/** A record's favourite: its id, so the show and edit pages share one */
|
|
31
|
+
itemId?: string
|
|
32
|
+
/** When it was added (ISO) */
|
|
33
|
+
at: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A record someone just opened */
|
|
37
|
+
export interface RecentItem {
|
|
38
|
+
/** The record's id in the recents entity */
|
|
39
|
+
id: string
|
|
40
|
+
entity: string
|
|
41
|
+
/** The opened record's id */
|
|
42
|
+
itemId: string
|
|
43
|
+
label: string
|
|
44
|
+
to: string
|
|
45
|
+
/** When it was opened (ISO) */
|
|
46
|
+
at: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const RECENT_MAX = 20
|
|
50
|
+
|
|
51
|
+
export interface FavoritesOptions {
|
|
52
|
+
/** The entity holding the favourites (default 'favorites'); false: none */
|
|
53
|
+
favorites?: string | false
|
|
54
|
+
/** The entity holding the recents (default 'recents'); false: none */
|
|
55
|
+
recents?: string | false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const config: Required<FavoritesOptions> = { favorites: 'favorites', recents: 'recents' }
|
|
59
|
+
|
|
60
|
+
/** Name the entities, once at boot. Later calls merge over earlier ones. */
|
|
61
|
+
export function configureFavorites(options: FavoritesOptions): void {
|
|
62
|
+
Object.assign(config, options)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getFavoritesConfig(): Readonly<Required<FavoritesOptions>> {
|
|
66
|
+
return config
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** What qdadm needs of an entity's manager */
|
|
70
|
+
export interface FavoritesManager {
|
|
71
|
+
list(params?: Record<string, unknown>): Promise<{ items: Array<Record<string, unknown>> }>
|
|
72
|
+
create(data: Record<string, unknown>): Promise<unknown>
|
|
73
|
+
delete(id: string | number): Promise<unknown>
|
|
74
|
+
patch?(id: string | number, data: Record<string, unknown>): Promise<unknown>
|
|
75
|
+
update?(id: string | number, data: Record<string, unknown>): Promise<unknown>
|
|
76
|
+
idField?: string
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface LiveList<T> {
|
|
80
|
+
items: T[]
|
|
81
|
+
loaded: boolean
|
|
82
|
+
/** The load or the last change failed */
|
|
83
|
+
error: string | null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const lists = new Map<string, LiveList<unknown>>()
|
|
87
|
+
const warned = new Set<string>()
|
|
88
|
+
|
|
89
|
+
/** The live list of an entity, loaded from its manager the first time */
|
|
90
|
+
export function liveList<T>(name: string, manager: FavoritesManager, read: (row: Record<string, unknown>, idField: string) => T | null): LiveList<T> {
|
|
91
|
+
const known = lists.get(name)
|
|
92
|
+
if (known) return known as LiveList<T>
|
|
93
|
+
const state = reactive({ items: [] as T[], loaded: false, error: null as string | null }) as LiveList<T>
|
|
94
|
+
lists.set(name, state as LiveList<unknown>)
|
|
95
|
+
void reloadList(name, manager, read)
|
|
96
|
+
return state
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Read the entity again (another tab, a page that edits it) */
|
|
100
|
+
export async function reloadList<T>(name: string, manager: FavoritesManager, read: (row: Record<string, unknown>, idField: string) => T | null): Promise<void> {
|
|
101
|
+
const state = lists.get(name) as LiveList<T> | undefined
|
|
102
|
+
if (!state) return
|
|
103
|
+
try {
|
|
104
|
+
const { items } = await manager.list({ page_size: 500 })
|
|
105
|
+
const idField = manager.idField ?? 'id'
|
|
106
|
+
state.items = items.map((row) => read(row, idField)).filter((v): v is T => v !== null)
|
|
107
|
+
state.error = null
|
|
108
|
+
} catch (err) {
|
|
109
|
+
state.error = err instanceof Error ? err.message : String(err)
|
|
110
|
+
console.warn(`[qdadm] favourites: "${name}" could not be read:`, err)
|
|
111
|
+
} finally {
|
|
112
|
+
state.loaded = true
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** A change failed: say so in the console, keep the error for the cards */
|
|
117
|
+
export function changeFailed(name: string, state: LiveList<unknown>, err: unknown): void {
|
|
118
|
+
state.error = err instanceof Error ? err.message : String(err)
|
|
119
|
+
console.warn(`[qdadm] favourites: "${name}" could not be changed:`, err)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The entity's manager, or null (with one warning) when the app declares none */
|
|
123
|
+
export function managerOf(orchestrator: { get?: (name: string) => unknown; has?: (name: string) => boolean } | null, name: string | false): FavoritesManager | null {
|
|
124
|
+
if (!name) return null
|
|
125
|
+
let manager: FavoritesManager | undefined
|
|
126
|
+
// Declared only: a factory would make a manager for any name
|
|
127
|
+
let declared = !!orchestrator?.has?.(name)
|
|
128
|
+
try {
|
|
129
|
+
declared ||= !!getEntityConfig(name)
|
|
130
|
+
} catch {
|
|
131
|
+
// A module registry mocked without it (tests): instantiated managers only
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
manager = declared ? (orchestrator?.get?.(name) as FavoritesManager | undefined) : undefined
|
|
135
|
+
} catch {
|
|
136
|
+
manager = undefined
|
|
137
|
+
}
|
|
138
|
+
if (manager) return manager
|
|
139
|
+
if (!warned.has(name) && orchestrator && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) {
|
|
140
|
+
warned.add(name)
|
|
141
|
+
console.warn(`[qdadm] favourites: no "${name}" entity is declared, so its star and card stay hidden; declare it (ctx.entity), name another with configureFavorites(), or turn it off with configureFavorites({ ${name === config.recents ? 'recents' : 'favorites'}: false })`)
|
|
142
|
+
}
|
|
143
|
+
return null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** For tests: forget the live lists, back to the default names */
|
|
147
|
+
export function resetFavoriteLists(): void {
|
|
148
|
+
lists.clear()
|
|
149
|
+
warned.clear()
|
|
150
|
+
config.favorites = 'favorites'
|
|
151
|
+
config.recents = 'recents'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const KINDS = ['item', 'list', 'search', 'board']
|
|
155
|
+
const iso = (v: unknown): string => {
|
|
156
|
+
const d = v instanceof Date ? v : new Date(typeof v === 'number' || typeof v === 'string' ? v : 0)
|
|
157
|
+
return Number.isNaN(d.getTime()) ? new Date(0).toISOString() : d.toISOString()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function readFavorite(row: Record<string, unknown>, idField: string): Favorite | null {
|
|
161
|
+
const id = row[idField]
|
|
162
|
+
if ((typeof id !== 'string' && typeof id !== 'number') || typeof row.label !== 'string' || typeof row.to !== 'string') return null
|
|
163
|
+
const kind = KINDS.includes(row.kind as string) ? (row.kind as Favorite['kind']) : 'item'
|
|
164
|
+
const itemId = row.itemId !== undefined && row.itemId !== null && row.itemId !== '' ? { itemId: String(row.itemId) } : {}
|
|
165
|
+
return { id: String(id), kind, label: row.label, to: row.to, ...(typeof row.entity === 'string' && row.entity ? { entity: row.entity } : {}), ...itemId, at: iso(row.at) }
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function readRecent(row: Record<string, unknown>, idField: string): RecentItem | null {
|
|
169
|
+
const id = row[idField]
|
|
170
|
+
if ((typeof id !== 'string' && typeof id !== 'number') || typeof row.entity !== 'string' || typeof row.label !== 'string' || typeof row.to !== 'string') return null
|
|
171
|
+
return { id: String(id), entity: row.entity, itemId: String(row.itemId ?? ''), label: row.label, to: row.to, at: iso(row.at) }
|
|
172
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useFavorites / useRecent (#5349): the person's favourites and the records
|
|
3
|
+
* they just opened, live, through the `favorites` and `recents` entities the
|
|
4
|
+
* app declares (see store.ts).
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const favorites = useFavorites()
|
|
8
|
+
* await favorites.toggle({ kind: 'item', label: book.title, to: route.path, entity: 'books' })
|
|
9
|
+
* favorites.list.value // oldest first
|
|
10
|
+
*
|
|
11
|
+
* const recent = useRecent()
|
|
12
|
+
* recent.list.value // the last records opened, newest first
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Without the entity, `available` is false and the lists stay empty.
|
|
16
|
+
*/
|
|
17
|
+
import { computed, inject, type ComputedRef } from 'vue'
|
|
18
|
+
import {
|
|
19
|
+
changeFailed,
|
|
20
|
+
getFavoritesConfig,
|
|
21
|
+
liveList,
|
|
22
|
+
managerOf,
|
|
23
|
+
readFavorite,
|
|
24
|
+
readRecent,
|
|
25
|
+
reloadList,
|
|
26
|
+
RECENT_MAX,
|
|
27
|
+
type Favorite,
|
|
28
|
+
type FavoritesManager,
|
|
29
|
+
type LiveList,
|
|
30
|
+
type RecentItem,
|
|
31
|
+
} from './store'
|
|
32
|
+
|
|
33
|
+
type FavoriteInput = Omit<Favorite, 'id' | 'at'>
|
|
34
|
+
|
|
35
|
+
export interface UseFavoritesReturn {
|
|
36
|
+
/** The app declares the favorites entity */
|
|
37
|
+
available: boolean
|
|
38
|
+
list: ComputedRef<Favorite[]>
|
|
39
|
+
/** The entity has answered */
|
|
40
|
+
loaded: ComputedRef<boolean>
|
|
41
|
+
/** The last read or change failed */
|
|
42
|
+
error: ComputedRef<string | null>
|
|
43
|
+
/** The favourite of this page, if any */
|
|
44
|
+
find: (to: string) => Favorite | undefined
|
|
45
|
+
/** A record's favourite, whichever of its pages added it */
|
|
46
|
+
findItem: (entity: string, itemId: string | number) => Favorite | undefined
|
|
47
|
+
has: (to: string) => boolean
|
|
48
|
+
add: (entry: FavoriteInput) => Promise<Favorite | null>
|
|
49
|
+
remove: (id: string) => Promise<void>
|
|
50
|
+
/** Add it, or remove it when this page is already one; true when it is one now */
|
|
51
|
+
toggle: (entry: FavoriteInput) => Promise<boolean>
|
|
52
|
+
rename: (id: string, label: string) => Promise<void>
|
|
53
|
+
/** Forget every favourite of a path (a deleted record) */
|
|
54
|
+
forgetPath: (to: string) => Promise<void>
|
|
55
|
+
/** Forget a deleted record's favourites */
|
|
56
|
+
forgetItem: (entity: string, itemId: string | number) => Promise<void>
|
|
57
|
+
reload: () => Promise<void>
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface UseRecentReturn {
|
|
61
|
+
available: boolean
|
|
62
|
+
/** The last records opened, newest first */
|
|
63
|
+
list: ComputedRef<RecentItem[]>
|
|
64
|
+
loaded: ComputedRef<boolean>
|
|
65
|
+
error: ComputedRef<string | null>
|
|
66
|
+
/** A record opened now: first in the list, once, at most RECENT_MAX kept */
|
|
67
|
+
record: (entry: Omit<RecentItem, 'id' | 'at'>) => Promise<void>
|
|
68
|
+
/** A deleted record leaves the list */
|
|
69
|
+
forget: (entity: string, itemId: string | number) => Promise<void>
|
|
70
|
+
reload: () => Promise<void>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const EMPTY: LiveList<never> = { items: [], loaded: true, error: null }
|
|
74
|
+
let tempIds = 0
|
|
75
|
+
const tempId = () => `pending-${++tempIds}`
|
|
76
|
+
|
|
77
|
+
/** The id the storage gave the record it created */
|
|
78
|
+
function createdId(created: unknown, manager: FavoritesManager): string | null {
|
|
79
|
+
const id = (created as Record<string, unknown> | null)?.[manager.idField ?? 'id']
|
|
80
|
+
return typeof id === 'string' || typeof id === 'number' ? String(id) : null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function useFavorites(): UseFavoritesReturn {
|
|
84
|
+
const orchestrator = inject<{ get?: (name: string) => unknown; has?: (name: string) => boolean } | null>('qdadmOrchestrator', null)
|
|
85
|
+
const name = getFavoritesConfig().favorites
|
|
86
|
+
const manager = managerOf(orchestrator, name)
|
|
87
|
+
const state: LiveList<Favorite> = manager && name ? liveList(name, manager, readFavorite) : EMPTY
|
|
88
|
+
|
|
89
|
+
const find = (to: string) => state.items.find((f) => f.to === to)
|
|
90
|
+
/** A record's favourite, whichever of its pages added it */
|
|
91
|
+
const findItem = (entity: string, itemId: string | number) => state.items.find((f) => f.entity === entity && f.itemId === String(itemId))
|
|
92
|
+
const findEntry = (entry: FavoriteInput) => (entry.entity && entry.itemId ? findItem(entry.entity, entry.itemId) : undefined) ?? find(entry.to)
|
|
93
|
+
|
|
94
|
+
async function add(entry: FavoriteInput): Promise<Favorite | null> {
|
|
95
|
+
if (!manager || !name) return null
|
|
96
|
+
const known = findEntry(entry)
|
|
97
|
+
if (known) return known
|
|
98
|
+
const fav: Favorite = { ...entry, id: tempId(), at: new Date().toISOString() }
|
|
99
|
+
state.items.push(fav)
|
|
100
|
+
const { id: _id, ...fields } = fav
|
|
101
|
+
try {
|
|
102
|
+
const id = createdId(await manager.create(fields), manager)
|
|
103
|
+
const shown = state.items.find((f) => f.id === fav.id)
|
|
104
|
+
if (shown && id) shown.id = id
|
|
105
|
+
else if (!id) await reloadList(name, manager, readFavorite)
|
|
106
|
+
return shown ?? fav
|
|
107
|
+
} catch (err) {
|
|
108
|
+
state.items = state.items.filter((f) => f.id !== fav.id)
|
|
109
|
+
changeFailed(name, state, err)
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function remove(id: string): Promise<void> {
|
|
115
|
+
if (!manager || !name) return
|
|
116
|
+
const before = state.items
|
|
117
|
+
if (!before.some((f) => f.id === id)) return
|
|
118
|
+
state.items = before.filter((f) => f.id !== id)
|
|
119
|
+
try {
|
|
120
|
+
await manager.delete(id)
|
|
121
|
+
} catch (err) {
|
|
122
|
+
state.items = before
|
|
123
|
+
changeFailed(name, state, err)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
available: !!manager,
|
|
129
|
+
list: computed(() => state.items),
|
|
130
|
+
loaded: computed(() => state.loaded),
|
|
131
|
+
error: computed(() => state.error),
|
|
132
|
+
find,
|
|
133
|
+
findItem,
|
|
134
|
+
has: (to) => !!find(to),
|
|
135
|
+
add,
|
|
136
|
+
remove,
|
|
137
|
+
async toggle(entry) {
|
|
138
|
+
const known = findEntry(entry)
|
|
139
|
+
if (known) {
|
|
140
|
+
await remove(known.id)
|
|
141
|
+
return false
|
|
142
|
+
}
|
|
143
|
+
return !!(await add(entry))
|
|
144
|
+
},
|
|
145
|
+
async rename(id, label) {
|
|
146
|
+
const fav = state.items.find((f) => f.id === id)
|
|
147
|
+
const text = label.trim()
|
|
148
|
+
if (!manager || !name || !fav || !text || fav.label === text) return
|
|
149
|
+
const old = fav.label
|
|
150
|
+
fav.label = text
|
|
151
|
+
try {
|
|
152
|
+
await (manager.patch ?? manager.update)?.call(manager, id, { label: text })
|
|
153
|
+
} catch (err) {
|
|
154
|
+
fav.label = old
|
|
155
|
+
changeFailed(name, state, err)
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
async forgetPath(to) {
|
|
159
|
+
for (const f of state.items.filter((x) => x.to === to || x.to.startsWith(`${to}?`))) await remove(f.id)
|
|
160
|
+
},
|
|
161
|
+
async forgetItem(entity, itemId) {
|
|
162
|
+
for (const f of state.items.filter((x) => x.entity === entity && x.itemId === String(itemId))) await remove(f.id)
|
|
163
|
+
},
|
|
164
|
+
reload: () => (manager && name ? reloadList(name, manager, readFavorite) : Promise.resolve()),
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function useRecent(): UseRecentReturn {
|
|
169
|
+
const orchestrator = inject<{ get?: (name: string) => unknown; has?: (name: string) => boolean } | null>('qdadmOrchestrator', null)
|
|
170
|
+
const name = getFavoritesConfig().recents
|
|
171
|
+
const manager = managerOf(orchestrator, name)
|
|
172
|
+
const state: LiveList<RecentItem> = manager && name ? liveList(name, manager, readRecent) : EMPTY
|
|
173
|
+
|
|
174
|
+
async function drop(items: RecentItem[]): Promise<void> {
|
|
175
|
+
if (!manager || !name) return
|
|
176
|
+
const ids = new Set(items.map((r) => r.id))
|
|
177
|
+
state.items = state.items.filter((r) => !ids.has(r.id))
|
|
178
|
+
for (const r of items) {
|
|
179
|
+
if (r.id.startsWith('pending-')) continue
|
|
180
|
+
try {
|
|
181
|
+
await manager.delete(r.id)
|
|
182
|
+
} catch (err) {
|
|
183
|
+
changeFailed(name, state, err)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
available: !!manager,
|
|
190
|
+
list: computed(() => [...state.items].sort((a, b) => b.at.localeCompare(a.at))),
|
|
191
|
+
loaded: computed(() => state.loaded),
|
|
192
|
+
error: computed(() => state.error),
|
|
193
|
+
async record(entry) {
|
|
194
|
+
if (!manager || !name) return
|
|
195
|
+
const itemId = String(entry.itemId)
|
|
196
|
+
const same = state.items.filter((r) => r.entity === entry.entity && r.itemId === itemId)
|
|
197
|
+
const item: RecentItem = { ...entry, itemId, id: tempId(), at: new Date().toISOString() }
|
|
198
|
+
state.items.push(item)
|
|
199
|
+
// Older than the RECENT_MAX newest go
|
|
200
|
+
const overflow = [...state.items].sort((a, b) => b.at.localeCompare(a.at)).filter((r) => !same.includes(r)).slice(RECENT_MAX)
|
|
201
|
+
await drop([...same, ...overflow])
|
|
202
|
+
const { id: _id, ...fields } = item
|
|
203
|
+
try {
|
|
204
|
+
const id = createdId(await manager.create(fields), manager)
|
|
205
|
+
const shown = state.items.find((r) => r.id === item.id)
|
|
206
|
+
if (shown && id) shown.id = id
|
|
207
|
+
} catch (err) {
|
|
208
|
+
state.items = state.items.filter((r) => r.id !== item.id)
|
|
209
|
+
changeFailed(name, state, err)
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
async forget(entity, itemId) {
|
|
213
|
+
await drop(state.items.filter((r) => r.entity === entity && r.itemId === String(itemId)))
|
|
214
|
+
},
|
|
215
|
+
reload: () => (manager && name ? reloadList(name, manager, readRecent) : Promise.resolve()),
|
|
216
|
+
}
|
|
217
|
+
}
|
|
@@ -254,6 +254,35 @@ export default `core:
|
|
|
254
254
|
trayView: Show hidden cards as
|
|
255
255
|
viewCards: Cards
|
|
256
256
|
viewCompact: Compact
|
|
257
|
+
# The catalogue, cards with parameters, sizes, sections (#5348)
|
|
258
|
+
addCard: Add a card
|
|
259
|
+
catalogue: Add a card
|
|
260
|
+
catalogueEmpty: Every card is already on the board
|
|
261
|
+
hiddenNow: "Hidden: it comes back where it was"
|
|
262
|
+
add: Add
|
|
263
|
+
addOne: "Add {title}"
|
|
264
|
+
added: "{title} added"
|
|
265
|
+
remove: "Remove {title}"
|
|
266
|
+
removed: "{title} removed"
|
|
267
|
+
cardTitle: Title
|
|
268
|
+
choose: Choose…
|
|
269
|
+
inSection: In the section
|
|
270
|
+
paramRequired: Fill this in
|
|
271
|
+
paramInvalid: "Not a valid value: {problem}"
|
|
272
|
+
size: "Size of {title}"
|
|
273
|
+
sizeS: Small
|
|
274
|
+
sizeM: Medium
|
|
275
|
+
sizeL: Large
|
|
276
|
+
resized: "{title}: {size}"
|
|
277
|
+
addSection: Add a section
|
|
278
|
+
firstSection: Main
|
|
279
|
+
newSection: New section
|
|
280
|
+
sectionName: Name of the section
|
|
281
|
+
sectionAdded: "Section {title} added"
|
|
282
|
+
removeSection: "Remove the section {title}"
|
|
283
|
+
sectionRemoved: "Section {title} removed, its cards moved to the first one"
|
|
284
|
+
section: "Section of {title}"
|
|
285
|
+
movedToSection: "{title} moved to {section}"
|
|
257
286
|
# SessionsModule (#4336)
|
|
258
287
|
sessions:
|
|
259
288
|
title: Sessions
|
|
@@ -365,6 +394,54 @@ export default `core:
|
|
|
365
394
|
moreKeys: "+{count} more"
|
|
366
395
|
takeTheirs: Load their version
|
|
367
396
|
keepMine: Keep mine and save over it
|
|
397
|
+
# Cards (#5339): the envelope's words and the generic cards'
|
|
398
|
+
cards:
|
|
399
|
+
status:
|
|
400
|
+
critical: Critical
|
|
401
|
+
watch: To watch
|
|
402
|
+
good: Good
|
|
403
|
+
info: Info
|
|
404
|
+
loading: Loading…
|
|
405
|
+
unreachable: Source unreachable
|
|
406
|
+
galleryUnreachable: "The source did not answer (timeout after 10 s)"
|
|
407
|
+
empty: Nothing to report
|
|
408
|
+
invalid: Invalid data
|
|
409
|
+
moreProblems: "and {count} more"
|
|
410
|
+
overdue: overdue
|
|
411
|
+
compare:
|
|
412
|
+
points: pt
|
|
413
|
+
trend:
|
|
414
|
+
within: Within the normal
|
|
415
|
+
outside: "{count} point outside the normal | {count} points outside the normal"
|
|
416
|
+
split:
|
|
417
|
+
others: Others
|
|
418
|
+
funnel:
|
|
419
|
+
loss: "−{count} between {from} and {to}"
|
|
420
|
+
heat:
|
|
421
|
+
low: Fewer
|
|
422
|
+
high: "More (up to {max})"
|
|
423
|
+
agenda:
|
|
424
|
+
today: Today
|
|
425
|
+
tomorrow: Tomorrow
|
|
426
|
+
yesterday: Yesterday
|
|
427
|
+
tomorrowAt: "Tomorrow {time}"
|
|
428
|
+
yesterdayAt: "Yesterday {time}"
|
|
429
|
+
ageUnit:
|
|
430
|
+
min: min
|
|
431
|
+
h: h
|
|
432
|
+
d: d
|
|
433
|
+
goal:
|
|
434
|
+
of: "of {target}"
|
|
435
|
+
reached: "{share} of the target"
|
|
436
|
+
pace: "expected on {date}: {share}"
|
|
437
|
+
ahead: ahead
|
|
438
|
+
behind: behind
|
|
439
|
+
bullet:
|
|
440
|
+
target: "target {target}"
|
|
441
|
+
aria: "{value}: {range}"
|
|
442
|
+
poor: Poor
|
|
443
|
+
fair: Fair
|
|
444
|
+
good: Good
|
|
368
445
|
# PermissionEditor (#5333)
|
|
369
446
|
permissionEditor:
|
|
370
447
|
placeholder: Type a permission…
|
|
@@ -390,6 +467,61 @@ export default `core:
|
|
|
390
467
|
copied: Copied
|
|
391
468
|
copyFailed: "Copy failed: {error}"
|
|
392
469
|
confirm: I have copied it
|
|
470
|
+
# The run bar: walking a set of items one after the other (QdRunBar, useRun, #5343)
|
|
471
|
+
run:
|
|
472
|
+
bar: Run
|
|
473
|
+
position: "{position} of {total}"
|
|
474
|
+
order: "sorted by {order}"
|
|
475
|
+
filter: "filter: {filter}"
|
|
476
|
+
doneSince: "{count} done since it started | {count} done since it started"
|
|
477
|
+
prev: Previous
|
|
478
|
+
next: Next
|
|
479
|
+
saveAndNext: Save and go to the next
|
|
480
|
+
finished: "The item is done | The {count} items are done"
|
|
481
|
+
state:
|
|
482
|
+
current: current
|
|
483
|
+
done: done
|
|
484
|
+
urgent: urgent
|
|
485
|
+
todo: to do
|
|
486
|
+
# Favourites and recents: the star, "Save this search", the two cards (#5349)
|
|
487
|
+
favorites:
|
|
488
|
+
add: "Add {label} to favourites"
|
|
489
|
+
remove: "Remove {label} from favourites"
|
|
490
|
+
saveSearch: Save this search
|
|
491
|
+
searchSaved: Search saved
|
|
492
|
+
searchName: Name of the search
|
|
493
|
+
save: Save
|
|
494
|
+
title: Favourites
|
|
495
|
+
none: "No favourites yet: the star beside a page title adds one"
|
|
496
|
+
recentTitle: Recent
|
|
497
|
+
noneRecent: Nothing opened yet
|
|
498
|
+
noEntity: No favorites entity is declared
|
|
499
|
+
noRecentsEntity: No recents entity is declared
|
|
500
|
+
kind:
|
|
501
|
+
item: Records
|
|
502
|
+
list: Lists
|
|
503
|
+
search: Searches
|
|
504
|
+
board: Boards
|
|
505
|
+
# A domain's board (QdDomainBoard, #5352)
|
|
506
|
+
board:
|
|
507
|
+
source: "Source: {source}"
|
|
508
|
+
readAt: "read {when}"
|
|
509
|
+
openSource: "open {source}"
|
|
510
|
+
retry: Try again
|
|
511
|
+
change: "{change} on the period before"
|
|
512
|
+
same: Same as the period before
|
|
513
|
+
timelineBars: "Volume from {from} to {to}"
|
|
514
|
+
# The domain bar (#5389)
|
|
515
|
+
domainBar:
|
|
516
|
+
label: "{domain}: its pages and indicators"
|
|
517
|
+
nav: "{domain} pages"
|
|
518
|
+
indicators: "{domain} indicators"
|
|
519
|
+
compact: Compact bar
|
|
520
|
+
expand: Full bar
|
|
521
|
+
badge: "{count} — {title}"
|
|
522
|
+
unreachable: "{title}: unreachable ({error})"
|
|
523
|
+
invalid: "{title}: data that does not fit"
|
|
524
|
+
loading: "{title}: loading"
|
|
393
525
|
# NotFoundPage
|
|
394
526
|
notFound:
|
|
395
527
|
title: Page not found
|
|
@@ -252,6 +252,35 @@ core:
|
|
|
252
252
|
trayView: Show hidden cards as
|
|
253
253
|
viewCards: Cards
|
|
254
254
|
viewCompact: Compact
|
|
255
|
+
# The catalogue, cards with parameters, sizes, sections (#5348)
|
|
256
|
+
addCard: Add a card
|
|
257
|
+
catalogue: Add a card
|
|
258
|
+
catalogueEmpty: Every card is already on the board
|
|
259
|
+
hiddenNow: "Hidden: it comes back where it was"
|
|
260
|
+
add: Add
|
|
261
|
+
addOne: "Add {title}"
|
|
262
|
+
added: "{title} added"
|
|
263
|
+
remove: "Remove {title}"
|
|
264
|
+
removed: "{title} removed"
|
|
265
|
+
cardTitle: Title
|
|
266
|
+
choose: Choose…
|
|
267
|
+
inSection: In the section
|
|
268
|
+
paramRequired: Fill this in
|
|
269
|
+
paramInvalid: "Not a valid value: {problem}"
|
|
270
|
+
size: "Size of {title}"
|
|
271
|
+
sizeS: Small
|
|
272
|
+
sizeM: Medium
|
|
273
|
+
sizeL: Large
|
|
274
|
+
resized: "{title}: {size}"
|
|
275
|
+
addSection: Add a section
|
|
276
|
+
firstSection: Main
|
|
277
|
+
newSection: New section
|
|
278
|
+
sectionName: Name of the section
|
|
279
|
+
sectionAdded: "Section {title} added"
|
|
280
|
+
removeSection: "Remove the section {title}"
|
|
281
|
+
sectionRemoved: "Section {title} removed, its cards moved to the first one"
|
|
282
|
+
section: "Section of {title}"
|
|
283
|
+
movedToSection: "{title} moved to {section}"
|
|
255
284
|
# SessionsModule (#4336)
|
|
256
285
|
sessions:
|
|
257
286
|
title: Sessions
|
|
@@ -363,6 +392,54 @@ core:
|
|
|
363
392
|
moreKeys: "+{count} more"
|
|
364
393
|
takeTheirs: Load their version
|
|
365
394
|
keepMine: Keep mine and save over it
|
|
395
|
+
# Cards (#5339): the envelope's words and the generic cards'
|
|
396
|
+
cards:
|
|
397
|
+
status:
|
|
398
|
+
critical: Critical
|
|
399
|
+
watch: To watch
|
|
400
|
+
good: Good
|
|
401
|
+
info: Info
|
|
402
|
+
loading: Loading…
|
|
403
|
+
unreachable: Source unreachable
|
|
404
|
+
galleryUnreachable: "The source did not answer (timeout after 10 s)"
|
|
405
|
+
empty: Nothing to report
|
|
406
|
+
invalid: Invalid data
|
|
407
|
+
moreProblems: "and {count} more"
|
|
408
|
+
overdue: overdue
|
|
409
|
+
compare:
|
|
410
|
+
points: pt
|
|
411
|
+
trend:
|
|
412
|
+
within: Within the normal
|
|
413
|
+
outside: "{count} point outside the normal | {count} points outside the normal"
|
|
414
|
+
split:
|
|
415
|
+
others: Others
|
|
416
|
+
funnel:
|
|
417
|
+
loss: "−{count} between {from} and {to}"
|
|
418
|
+
heat:
|
|
419
|
+
low: Fewer
|
|
420
|
+
high: "More (up to {max})"
|
|
421
|
+
agenda:
|
|
422
|
+
today: Today
|
|
423
|
+
tomorrow: Tomorrow
|
|
424
|
+
yesterday: Yesterday
|
|
425
|
+
tomorrowAt: "Tomorrow {time}"
|
|
426
|
+
yesterdayAt: "Yesterday {time}"
|
|
427
|
+
ageUnit:
|
|
428
|
+
min: min
|
|
429
|
+
h: h
|
|
430
|
+
d: d
|
|
431
|
+
goal:
|
|
432
|
+
of: "of {target}"
|
|
433
|
+
reached: "{share} of the target"
|
|
434
|
+
pace: "expected on {date}: {share}"
|
|
435
|
+
ahead: ahead
|
|
436
|
+
behind: behind
|
|
437
|
+
bullet:
|
|
438
|
+
target: "target {target}"
|
|
439
|
+
aria: "{value}: {range}"
|
|
440
|
+
poor: Poor
|
|
441
|
+
fair: Fair
|
|
442
|
+
good: Good
|
|
366
443
|
# PermissionEditor (#5333)
|
|
367
444
|
permissionEditor:
|
|
368
445
|
placeholder: Type a permission…
|
|
@@ -388,6 +465,61 @@ core:
|
|
|
388
465
|
copied: Copied
|
|
389
466
|
copyFailed: "Copy failed: {error}"
|
|
390
467
|
confirm: I have copied it
|
|
468
|
+
# The run bar: walking a set of items one after the other (QdRunBar, useRun, #5343)
|
|
469
|
+
run:
|
|
470
|
+
bar: Run
|
|
471
|
+
position: "{position} of {total}"
|
|
472
|
+
order: "sorted by {order}"
|
|
473
|
+
filter: "filter: {filter}"
|
|
474
|
+
doneSince: "{count} done since it started | {count} done since it started"
|
|
475
|
+
prev: Previous
|
|
476
|
+
next: Next
|
|
477
|
+
saveAndNext: Save and go to the next
|
|
478
|
+
finished: "The item is done | The {count} items are done"
|
|
479
|
+
state:
|
|
480
|
+
current: current
|
|
481
|
+
done: done
|
|
482
|
+
urgent: urgent
|
|
483
|
+
todo: to do
|
|
484
|
+
# Favourites and recents: the star, "Save this search", the two cards (#5349)
|
|
485
|
+
favorites:
|
|
486
|
+
add: "Add {label} to favourites"
|
|
487
|
+
remove: "Remove {label} from favourites"
|
|
488
|
+
saveSearch: Save this search
|
|
489
|
+
searchSaved: Search saved
|
|
490
|
+
searchName: Name of the search
|
|
491
|
+
save: Save
|
|
492
|
+
title: Favourites
|
|
493
|
+
none: "No favourites yet: the star beside a page title adds one"
|
|
494
|
+
recentTitle: Recent
|
|
495
|
+
noneRecent: Nothing opened yet
|
|
496
|
+
noEntity: No favorites entity is declared
|
|
497
|
+
noRecentsEntity: No recents entity is declared
|
|
498
|
+
kind:
|
|
499
|
+
item: Records
|
|
500
|
+
list: Lists
|
|
501
|
+
search: Searches
|
|
502
|
+
board: Boards
|
|
503
|
+
# A domain's board (QdDomainBoard, #5352)
|
|
504
|
+
board:
|
|
505
|
+
source: "Source: {source}"
|
|
506
|
+
readAt: "read {when}"
|
|
507
|
+
openSource: "open {source}"
|
|
508
|
+
retry: Try again
|
|
509
|
+
change: "{change} on the period before"
|
|
510
|
+
same: Same as the period before
|
|
511
|
+
timelineBars: "Volume from {from} to {to}"
|
|
512
|
+
# The domain bar (#5389)
|
|
513
|
+
domainBar:
|
|
514
|
+
label: "{domain}: its pages and indicators"
|
|
515
|
+
nav: "{domain} pages"
|
|
516
|
+
indicators: "{domain} indicators"
|
|
517
|
+
compact: Compact bar
|
|
518
|
+
expand: Full bar
|
|
519
|
+
badge: "{count} — {title}"
|
|
520
|
+
unreachable: "{title}: unreachable ({error})"
|
|
521
|
+
invalid: "{title}: data that does not fit"
|
|
522
|
+
loading: "{title}: loading"
|
|
391
523
|
# NotFoundPage
|
|
392
524
|
notFound:
|
|
393
525
|
title: Page not found
|