@quazardous/qdadm 2.46.0 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styles/qdadm.css +1 -1
- package/package.json +1 -1
- package/src/components/SeverityTag.vue +15 -1
- package/src/components/display/QdPending.vue +58 -0
- package/src/components/display/QdPendingZone.vue +104 -0
- package/src/components/index.ts +5 -0
- package/src/components/lists/ListPage.vue +33 -4
- package/src/components/show/ShowDisplay.vue +13 -2
- package/src/components/show/ShowPage.vue +6 -6
- package/src/components/tasks/TaskDialog.vue +13 -157
- package/src/components/tasks/TaskHost.vue +28 -2
- package/src/components/tasks/TaskRunStatus.vue +63 -0
- package/src/components/tasks/TaskRunView.vue +197 -0
- package/src/components/tasks/TaskSequenceDialog.vue +157 -0
- package/src/components/tasks/TaskTray.vue +33 -13
- package/src/composables/index.ts +6 -0
- package/src/composables/useAsyncRead.ts +109 -0
- package/src/composables/useEntityItemFormPage.ts +13 -6
- package/src/composables/useEntityItemFormPage.types.ts +4 -1
- package/src/composables/useEntityItemShowPage.ts +18 -7
- package/src/composables/useFieldManager.ts +11 -2
- package/src/composables/useListPage.filters.ts +21 -1
- package/src/composables/useListPage.ts +68 -9
- package/src/composables/useListPage.types.ts +4 -1
- package/src/composables/useNavContext.ts +5 -4
- package/src/entity/EntityManager.ts +17 -0
- package/src/entity/EntityManager.types.ts +2 -0
- package/src/entity/storage/MockApiStorage.ts +31 -7
- package/src/i18n/defaults/core.en.generated.ts +32 -0
- package/src/i18n/defaults/core.en.yml +32 -0
- package/src/i18n/defaults/core.fr.generated.ts +32 -0
- package/src/i18n/defaults/core.fr.yml +32 -0
- package/src/i18n/optionLabels.ts +35 -0
- package/src/i18n/types.ts +5 -0
- package/src/index.ts +11 -0
- package/src/kernel/Kernel.i18n.ts +36 -3
- package/src/kernel/Kernel.registries.ts +11 -7
- package/src/kernel/Kernel.ts +2 -0
- package/src/kernel/KernelContext.permissions.ts +11 -0
- package/src/kernel/KernelContext.ts +6 -0
- package/src/kernel/KernelContext.types.ts +2 -0
- package/src/orchestrator/Orchestrator.ts +3 -0
- package/src/security/PersistableRolesProvider.ts +61 -3
- package/src/security/StaticRolesProvider.ts +6 -0
- package/src/styles/_pending.scss +125 -0
- package/src/styles/_tasks.scss +126 -0
- package/src/styles/index.scss +1 -0
- package/src/tasks/taskStore.ts +449 -14
- package/src/tasks/taskUi.ts +6 -0
- package/src/tasks/useTaskNotifications.ts +6 -2
- package/src/tasks/useTaskRunner.ts +24 -0
|
@@ -86,7 +86,10 @@ export type ResolvedFieldConfig = ShowResolvedFieldConfig
|
|
|
86
86
|
*/
|
|
87
87
|
export interface ActionConfig {
|
|
88
88
|
name: string
|
|
89
|
-
|
|
89
|
+
/** A string, or a function read at each render, so it follows the locale (#4692) */
|
|
90
|
+
label: string | (() => string)
|
|
91
|
+
/** Where it shows: the header or the footer. Default: the header for `edit`, the footer for the rest (#4693) */
|
|
92
|
+
placement?: 'header' | 'footer'
|
|
90
93
|
icon?: string
|
|
91
94
|
/** PrimeVue Button severity — the shared union, not bare string (#1281) */
|
|
92
95
|
severity?: ButtonSeverity
|
|
@@ -94,6 +97,8 @@ export interface ActionConfig {
|
|
|
94
97
|
visible?: (ctx: { canEdit: boolean; canDelete: boolean }) => boolean
|
|
95
98
|
disabled?: (ctx: { loading: boolean }) => boolean
|
|
96
99
|
loading?: () => boolean
|
|
100
|
+
/** A default label, read again at each render so it follows the locale (#4686) */
|
|
101
|
+
_label?: () => string
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
/**
|
|
@@ -421,6 +426,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
|
|
|
421
426
|
if (action.visible && !action.visible(ctx)) return null
|
|
422
427
|
return {
|
|
423
428
|
...action,
|
|
429
|
+
label: typeof action.label === 'function' ? action.label() : action._label ? action._label() : action.label,
|
|
424
430
|
isLoading: action.loading ? action.loading() : false,
|
|
425
431
|
isDisabled: action.disabled ? action.disabled(ctx) : false,
|
|
426
432
|
}
|
|
@@ -442,11 +448,16 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
|
|
|
442
448
|
return returnValue
|
|
443
449
|
}
|
|
444
450
|
|
|
451
|
+
/** The page's label as given, else the catalogue's, read again on each render */
|
|
452
|
+
function ownLabel(label: string | undefined, key: string, fallback: string): Pick<ActionConfig, 'label' | '_label'> {
|
|
453
|
+
return label ? { label } : { label: tOr(key, fallback), _label: () => tOr(key, fallback) }
|
|
454
|
+
}
|
|
455
|
+
|
|
445
456
|
function addEditAction(editOptions: { label?: string; icon?: string } = {}): UseEntityItemShowPageReturn<T> {
|
|
446
|
-
const { label
|
|
457
|
+
const { label, icon = 'pi pi-pencil' } = editOptions
|
|
447
458
|
return addAction({
|
|
448
459
|
name: 'edit',
|
|
449
|
-
label,
|
|
460
|
+
...ownLabel(label, 'core.actions.edit', 'Edit'),
|
|
450
461
|
icon,
|
|
451
462
|
severity: 'primary',
|
|
452
463
|
onClick: goToEdit,
|
|
@@ -457,10 +468,10 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
|
|
|
457
468
|
function addDeleteAction(
|
|
458
469
|
deleteOptions: { label?: string; icon?: string; confirm?: boolean } = {}
|
|
459
470
|
): UseEntityItemShowPageReturn<T> {
|
|
460
|
-
const { label
|
|
471
|
+
const { label, icon = 'pi pi-trash', confirm: confirmDelete = true } = deleteOptions
|
|
461
472
|
return addAction({
|
|
462
473
|
name: 'delete',
|
|
463
|
-
label,
|
|
474
|
+
...ownLabel(label, 'core.actions.delete', 'Delete'),
|
|
464
475
|
icon,
|
|
465
476
|
severity: 'danger',
|
|
466
477
|
onClick: () => {
|
|
@@ -479,10 +490,10 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
|
|
|
479
490
|
}
|
|
480
491
|
|
|
481
492
|
function addBackAction(backOptions: { label?: string; icon?: string; route?: string } = {}): UseEntityItemShowPageReturn<T> {
|
|
482
|
-
const { label
|
|
493
|
+
const { label, icon = 'pi pi-arrow-left', route: backRoute } = backOptions
|
|
483
494
|
return addAction({
|
|
484
495
|
name: 'back',
|
|
485
|
-
label,
|
|
496
|
+
...ownLabel(label, 'core.actions.back', 'Back'),
|
|
486
497
|
icon,
|
|
487
498
|
severity: 'secondary',
|
|
488
499
|
onClick: () => {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* fieldManager.group('info', ['name', 'email'], { label: 'Information' })
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
+
import { translateOptions, type LabeledOption } from '../i18n/optionLabels'
|
|
21
22
|
import { ref, computed, watch, type Ref, type ComputedRef } from 'vue'
|
|
22
23
|
import { useI18n } from '../i18n/useI18n'
|
|
23
24
|
|
|
@@ -273,6 +274,10 @@ export function useFieldManager<T extends ResolvedFieldConfig = ResolvedFieldCon
|
|
|
273
274
|
if (trace.hit) {
|
|
274
275
|
resolved.label = trace.result
|
|
275
276
|
}
|
|
277
|
+
const withOptions = resolved as T & { options?: LabeledOption[] }
|
|
278
|
+
if (Array.isArray(withOptions.options)) {
|
|
279
|
+
withOptions.options = translateOptions(i18n, entityName, name, withOptions.options) as LabeledOption[]
|
|
280
|
+
}
|
|
276
281
|
return resolved
|
|
277
282
|
}
|
|
278
283
|
|
|
@@ -632,8 +637,12 @@ export function useFieldManager<T extends ResolvedFieldConfig = ResolvedFieldCon
|
|
|
632
637
|
const newLabel = trace.hit
|
|
633
638
|
? trace.result
|
|
634
639
|
: meta._inlineLabel || snakeCaseToTitle(name)
|
|
635
|
-
|
|
636
|
-
|
|
640
|
+
const options = (field as T & { options?: LabeledOption[] }).options
|
|
641
|
+
const newOptions = Array.isArray(options) ? translateOptions(i18n, entityName, name, options) : options
|
|
642
|
+
const optionsChanged =
|
|
643
|
+
Array.isArray(options) && JSON.stringify(newOptions?.map((o) => o?.label)) !== JSON.stringify(options.map((o) => o?.label))
|
|
644
|
+
if (field.label !== newLabel || optionsChanged) {
|
|
645
|
+
fieldsMap.value.set(name, { ...field, label: newLabel, ...(optionsChanged ? { options: newOptions } : {}) } as T)
|
|
637
646
|
}
|
|
638
647
|
}
|
|
639
648
|
|
|
@@ -212,11 +212,29 @@ export function useListFilters(deps: UseListFiltersDeps): UseListFiltersReturn {
|
|
|
212
212
|
warnIfReservedName(name)
|
|
213
213
|
warnIfUnknownType(name, filterConfig?.type)
|
|
214
214
|
warnIfEndpointUnreachable(name, filterConfig)
|
|
215
|
+
// Static options get the same "All" choice as loaded ones (#4692): a
|
|
216
|
+
// select has no other way back to no filter. Not when the page has its own
|
|
217
|
+
// null option, nor with allLabel: false.
|
|
218
|
+
const staticOptions = Array.isArray(filterConfig.options) ? filterConfig.options : null
|
|
219
|
+
const addAll =
|
|
220
|
+
staticOptions !== null &&
|
|
221
|
+
(filterConfig as { allLabel?: string | false }).allLabel !== false &&
|
|
222
|
+
!staticOptions.some((o) => (o as { value?: unknown })?.value === null)
|
|
223
|
+
const allOption = addAll
|
|
224
|
+
? [{
|
|
225
|
+
label: (filterConfig as { allLabel?: string }).allLabel || filterConfig.placeholder || `All ${snakeToTitle(name)}`,
|
|
226
|
+
value: null as unknown,
|
|
227
|
+
...(!(filterConfig as { allLabel?: string }).allLabel && !filterConfig.placeholder ? { _autoAll: true } : {}),
|
|
228
|
+
}]
|
|
229
|
+
: []
|
|
215
230
|
filtersMap.value.set(name, {
|
|
216
231
|
name,
|
|
217
232
|
type: 'select',
|
|
218
233
|
placeholder: name,
|
|
234
|
+
// No placeholder given: the field's label, resolved at render (#4692)
|
|
235
|
+
...(filterConfig.placeholder ? {} : { _autoPlaceholder: true }),
|
|
219
236
|
...filterConfig,
|
|
237
|
+
...(addAll ? { options: [...allOption, ...staticOptions!] } : {}),
|
|
220
238
|
})
|
|
221
239
|
if (filterValues.value[name] === undefined) {
|
|
222
240
|
filterValues.value[name] = filterConfig.default ?? null
|
|
@@ -459,7 +477,9 @@ export function useListFilters(deps: UseListFiltersDeps): UseListFiltersReturn {
|
|
|
459
477
|
filterDef.component || (shouldCache ? 'dropdown' : 'autocomplete')
|
|
460
478
|
const allLabel =
|
|
461
479
|
filterDef.allLabel || filterDef.placeholder || `All ${snakeToTitle(filterName)}`
|
|
462
|
-
|
|
480
|
+
// Neither allLabel nor placeholder given: "All <field>" from the catalogue at render (#4692)
|
|
481
|
+
const autoAll = !filterDef.allLabel && !!(filterDef as { _autoPlaceholder?: boolean })._autoPlaceholder
|
|
482
|
+
let finalOptions = [{ label: allLabel, value: null as unknown, ...(autoAll ? { _autoAll: true } : {}) }, ...rawOptions]
|
|
463
483
|
|
|
464
484
|
if (typeof filterDef.processor === 'function') {
|
|
465
485
|
finalOptions = filterDef.processor(finalOptions)
|
|
@@ -46,6 +46,7 @@ import { useI18n } from '../i18n/useI18n'
|
|
|
46
46
|
import { useLiveEntity } from './useLiveEntity'
|
|
47
47
|
import { formatDateOnly } from '../utils/formatters'
|
|
48
48
|
import { humanizeFieldName } from '../utils/humanize'
|
|
49
|
+
import { translateOptions, type LabeledOption } from '../i18n/optionLabels'
|
|
49
50
|
|
|
50
51
|
// Import types from dedicated types file
|
|
51
52
|
import type {
|
|
@@ -317,7 +318,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
317
318
|
// Search
|
|
318
319
|
const searchQuery = ref(savedSearch)
|
|
319
320
|
const searchConfig = ref<SearchConfig>({
|
|
320
|
-
placeholder: '
|
|
321
|
+
placeholder: '', // empty: the catalogue's core.placeholders.search, at render (#4692)
|
|
321
322
|
fields: [],
|
|
322
323
|
debounce: 300,
|
|
323
324
|
})
|
|
@@ -445,7 +446,43 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
448
|
|
|
448
|
-
|
|
449
|
+
/**
|
|
450
|
+
* One column per listable field of the entity, in the order they are
|
|
451
|
+
* declared (#4685). `password`, `textarea` and `json` fields are left out,
|
|
452
|
+
* as is any field with `listable: false`; `exclude` / `only` narrow it.
|
|
453
|
+
* A column already added keeps its own settings.
|
|
454
|
+
*/
|
|
455
|
+
// What generateColumns and the cells read of the manager
|
|
456
|
+
const columnSource = manager as unknown as {
|
|
457
|
+
getListFields?: () => Array<{ name: string; type?: string; sortable?: boolean }>
|
|
458
|
+
hasSeverityMap?: (field: string) => boolean
|
|
459
|
+
name?: string
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function generateColumns(options: { exclude?: string[]; only?: string[] } = {}): void {
|
|
463
|
+
const skip = new Set(options.exclude ?? [])
|
|
464
|
+
const only = options.only ? new Set(options.only) : null
|
|
465
|
+
for (const field of columnSource.getListFields?.() ?? []) {
|
|
466
|
+
const name = field.name
|
|
467
|
+
if (skip.has(name) || (only && !only.has(name)) || columnsMap.value.has(name)) continue
|
|
468
|
+
if (['password', 'textarea', 'json'].includes(field.type ?? '')) continue
|
|
469
|
+
addColumn(name, field.sortable ? { sortable: true } : {})
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Each column carries what ListPage needs to render its cells by type
|
|
474
|
+
// (dates, booleans, options, severity) when the page gives no #columns slot
|
|
475
|
+
const columns = computed(() =>
|
|
476
|
+
Array.from(columnsMap.value.values()).map((c) => ({
|
|
477
|
+
...c,
|
|
478
|
+
display: {
|
|
479
|
+
name: c.field,
|
|
480
|
+
...(manager.getFieldConfig(c.field) ?? {}),
|
|
481
|
+
severity: columnSource.hasSeverityMap?.(c.field) ?? false,
|
|
482
|
+
entity: columnSource.name ?? entity,
|
|
483
|
+
},
|
|
484
|
+
}))
|
|
485
|
+
)
|
|
449
486
|
|
|
450
487
|
// ============ HEADER ACTIONS ============
|
|
451
488
|
const headerActionsMap = ref<Map<string, HeaderActionConfig>>(new Map())
|
|
@@ -498,8 +535,10 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
498
535
|
const options: CreateActionOptions =
|
|
499
536
|
typeof labelOrOptions === 'string' ? { label: labelOrOptions } : labelOrOptions || {}
|
|
500
537
|
|
|
501
|
-
|
|
502
|
-
|
|
538
|
+
// Read at each render: the entity's label and the verb follow the locale (#4686)
|
|
539
|
+
const createLabel = options.label
|
|
540
|
+
? options.label
|
|
541
|
+
: () => tOr('core.actions.createEntity', 'Create {entity}', { entity: manager.label })
|
|
503
542
|
|
|
504
543
|
const onClick = options.routeName
|
|
505
544
|
? () =>
|
|
@@ -1246,7 +1285,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1246
1285
|
function addViewAction(options: Partial<ActionConfig> = {}): void {
|
|
1247
1286
|
addAction('view', {
|
|
1248
1287
|
icon: 'pi pi-eye',
|
|
1249
|
-
tooltip: tOr('core.actions.view', 'View'),
|
|
1288
|
+
tooltip: () => tOr('core.actions.view', 'View'),
|
|
1250
1289
|
onClick: options.onClick || goToShow,
|
|
1251
1290
|
...options,
|
|
1252
1291
|
})
|
|
@@ -1255,7 +1294,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1255
1294
|
function addEditAction(options: Partial<ActionConfig> = {}): void {
|
|
1256
1295
|
addAction('edit', {
|
|
1257
1296
|
icon: 'pi pi-pencil',
|
|
1258
|
-
tooltip: tOr('core.actions.edit', 'Edit'),
|
|
1297
|
+
tooltip: () => tOr('core.actions.edit', 'Edit'),
|
|
1259
1298
|
onClick: options.onClick || goToEdit,
|
|
1260
1299
|
visible: (row) => manager.canUpdate(row),
|
|
1261
1300
|
...options,
|
|
@@ -1266,7 +1305,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1266
1305
|
const labelField = options.labelField || 'name'
|
|
1267
1306
|
addAction('delete', {
|
|
1268
1307
|
icon: 'pi pi-trash',
|
|
1269
|
-
tooltip: tOr('core.actions.delete', 'Delete'),
|
|
1308
|
+
tooltip: () => tOr('core.actions.delete', 'Delete'),
|
|
1270
1309
|
severity: 'danger',
|
|
1271
1310
|
onClick: (row) => confirmDelete(row, labelField),
|
|
1272
1311
|
visible: (row) => manager.canDelete(row),
|
|
@@ -1293,6 +1332,14 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1293
1332
|
return false
|
|
1294
1333
|
})
|
|
1295
1334
|
|
|
1335
|
+
/** A filter's field label: the catalogue's, the field's, else its humanized name (#4692) */
|
|
1336
|
+
function filterFieldLabel(name: string): string {
|
|
1337
|
+
const trace = kernelI18n?.resolve(`entities.${entity}.fields.${name}`)
|
|
1338
|
+
if (trace?.hit && typeof trace.result === 'string') return trace.result
|
|
1339
|
+
const declared = (manager.getFieldConfig?.(name) as { label?: string } | null | undefined)?.label
|
|
1340
|
+
return declared || humanizeFieldName(name)
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1296
1343
|
// ============ LIST PAGE PROPS ============
|
|
1297
1344
|
|
|
1298
1345
|
const listProps = computed<ListPageProps>(() => ({
|
|
@@ -1317,8 +1364,19 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1317
1364
|
sortField: sortField.value,
|
|
1318
1365
|
sortOrder: sortOrder.value,
|
|
1319
1366
|
searchQuery: searchQuery.value,
|
|
1320
|
-
searchPlaceholder: searchConfig.value.placeholder || 'Search...',
|
|
1321
|
-
|
|
1367
|
+
searchPlaceholder: searchConfig.value.placeholder || tOr('core.placeholders.search', 'Search...'),
|
|
1368
|
+
// Static options translate as the field's do (#4686); the automatic
|
|
1369
|
+
// placeholder and "All …" follow the locale (#4692)
|
|
1370
|
+
filters: filters.value.map((f) => {
|
|
1371
|
+
const auto = f as typeof f & { _autoPlaceholder?: boolean }
|
|
1372
|
+
const label = auto._autoPlaceholder ? filterFieldLabel(f.name) : null
|
|
1373
|
+
const options = Array.isArray(f.options)
|
|
1374
|
+
? (translateOptions(kernelI18n, entity, f.name, f.options as LabeledOption[]) as LabeledOption[]).map((o) =>
|
|
1375
|
+
(o as LabeledOption & { _autoAll?: boolean })._autoAll ? { ...o, label: tOr('core.filters.all', 'All {field}', { field: filterFieldLabel(f.name) }) } : o
|
|
1376
|
+
)
|
|
1377
|
+
: f.options
|
|
1378
|
+
return { ...f, ...(label ? { placeholder: label } : {}), options: options as typeof f.options }
|
|
1379
|
+
}),
|
|
1322
1380
|
filterValues: filterValues.value,
|
|
1323
1381
|
isFilterAtDefault,
|
|
1324
1382
|
getActions,
|
|
@@ -1376,6 +1434,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1376
1434
|
columns,
|
|
1377
1435
|
column,
|
|
1378
1436
|
addColumn,
|
|
1437
|
+
generateColumns,
|
|
1379
1438
|
removeColumn,
|
|
1380
1439
|
updateColumn,
|
|
1381
1440
|
|
|
@@ -121,7 +121,8 @@ export interface FilterOptions {
|
|
|
121
121
|
options?: Array<{ label: string; value: unknown }>
|
|
122
122
|
default?: unknown
|
|
123
123
|
persist?: boolean
|
|
124
|
-
|
|
124
|
+
/** The empty choice's label; `false` for no empty choice on static options (#4692) */
|
|
125
|
+
allLabel?: string | false
|
|
125
126
|
optionsEntity?: string
|
|
126
127
|
optionsEndpoint?: string | boolean
|
|
127
128
|
optionsFromCache?: string | boolean
|
|
@@ -428,6 +429,8 @@ export interface UseListPageReturn<T = unknown> {
|
|
|
428
429
|
/** v-bind column binding helper (#1255): field + header from one source */
|
|
429
430
|
column: (name: string, overrides?: Partial<ColumnConfig>) => ColumnConfig
|
|
430
431
|
addColumn: (field: string, config?: Partial<ColumnConfig>) => void
|
|
432
|
+
/** One column per listable field of the entity (#4685). */
|
|
433
|
+
generateColumns: (options?: { exclude?: string[]; only?: string[] }) => void
|
|
431
434
|
removeColumn: (field: string) => void
|
|
432
435
|
updateColumn: (field: string, updates: Partial<ColumnConfig>) => void
|
|
433
436
|
|
|
@@ -166,8 +166,9 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
|
|
|
166
166
|
/**
|
|
167
167
|
* Get default item route for an entity manager
|
|
168
168
|
* Checks which routes actually exist and returns the appropriate one:
|
|
169
|
-
* - Prefers -
|
|
170
|
-
*
|
|
169
|
+
* - Prefers -show: a record's crumb (and a child page's "Details") opens
|
|
170
|
+
* the record, not its form (#4685)
|
|
171
|
+
* - Falls back to -edit for an entity with no show page
|
|
171
172
|
* @param manager - Entity manager
|
|
172
173
|
* @returns Route name or null if neither exists
|
|
173
174
|
*/
|
|
@@ -178,8 +179,8 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
|
|
|
178
179
|
const showRoute = `${manager.routePrefix}-show`
|
|
179
180
|
|
|
180
181
|
// Check which routes actually exist and return the first available
|
|
181
|
-
if (router.hasRoute(editRoute)) return editRoute
|
|
182
182
|
if (router.hasRoute(showRoute)) return showRoute
|
|
183
|
+
if (router.hasRoute(editRoute)) return editRoute
|
|
183
184
|
|
|
184
185
|
return null
|
|
185
186
|
}
|
|
@@ -488,7 +489,7 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
|
|
|
488
489
|
}
|
|
489
490
|
|
|
490
491
|
// Item pages (#1332): the terminal is entity-show/entity-edit — offer the
|
|
491
|
-
// OPPOSITE mode (getDefaultItemRoute's
|
|
492
|
+
// OPPOSITE mode (getDefaultItemRoute's show-preference is a landing
|
|
492
493
|
// default, not a toggle).
|
|
493
494
|
const modeToggle = computed<BreadcrumbModeToggle | null>(() => {
|
|
494
495
|
void i18nLocale.value // label re-resolves on locale change
|
|
@@ -474,10 +474,25 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
474
474
|
|
|
475
475
|
// ============ METADATA ACCESSORS ============
|
|
476
476
|
|
|
477
|
+
/**
|
|
478
|
+
* `entities.<name>.label` / `labelPlural` in the app's catalogue (#4686).
|
|
479
|
+
* The catalogue wins over the `label` option, as it does for field labels;
|
|
480
|
+
* it reads the reactive locale, so a title computed from it follows a
|
|
481
|
+
* locale change.
|
|
482
|
+
*/
|
|
483
|
+
protected _catalogueLabel(key: 'label' | 'labelPlural'): string | null {
|
|
484
|
+
const i18n = this._orchestrator?.i18n
|
|
485
|
+
if (!i18n || !this.name) return null
|
|
486
|
+
const trace = i18n.resolve(`entities.${this.name}.${key}`)
|
|
487
|
+
return trace.hit && typeof trace.result === 'string' ? trace.result : null
|
|
488
|
+
}
|
|
489
|
+
|
|
477
490
|
/**
|
|
478
491
|
* Get entity label (singular)
|
|
479
492
|
*/
|
|
480
493
|
get label(): string {
|
|
494
|
+
const translated = this._catalogueLabel('label')
|
|
495
|
+
if (translated) return translated
|
|
481
496
|
if (this._label) return this._label
|
|
482
497
|
if (!this.name) return 'Item'
|
|
483
498
|
const singular = pluralize.singular(this.name)
|
|
@@ -488,6 +503,8 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
488
503
|
* Get entity label (plural)
|
|
489
504
|
*/
|
|
490
505
|
get labelPlural(): string {
|
|
506
|
+
const translated = this._catalogueLabel('labelPlural')
|
|
507
|
+
if (translated) return translated
|
|
491
508
|
if (this._labelPlural) return this._labelPlural
|
|
492
509
|
if (!this.name) return 'Items'
|
|
493
510
|
const plural = pluralize.plural(this.name)
|
|
@@ -342,6 +342,8 @@ export interface Orchestrator {
|
|
|
342
342
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
343
343
|
kernel?: any
|
|
344
344
|
deferred?: DeferredRegistry | null
|
|
345
|
+
/** The app's catalogue (#4686) */
|
|
346
|
+
i18n?: { resolve: (key: string) => { hit: boolean; result: string } } | null
|
|
345
347
|
}
|
|
346
348
|
|
|
347
349
|
// Forward declaration for DeferredRegistry
|
|
@@ -17,6 +17,13 @@ export interface MockApiStorageOptions<T extends EntityRecord = EntityRecord> {
|
|
|
17
17
|
* Needed when several apps sharing an origin use the same entity names
|
|
18
18
|
* (e.g. multiple demos on one GitHub Pages site) (#1382). */
|
|
19
19
|
storageKey?: string
|
|
20
|
+
/**
|
|
21
|
+
* Behave like a remote server (#4687): each call waits `latency` ms (a
|
|
22
|
+
* number, or `[min, max]` for a random wait) and fails with a 503 at the
|
|
23
|
+
* `failRate` (0 to 1). Off by default.
|
|
24
|
+
*/
|
|
25
|
+
latency?: number | [number, number]
|
|
26
|
+
failRate?: number
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
@@ -58,6 +65,8 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
58
65
|
protected _storageKey: string
|
|
59
66
|
protected _data: Map<string, T>
|
|
60
67
|
protected _authCheck: (() => boolean) | null
|
|
68
|
+
protected _latency: number | [number, number]
|
|
69
|
+
protected _failRate: number
|
|
61
70
|
|
|
62
71
|
constructor(options: MockApiStorageOptions<T>) {
|
|
63
72
|
super()
|
|
@@ -68,6 +77,8 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
68
77
|
initialData = null,
|
|
69
78
|
authCheck = null,
|
|
70
79
|
storageKey = null,
|
|
80
|
+
latency = 0,
|
|
81
|
+
failRate = 0,
|
|
71
82
|
} = options
|
|
72
83
|
|
|
73
84
|
if (!entityName) {
|
|
@@ -80,10 +91,23 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
80
91
|
this._storageKey = storageKey || `mockapi_${entityName}_data`
|
|
81
92
|
this._data = new Map()
|
|
82
93
|
this._authCheck = authCheck
|
|
94
|
+
this._latency = latency
|
|
95
|
+
this._failRate = failRate
|
|
83
96
|
|
|
84
97
|
this._loadFromStorage(initialData)
|
|
85
98
|
}
|
|
86
99
|
|
|
100
|
+
/** The simulated network: the wait, then maybe a failure, then the auth check */
|
|
101
|
+
protected async _call(): Promise<void> {
|
|
102
|
+
const [min, max] = Array.isArray(this._latency) ? this._latency : [this._latency, this._latency]
|
|
103
|
+
const wait = min + Math.random() * Math.max(0, max - min)
|
|
104
|
+
if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait))
|
|
105
|
+
if (this._failRate > 0 && Math.random() < this._failRate) {
|
|
106
|
+
throw new StorageError(`Service unavailable (simulated failure of ${this.entityName})`, 503)
|
|
107
|
+
}
|
|
108
|
+
this._checkAuth()
|
|
109
|
+
}
|
|
110
|
+
|
|
87
111
|
protected _checkAuth(): void {
|
|
88
112
|
if (this._authCheck && !this._authCheck()) {
|
|
89
113
|
throw new StorageError(
|
|
@@ -139,7 +163,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
139
163
|
}
|
|
140
164
|
|
|
141
165
|
async list(params: ListParams = {}): Promise<ListResult<T>> {
|
|
142
|
-
this.
|
|
166
|
+
await this._call()
|
|
143
167
|
const { page = 1, page_size = 20, sort_by, sort_order = 'asc', filters = {}, search } = params
|
|
144
168
|
|
|
145
169
|
let items = this._getAll()
|
|
@@ -163,7 +187,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
163
187
|
}
|
|
164
188
|
|
|
165
189
|
async get(id: string | number): Promise<T> {
|
|
166
|
-
this.
|
|
190
|
+
await this._call()
|
|
167
191
|
const item = this._data.get(String(id))
|
|
168
192
|
if (!item) {
|
|
169
193
|
throw new StorageError(`Entity not found: ${id}`, 404)
|
|
@@ -172,7 +196,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
172
196
|
}
|
|
173
197
|
|
|
174
198
|
async getMany(ids: Array<string | number>): Promise<T[]> {
|
|
175
|
-
this.
|
|
199
|
+
await this._call()
|
|
176
200
|
if (!ids || ids.length === 0) return []
|
|
177
201
|
const results: T[] = []
|
|
178
202
|
for (const id of ids) {
|
|
@@ -215,7 +239,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
215
239
|
}
|
|
216
240
|
|
|
217
241
|
async create(data: Partial<T>): Promise<T> {
|
|
218
|
-
this.
|
|
242
|
+
await this._call()
|
|
219
243
|
const id =
|
|
220
244
|
(data[this.idField as keyof T] as string | number | undefined) || this.generateId()
|
|
221
245
|
const newItem = {
|
|
@@ -229,7 +253,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
229
253
|
}
|
|
230
254
|
|
|
231
255
|
async update(id: string | number, data: Partial<T>): Promise<T> {
|
|
232
|
-
this.
|
|
256
|
+
await this._call()
|
|
233
257
|
if (!this._data.has(String(id))) {
|
|
234
258
|
throw new StorageError(`Entity not found: ${id}`, 404)
|
|
235
259
|
}
|
|
@@ -244,7 +268,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
244
268
|
}
|
|
245
269
|
|
|
246
270
|
async patch(id: string | number, data: Partial<T>): Promise<T> {
|
|
247
|
-
this.
|
|
271
|
+
await this._call()
|
|
248
272
|
const existing = this._data.get(String(id))
|
|
249
273
|
if (!existing) {
|
|
250
274
|
throw new StorageError(`Entity not found: ${id}`, 404)
|
|
@@ -260,7 +284,7 @@ export class MockApiStorage<T extends EntityRecord = EntityRecord> extends IStor
|
|
|
260
284
|
}
|
|
261
285
|
|
|
262
286
|
async delete(id: string | number): Promise<void> {
|
|
263
|
-
this.
|
|
287
|
+
await this._call()
|
|
264
288
|
if (!this._data.has(String(id))) {
|
|
265
289
|
throw new StorageError(`Entity not found: ${id}`, 404)
|
|
266
290
|
}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/* GENERATED from core.en.yml — DO NOT EDIT.
|
|
2
2
|
* Run `npm run gen:i18n-defaults -w packages/qdadm` to regenerate. */
|
|
3
3
|
export default `core:
|
|
4
|
+
# A filter's "all" choice (#4692)
|
|
5
|
+
filters:
|
|
6
|
+
all: "All {field}"
|
|
7
|
+
# The table's own column headers (#4686)
|
|
8
|
+
table:
|
|
9
|
+
actions: Actions
|
|
10
|
+
# Boolean values (#4686)
|
|
11
|
+
values:
|
|
12
|
+
"yes": "Yes"
|
|
13
|
+
"no": "No"
|
|
4
14
|
actions:
|
|
5
15
|
save: Save
|
|
6
16
|
cancel: Cancel
|
|
7
17
|
delete: Delete
|
|
8
18
|
edit: Edit
|
|
9
19
|
create: Create
|
|
20
|
+
createEntity: "Create {entity}"
|
|
10
21
|
update: Update
|
|
11
22
|
createAndClose: Create & Close
|
|
12
23
|
updateAndClose: Update & Close
|
|
@@ -158,6 +169,8 @@ export default `core:
|
|
|
158
169
|
close: Close
|
|
159
170
|
background: Run in the background
|
|
160
171
|
open: Open the task
|
|
172
|
+
follow: Follow
|
|
173
|
+
notRun: Not run yet
|
|
161
174
|
readError: "Could not read the task ({error}), still trying"
|
|
162
175
|
start: Start
|
|
163
176
|
dontStart: Do not start
|
|
@@ -176,6 +189,25 @@ export default `core:
|
|
|
176
189
|
subs: "{count} sub-phase | {count} sub-phases"
|
|
177
190
|
filter: "Phase: {name}"
|
|
178
191
|
showAll: Show the whole log
|
|
192
|
+
# Tasks chained in one window (#4934)
|
|
193
|
+
sequence:
|
|
194
|
+
progress: "{done}/{total}"
|
|
195
|
+
step: "Step {n}"
|
|
196
|
+
pending: Waiting
|
|
197
|
+
skipped: Not run
|
|
198
|
+
why:
|
|
199
|
+
error: An earlier step failed
|
|
200
|
+
cancelled: The sequence was stopped
|
|
201
|
+
reload: The page was reloaded
|
|
202
|
+
back: Back to the list
|
|
203
|
+
details: Show this step
|
|
204
|
+
cancel: Stop the sequence
|
|
205
|
+
# Waiting states (#4665)
|
|
206
|
+
pending:
|
|
207
|
+
reading: Reading…
|
|
208
|
+
unavailable: Unavailable
|
|
209
|
+
failed: "Could not read: {error}"
|
|
210
|
+
retry: Retry
|
|
179
211
|
# LoginPage (#4168)
|
|
180
212
|
login:
|
|
181
213
|
username: Username
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
core:
|
|
2
|
+
# A filter's "all" choice (#4692)
|
|
3
|
+
filters:
|
|
4
|
+
all: "All {field}"
|
|
5
|
+
# The table's own column headers (#4686)
|
|
6
|
+
table:
|
|
7
|
+
actions: Actions
|
|
8
|
+
# Boolean values (#4686)
|
|
9
|
+
values:
|
|
10
|
+
"yes": "Yes"
|
|
11
|
+
"no": "No"
|
|
2
12
|
actions:
|
|
3
13
|
save: Save
|
|
4
14
|
cancel: Cancel
|
|
5
15
|
delete: Delete
|
|
6
16
|
edit: Edit
|
|
7
17
|
create: Create
|
|
18
|
+
createEntity: "Create {entity}"
|
|
8
19
|
update: Update
|
|
9
20
|
createAndClose: Create & Close
|
|
10
21
|
updateAndClose: Update & Close
|
|
@@ -156,6 +167,8 @@ core:
|
|
|
156
167
|
close: Close
|
|
157
168
|
background: Run in the background
|
|
158
169
|
open: Open the task
|
|
170
|
+
follow: Follow
|
|
171
|
+
notRun: Not run yet
|
|
159
172
|
readError: "Could not read the task ({error}), still trying"
|
|
160
173
|
start: Start
|
|
161
174
|
dontStart: Do not start
|
|
@@ -174,6 +187,25 @@ core:
|
|
|
174
187
|
subs: "{count} sub-phase | {count} sub-phases"
|
|
175
188
|
filter: "Phase: {name}"
|
|
176
189
|
showAll: Show the whole log
|
|
190
|
+
# Tasks chained in one window (#4934)
|
|
191
|
+
sequence:
|
|
192
|
+
progress: "{done}/{total}"
|
|
193
|
+
step: "Step {n}"
|
|
194
|
+
pending: Waiting
|
|
195
|
+
skipped: Not run
|
|
196
|
+
why:
|
|
197
|
+
error: An earlier step failed
|
|
198
|
+
cancelled: The sequence was stopped
|
|
199
|
+
reload: The page was reloaded
|
|
200
|
+
back: Back to the list
|
|
201
|
+
details: Show this step
|
|
202
|
+
cancel: Stop the sequence
|
|
203
|
+
# Waiting states (#4665)
|
|
204
|
+
pending:
|
|
205
|
+
reading: Reading…
|
|
206
|
+
unavailable: Unavailable
|
|
207
|
+
failed: "Could not read: {error}"
|
|
208
|
+
retry: Retry
|
|
177
209
|
# LoginPage (#4168)
|
|
178
210
|
login:
|
|
179
211
|
username: Username
|