@quazardous/qdadm 2.48.0 → 2.50.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/chain/StackHydrator.ts +82 -0
- package/src/components/dialogs/QdRevealOnce.vue +163 -0
- package/src/components/display/LogStream.vue +2 -28
- package/src/components/edit/FormPage.vue +9 -1
- package/src/components/index.ts +2 -0
- package/src/components/layout/EntityItemLayout.vue +120 -0
- package/src/components/layout/PageNav.vue +24 -2
- package/src/composables/useEntityItemFormPage.ts +45 -1
- package/src/composables/useEntityItemFormPage.types.ts +15 -0
- package/src/composables/useLiveEntity.ts +3 -1
- package/src/composables/useNavContext.ts +13 -2
- package/src/composables/useNavigation.ts +3 -4
- package/src/entity/EntityManager.cache.ts +49 -8
- package/src/entity/EntityManager.crud.ts +48 -5
- package/src/entity/EntityManager.interface.ts +10 -0
- package/src/entity/EntityManager.ts +21 -0
- package/src/entity/EntityManager.types.ts +28 -0
- package/src/i18n/defaults/core.en.generated.ts +8 -0
- package/src/i18n/defaults/core.en.yml +8 -0
- package/src/i18n/defaults/core.fr.generated.ts +8 -0
- package/src/i18n/defaults/core.fr.yml +8 -0
- package/src/index.ts +3 -1
- package/src/kernel/Kernel.routing.ts +22 -31
- package/src/kernel/KernelContext.routing.ts +9 -0
- package/src/kernel/KernelContext.ts +3 -0
- package/src/kernel/KernelContext.types.ts +6 -0
- package/src/kernel/itemTabs.ts +99 -0
- package/src/module/moduleRegistry.ts +26 -0
- package/src/security/index.ts +1 -0
- package/src/security/routeAccess.ts +94 -0
- package/src/styles/_item-tabs.scss +52 -0
- package/src/styles/index.scss +1 -0
- package/src/tasks/taskStore.ts +92 -2
- package/src/utils/clipboard.ts +36 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* QdRevealOnce - the values a create revealed once (#5319)
|
|
4
|
+
*
|
|
5
|
+
* A key's token, a generated password: the API hands it back once and keeps
|
|
6
|
+
* only its hash. This dialog shows each value with a copy button and a
|
|
7
|
+
* warning, and closes only on "I have copied it". It keeps nothing: the
|
|
8
|
+
* values live in its props, and whoever gives them clears them on `confirm`.
|
|
9
|
+
*
|
|
10
|
+
* FormPage renders it after a create whose entity declares `revealOnce`.
|
|
11
|
+
* A custom page binds it to the form's `revealed` / `confirmRevealed`:
|
|
12
|
+
*
|
|
13
|
+
* <QdRevealOnce :revealed="form.revealed.value" @confirm="form.confirmRevealed" />
|
|
14
|
+
*
|
|
15
|
+
* Labels: `entities.<entity>.reveal.<key>`, else the key.
|
|
16
|
+
*/
|
|
17
|
+
import { computed, inject, ref, watch } from 'vue'
|
|
18
|
+
import Dialog from 'primevue/dialog'
|
|
19
|
+
import QdButton from '../base/QdButton.vue'
|
|
20
|
+
import QdMessage from '../base/QdMessage.vue'
|
|
21
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
22
|
+
import { copyText } from '../../utils/clipboard'
|
|
23
|
+
import type { RevealedValues } from '../../composables/useEntityItemFormPage.types'
|
|
24
|
+
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
revealed: RevealedValues | null
|
|
27
|
+
}>()
|
|
28
|
+
|
|
29
|
+
const emit = defineEmits<{
|
|
30
|
+
confirm: []
|
|
31
|
+
}>()
|
|
32
|
+
|
|
33
|
+
const { t, tOr } = useI18n()
|
|
34
|
+
const orchestrator = inject<{ get: (name: string) => { label?: string } | null } | null>('qdadmOrchestrator', null)
|
|
35
|
+
|
|
36
|
+
const rows = computed(() => {
|
|
37
|
+
const r = props.revealed
|
|
38
|
+
if (!r) return []
|
|
39
|
+
return Object.entries(r.values).map(([key, value]) => ({
|
|
40
|
+
key,
|
|
41
|
+
label: tOr(`entities.${r.entity}.reveal.${key}`, key),
|
|
42
|
+
text: typeof value === 'string' ? value : JSON.stringify(value),
|
|
43
|
+
}))
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const title = computed(() => {
|
|
47
|
+
const r = props.revealed
|
|
48
|
+
if (!r) return ''
|
|
49
|
+
let label: string = r.entity
|
|
50
|
+
try {
|
|
51
|
+
label = orchestrator?.get(r.entity)?.label || r.entity
|
|
52
|
+
} catch {
|
|
53
|
+
// An entity the orchestrator does not know: its name will do
|
|
54
|
+
}
|
|
55
|
+
return t('core.revealOnce.title', { entity: label })
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/** Per key: what the last copy said */
|
|
59
|
+
const status = ref<Record<string, { ok: boolean; text: string }>>({})
|
|
60
|
+
watch(
|
|
61
|
+
() => props.revealed,
|
|
62
|
+
() => (status.value = {})
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
async function copy(key: string, text: string): Promise<void> {
|
|
66
|
+
try {
|
|
67
|
+
await copyText(text)
|
|
68
|
+
status.value = { ...status.value, [key]: { ok: true, text: t('core.revealOnce.copied') } }
|
|
69
|
+
} catch (err) {
|
|
70
|
+
status.value = {
|
|
71
|
+
...status.value,
|
|
72
|
+
[key]: { ok: false, text: t('core.revealOnce.copyFailed', { error: (err as Error)?.message ?? String(err) }) },
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function confirm(): void {
|
|
78
|
+
status.value = {}
|
|
79
|
+
emit('confirm')
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<template>
|
|
84
|
+
<Dialog
|
|
85
|
+
:visible="!!revealed"
|
|
86
|
+
:header="title"
|
|
87
|
+
modal
|
|
88
|
+
:closable="false"
|
|
89
|
+
:closeOnEscape="false"
|
|
90
|
+
:dismissableMask="false"
|
|
91
|
+
:style="{ width: '560px', maxWidth: '95vw' }"
|
|
92
|
+
class="qd-reveal-once"
|
|
93
|
+
>
|
|
94
|
+
<QdMessage severity="warn" :closable="false" class="qd-reveal-once-warning">
|
|
95
|
+
{{ t('core.revealOnce.warning') }}
|
|
96
|
+
</QdMessage>
|
|
97
|
+
<div v-for="row in rows" :key="row.key" class="qd-reveal-once-row">
|
|
98
|
+
<div class="qd-reveal-once-label">{{ row.label }}</div>
|
|
99
|
+
<div class="qd-reveal-once-value-line">
|
|
100
|
+
<code class="qd-reveal-once-value" :data-key="row.key">{{ row.text }}</code>
|
|
101
|
+
<QdButton
|
|
102
|
+
:label="t('core.revealOnce.copy')"
|
|
103
|
+
icon="pi pi-copy"
|
|
104
|
+
size="small"
|
|
105
|
+
severity="secondary"
|
|
106
|
+
class="qd-reveal-once-copy"
|
|
107
|
+
@click="copy(row.key, row.text)"
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
v-if="status[row.key]"
|
|
112
|
+
class="qd-reveal-once-status"
|
|
113
|
+
:class="status[row.key]?.ok ? 'qd-reveal-once-status--ok' : 'qd-reveal-once-status--failed'"
|
|
114
|
+
role="status"
|
|
115
|
+
>
|
|
116
|
+
{{ status[row.key]?.text }}
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
<template #footer>
|
|
120
|
+
<QdButton :label="t('core.revealOnce.confirm')" icon="pi pi-check" class="qd-reveal-once-confirm" @click="confirm" />
|
|
121
|
+
</template>
|
|
122
|
+
</Dialog>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<style scoped>
|
|
126
|
+
.qd-reveal-once-warning {
|
|
127
|
+
margin: 0 0 1rem;
|
|
128
|
+
}
|
|
129
|
+
.qd-reveal-once-row + .qd-reveal-once-row {
|
|
130
|
+
margin-top: 1rem;
|
|
131
|
+
}
|
|
132
|
+
.qd-reveal-once-label {
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
margin-bottom: 0.35rem;
|
|
135
|
+
}
|
|
136
|
+
.qd-reveal-once-value-line {
|
|
137
|
+
display: flex;
|
|
138
|
+
gap: 0.5rem;
|
|
139
|
+
align-items: center;
|
|
140
|
+
}
|
|
141
|
+
.qd-reveal-once-value {
|
|
142
|
+
flex: 1;
|
|
143
|
+
min-width: 0;
|
|
144
|
+
padding: 0.5rem 0.65rem;
|
|
145
|
+
border: 1px solid var(--p-content-border-color, #d1d5db);
|
|
146
|
+
border-radius: 6px;
|
|
147
|
+
background: var(--p-content-hover-background, #f3f4f6);
|
|
148
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
149
|
+
font-size: 0.875rem;
|
|
150
|
+
word-break: break-all;
|
|
151
|
+
user-select: all;
|
|
152
|
+
}
|
|
153
|
+
.qd-reveal-once-status {
|
|
154
|
+
margin-top: 0.3rem;
|
|
155
|
+
font-size: 0.8125rem;
|
|
156
|
+
}
|
|
157
|
+
.qd-reveal-once-status--ok {
|
|
158
|
+
color: var(--p-green-600, #16a34a);
|
|
159
|
+
}
|
|
160
|
+
.qd-reveal-once-status--failed {
|
|
161
|
+
color: var(--p-red-600, #dc2626);
|
|
162
|
+
}
|
|
163
|
+
</style>
|
|
@@ -24,6 +24,7 @@ import InputText from 'primevue/inputtext'
|
|
|
24
24
|
import QdButton from '../base/QdButton.vue'
|
|
25
25
|
import { useI18n } from '../../i18n/useI18n'
|
|
26
26
|
import { ansiStyleToCss } from '../../utils/ansi'
|
|
27
|
+
import { copyText } from '../../utils/clipboard'
|
|
27
28
|
import { useLogStream, type LogLine, type LogSource, type UseLogStreamReturn } from '../../composables/useLogStream'
|
|
28
29
|
import { linesOfPhase } from '../../tasks/taskPhases'
|
|
29
30
|
|
|
@@ -298,40 +299,13 @@ function download(): void {
|
|
|
298
299
|
const copyStatus = ref<{ ok: boolean; text: string } | null>(null)
|
|
299
300
|
let copyTimer: ReturnType<typeof setTimeout> | null = null
|
|
300
301
|
|
|
301
|
-
/** Without navigator.clipboard (a page served over plain http): a selected textarea */
|
|
302
|
-
function copyByCommand(text: string): void {
|
|
303
|
-
const area = document.createElement('textarea')
|
|
304
|
-
area.value = text
|
|
305
|
-
area.setAttribute('readonly', '')
|
|
306
|
-
area.style.position = 'fixed'
|
|
307
|
-
area.style.opacity = '0'
|
|
308
|
-
document.body.appendChild(area)
|
|
309
|
-
const focused = document.activeElement as HTMLElement | null
|
|
310
|
-
area.select()
|
|
311
|
-
try {
|
|
312
|
-
if (!document.execCommand?.('copy')) throw new Error('the browser refused to copy')
|
|
313
|
-
} finally {
|
|
314
|
-
area.remove()
|
|
315
|
-
focused?.focus?.()
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
302
|
/** Every line received at this moment, as plain text; resolves to the line count. */
|
|
320
303
|
async function copy(): Promise<number> {
|
|
321
304
|
// Taken now: lines streaming in during the write are not part of it
|
|
322
305
|
const lines = log.lines.value.map((l) => l.text)
|
|
323
306
|
const text = lines.join('\n')
|
|
324
307
|
try {
|
|
325
|
-
|
|
326
|
-
if (!navigator.clipboard?.writeText) throw new Error('no clipboard on this page (it needs HTTPS)')
|
|
327
|
-
await navigator.clipboard.writeText(text)
|
|
328
|
-
} catch (err) {
|
|
329
|
-
try {
|
|
330
|
-
copyByCommand(text)
|
|
331
|
-
} catch {
|
|
332
|
-
throw err
|
|
333
|
-
}
|
|
334
|
-
}
|
|
308
|
+
await copyText(text)
|
|
335
309
|
copyStatus.value = { ok: true, text: t('core.log.copied', { count: lines.length }) }
|
|
336
310
|
} catch (err) {
|
|
337
311
|
copyStatus.value = { ok: false, text: t('core.log.copyFailed', { error: (err as Error)?.message ?? String(err) }) }
|
|
@@ -37,11 +37,12 @@ import { GUARD_DIALOG_HOST } from '../../composables/useGuardStore'
|
|
|
37
37
|
import PageHeader from '../layout/PageHeader.vue'
|
|
38
38
|
import FormActions from './FormActions.vue'
|
|
39
39
|
import UnsavedChangesDialog from '../dialogs/UnsavedChangesDialog.vue'
|
|
40
|
+
import QdRevealOnce from '../dialogs/QdRevealOnce.vue'
|
|
40
41
|
import CardShell from '../layout/CardShell.vue'
|
|
41
42
|
import { formatFetchError } from '../../utils/errors'
|
|
42
43
|
import QdButton from '../base/QdButton.vue'
|
|
43
44
|
import QdMessage from '../base/QdMessage.vue'
|
|
44
|
-
import type { ResolvedAction, ResolvedFieldConfig } from '../../composables/useEntityItemFormPage'
|
|
45
|
+
import type { ResolvedAction, ResolvedFieldConfig, RevealedValues } from '../../composables/useEntityItemFormPage'
|
|
45
46
|
import type { GuardDialogState } from '../../composables/useUnsavedChangesGuard'
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -99,6 +100,9 @@ const props = defineProps({
|
|
|
99
100
|
// Guard dialog (from useUnsavedChangesGuard)
|
|
100
101
|
guardDialog: { type: Object as PropType<GuardDialogState | null>, default: null },
|
|
101
102
|
|
|
103
|
+
// Values a create revealed once (#5319), shown until confirmed
|
|
104
|
+
revealed: { type: Object as PropType<RevealedValues | null>, default: null },
|
|
105
|
+
|
|
102
106
|
// Error for fetch failures (separate from validation errors)
|
|
103
107
|
fetchError: { type: [String, Object] as PropType<string | FetchError | null>, default: null },
|
|
104
108
|
|
|
@@ -113,6 +117,7 @@ const emit = defineEmits<{
|
|
|
113
117
|
(e: 'saveAndClose'): void
|
|
114
118
|
(e: 'cancel'): void
|
|
115
119
|
(e: 'delete'): void
|
|
120
|
+
(e: 'revealConfirmed'): void
|
|
116
121
|
}>()
|
|
117
122
|
|
|
118
123
|
// Header actions: all actions except save, delete, cancel (those go in footer)
|
|
@@ -238,5 +243,8 @@ function onGuardStay(): void {
|
|
|
238
243
|
@leave="onGuardLeave"
|
|
239
244
|
@stay="onGuardStay"
|
|
240
245
|
/>
|
|
246
|
+
|
|
247
|
+
<!-- Values a create revealed once (#5319) -->
|
|
248
|
+
<QdRevealOnce :revealed="revealed" @confirm="emit('revealConfirmed')" />
|
|
241
249
|
</div>
|
|
242
250
|
</template>
|
package/src/components/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { default as PageLayout } from './layout/PageLayout.vue'
|
|
|
14
14
|
export { default as PageHeader } from './layout/PageHeader.vue'
|
|
15
15
|
export { default as Breadcrumb } from './layout/Breadcrumb.vue'
|
|
16
16
|
export { default as PageNav } from './layout/PageNav.vue'
|
|
17
|
+
export { default as EntityItemLayout } from './layout/EntityItemLayout.vue'
|
|
17
18
|
export { default as Zone } from './layout/Zone.vue'
|
|
18
19
|
export { default as CardsDashboard } from './layout/CardsDashboard.vue'
|
|
19
20
|
export { default as SidebarBox } from './layout/SidebarBox.vue'
|
|
@@ -66,6 +67,7 @@ export { default as SimpleDialog } from './dialogs/SimpleDialog.vue'
|
|
|
66
67
|
export { default as MultiStepDialog } from './dialogs/MultiStepDialog.vue'
|
|
67
68
|
export { default as BulkStatusDialog } from './dialogs/BulkStatusDialog.vue'
|
|
68
69
|
export { default as UnsavedChangesDialog } from './dialogs/UnsavedChangesDialog.vue'
|
|
70
|
+
export { default as QdRevealOnce } from './dialogs/QdRevealOnce.vue'
|
|
69
71
|
|
|
70
72
|
// Display
|
|
71
73
|
export { default as CardsGrid } from './display/CardsGrid.vue'
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* EntityItemLayout - a tabbed item (#4963)
|
|
4
|
+
*
|
|
5
|
+
* The frame of `ctx.itemTabs(entity)`: the item's header, one tab per page of
|
|
6
|
+
* the item (its own page as "Details", its child pages and child lists, in
|
|
7
|
+
* declaration order, those the user may open), and the page in a
|
|
8
|
+
* `router-view`. A tab switch changes only the page: the header stays, and the
|
|
9
|
+
* item comes from the active stack, which reads it again when it is
|
|
10
|
+
* invalidated (#4960).
|
|
11
|
+
*
|
|
12
|
+
* Inside it, `<PageNav/>` stays silent: the tabs are the navigation.
|
|
13
|
+
*/
|
|
14
|
+
import { computed, inject, provide, type Component } from 'vue'
|
|
15
|
+
import { RouterLink, RouterView, useRoute, useRouter, type RouteRecordNormalized, type RouteRecordRaw } from 'vue-router'
|
|
16
|
+
import { useStackHydrator } from '../../chain/useStackHydrator'
|
|
17
|
+
import { useI18n } from '../../i18n/useI18n'
|
|
18
|
+
import { canOpenRoute, type RouteAccessDeps } from '../../security/routeAccess'
|
|
19
|
+
import type { ItemTabsMeta } from '../../kernel/itemTabs'
|
|
20
|
+
|
|
21
|
+
interface ManagerView {
|
|
22
|
+
label?: string
|
|
23
|
+
labelPlural?: string
|
|
24
|
+
getEntityLabel?: (item: unknown) => string | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const route = useRoute()
|
|
28
|
+
const router = useRouter()
|
|
29
|
+
const { tOr } = useI18n()
|
|
30
|
+
const hydrator = useStackHydrator()
|
|
31
|
+
const orchestrator = inject<(RouteAccessDeps['orchestrator'] & { get: (name: string) => unknown }) | null>('qdadmOrchestrator', null)
|
|
32
|
+
const checker = inject<RouteAccessDeps['checker']>('qdadmSecurityChecker', null)
|
|
33
|
+
|
|
34
|
+
provide('qdadmItemTabs', true)
|
|
35
|
+
|
|
36
|
+
/** This frame's record: the innermost matched record carrying meta.itemTabs */
|
|
37
|
+
const frame = computed<RouteRecordNormalized | undefined>(() => [...route.matched].reverse().find((r) => r.meta?.itemTabs))
|
|
38
|
+
const config = computed(() => frame.value?.meta.itemTabs as ItemTabsMeta | undefined)
|
|
39
|
+
const manager = computed(() => (config.value ? (orchestrator?.get(config.value.entity) as ManagerView | null) : null))
|
|
40
|
+
const id = computed(() => (config.value ? (route.params[config.value.param] as string | undefined) ?? null : null))
|
|
41
|
+
|
|
42
|
+
// Read through the levels array each time: the stack replaces it on every
|
|
43
|
+
// hydration, while a level object keeps its identity as its data changes
|
|
44
|
+
const findLevel = () =>
|
|
45
|
+
hydrator.levels.value.find((l) => l.entity === config.value?.entity && String(l.id) === String(id.value)) ?? null
|
|
46
|
+
const item = computed(() => findLevel()?.data ?? null)
|
|
47
|
+
const loading = computed(() => !findLevel()?.hydrated)
|
|
48
|
+
const title = computed(() => (item.value ? manager.value?.getEntityLabel?.(item.value) : null) ?? id.value ?? '')
|
|
49
|
+
|
|
50
|
+
interface Tab {
|
|
51
|
+
name: string
|
|
52
|
+
label: string
|
|
53
|
+
href: string
|
|
54
|
+
exact: boolean
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function tabLabel(child: RouteRecordRaw): string {
|
|
58
|
+
if (child.path === '') {
|
|
59
|
+
const details = config.value?.details
|
|
60
|
+
return typeof details === 'string' ? details : tOr('breadcrumb.details', 'Details')
|
|
61
|
+
}
|
|
62
|
+
const meta = (child.meta ?? {}) as { navLabel?: string; entity?: string }
|
|
63
|
+
if (meta.navLabel) return meta.navLabel
|
|
64
|
+
const childManager = meta.entity ? (orchestrator?.get(meta.entity) as ManagerView | null) : null
|
|
65
|
+
return childManager?.labelPlural || String(child.name)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const tabs = computed<Tab[]>(() => {
|
|
69
|
+
const children = (frame.value?.children ?? []) as RouteRecordRaw[]
|
|
70
|
+
const out: Tab[] = []
|
|
71
|
+
for (const child of children) {
|
|
72
|
+
if (typeof child.name !== 'string' || child.redirect) continue
|
|
73
|
+
// Forms and a child's own record are not tabs: they open from the tab's page
|
|
74
|
+
if (/-(create|edit|new|show)$/.test(child.name) && child.path !== '') continue
|
|
75
|
+
if (child.path.includes(':')) continue
|
|
76
|
+
if (child.path === '' && config.value?.details === false) continue
|
|
77
|
+
let resolved
|
|
78
|
+
try {
|
|
79
|
+
resolved = router.resolve({ name: child.name, params: route.params })
|
|
80
|
+
} catch {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
if (!canOpenRoute(resolved, { orchestrator, checker })) continue
|
|
84
|
+
out.push({ name: child.name, label: tabLabel(child), href: resolved.path, exact: child.path === '' })
|
|
85
|
+
}
|
|
86
|
+
return out
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
const isActive = (tab: Tab): boolean =>
|
|
90
|
+
tab.exact ? route.path === tab.href : route.path === tab.href || route.path.startsWith(`${tab.href}/`)
|
|
91
|
+
|
|
92
|
+
const header = computed(() => config.value?.header as Component | undefined)
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<template>
|
|
96
|
+
<div class="qd-item-tabs">
|
|
97
|
+
<header class="qd-item-tabs-header">
|
|
98
|
+
<component :is="header" v-if="header" :item="item" :manager="manager" :loading="loading" :id="id" />
|
|
99
|
+
<template v-else>
|
|
100
|
+
<span v-if="manager?.label" class="qd-item-tabs-entity">{{ manager.label }}</span>
|
|
101
|
+
<h1 class="qd-item-tabs-title">{{ title }}</h1>
|
|
102
|
+
</template>
|
|
103
|
+
</header>
|
|
104
|
+
<nav v-if="tabs.length > 1" class="qd-item-tabs-bar" :aria-label="title">
|
|
105
|
+
<RouterLink
|
|
106
|
+
v-for="tab in tabs"
|
|
107
|
+
:key="tab.name"
|
|
108
|
+
:to="tab.href"
|
|
109
|
+
class="qd-item-tabs-tab"
|
|
110
|
+
:class="{ 'qd-item-tabs-tab--active': isActive(tab) }"
|
|
111
|
+
:aria-current="isActive(tab) ? 'page' : undefined"
|
|
112
|
+
>
|
|
113
|
+
{{ tab.label }}
|
|
114
|
+
</RouterLink>
|
|
115
|
+
</nav>
|
|
116
|
+
<div class="qd-item-tabs-page">
|
|
117
|
+
<RouterView />
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</template>
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* Auto-detects from current route:
|
|
13
13
|
* - Navlinks: sibling routes (same parent entity + param) or children routes
|
|
14
14
|
*
|
|
15
|
+
* Links the user cannot open are left out (#4962): the same rule as the
|
|
16
|
+
* router guard and the menu (security/routeAccess).
|
|
17
|
+
*
|
|
15
18
|
* Props:
|
|
16
19
|
* - showDetailsLink: Show "Details" link in navlinks (default: false)
|
|
17
20
|
*/
|
|
@@ -20,6 +23,7 @@ import { useRoute, useRouter } from 'vue-router'
|
|
|
20
23
|
import { getSiblingRoutes, getChildRoutes, routeParamsSatisfied, type ModuleRoute, type ParentConfig } from '../../module/moduleRegistry'
|
|
21
24
|
import { useOrchestrator } from '../../orchestrator/useOrchestrator.js'
|
|
22
25
|
import { useI18n } from '../../i18n/useI18n'
|
|
26
|
+
import { canOpenRoute, type RouteAccessDeps } from '../../security/routeAccess'
|
|
23
27
|
import type { EntityManager } from '../../entity/EntityManager'
|
|
24
28
|
import type { EntityRecord } from '../../types'
|
|
25
29
|
|
|
@@ -41,6 +45,18 @@ const route = useRoute()
|
|
|
41
45
|
const router = useRouter()
|
|
42
46
|
const { getManager } = useOrchestrator()
|
|
43
47
|
const { tOr } = useI18n()
|
|
48
|
+
// null without security: every link shows, as in the menu
|
|
49
|
+
const securityChecker = inject<RouteAccessDeps['checker']>('qdadmSecurityChecker', null)
|
|
50
|
+
const accessOrchestrator = inject<RouteAccessDeps['orchestrator']>('qdadmOrchestrator', null)
|
|
51
|
+
|
|
52
|
+
/** Whether the user may open the link's route (unresolvable: shown, the router decides) */
|
|
53
|
+
function canOpen(link: NavLink): boolean {
|
|
54
|
+
try {
|
|
55
|
+
return canOpenRoute(router.resolve(link.to as never), { orchestrator: accessOrchestrator, checker: securityChecker })
|
|
56
|
+
} catch {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
44
60
|
|
|
45
61
|
// Parent config from route meta
|
|
46
62
|
const parentConfig = computed<ParentConfig | undefined>(() => route.meta?.parent as ParentConfig | undefined)
|
|
@@ -186,10 +202,16 @@ const allNavlinks = computed<NavLink[]>(() => {
|
|
|
186
202
|
return []
|
|
187
203
|
})
|
|
188
204
|
|
|
205
|
+
// Only what the user may open
|
|
206
|
+
const visibleNavlinks = computed<NavLink[]>(() => allNavlinks.value.filter(canOpen))
|
|
207
|
+
|
|
208
|
+
// Inside a tabbed item (#4963) the tabs are the navigation: no links twice
|
|
209
|
+
const inItemTabs = inject<boolean>('qdadmItemTabs', false)
|
|
210
|
+
|
|
189
211
|
// Sync navlinks to AppLayout via provide/inject
|
|
190
|
-
watch([
|
|
212
|
+
watch([visibleNavlinks, () => route.fullPath], ([links]) => {
|
|
191
213
|
if (navlinksOverride) {
|
|
192
|
-
navlinksOverride.value = links as NavLink[]
|
|
214
|
+
navlinksOverride.value = inItemTabs ? [] : (links as NavLink[])
|
|
193
215
|
}
|
|
194
216
|
}, { immediate: true })
|
|
195
217
|
</script>
|
|
@@ -69,6 +69,7 @@ export type {
|
|
|
69
69
|
ResolvedAction,
|
|
70
70
|
FormPageProps,
|
|
71
71
|
FormPageEvents,
|
|
72
|
+
RevealedValues,
|
|
72
73
|
UseEntityItemFormPageOptions,
|
|
73
74
|
UseEntityItemFormPageReturn,
|
|
74
75
|
GenerateFieldsOptions,
|
|
@@ -86,6 +87,7 @@ import type {
|
|
|
86
87
|
ResolvedAction,
|
|
87
88
|
FormPageProps,
|
|
88
89
|
FormPageEvents,
|
|
90
|
+
RevealedValues,
|
|
89
91
|
UseEntityItemFormPageOptions,
|
|
90
92
|
UseEntityItemFormPageReturn,
|
|
91
93
|
GenerateFieldsOptions,
|
|
@@ -358,7 +360,13 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
358
360
|
parentConfig.value && parentId.value
|
|
359
361
|
? { parentChain: [{ entity: parentConfig.value.entity, id: parentId.value }] }
|
|
360
362
|
: undefined
|
|
361
|
-
|
|
363
|
+
if (manager.revealOnce && manager.createRevealing) {
|
|
364
|
+
const { entity: created, revealed: values } = await manager.createRevealing(payload, context)
|
|
365
|
+
responseData = created
|
|
366
|
+
if (Object.keys(values).length) pendingReveal = values
|
|
367
|
+
} else {
|
|
368
|
+
responseData = await manager.create(payload, context)
|
|
369
|
+
}
|
|
362
370
|
}
|
|
363
371
|
|
|
364
372
|
toast.add({
|
|
@@ -374,6 +382,17 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
374
382
|
originalData.value = deepClone(savedData)
|
|
375
383
|
takeSnapshot()
|
|
376
384
|
|
|
385
|
+
// Values shown once (#5319): held here only, until the user says they copied them
|
|
386
|
+
if (pendingReveal) {
|
|
387
|
+
const values = pendingReveal
|
|
388
|
+
pendingReveal = null
|
|
389
|
+
saving.value = false
|
|
390
|
+
await new Promise<void>((resolve) => {
|
|
391
|
+
revealResolve = resolve
|
|
392
|
+
revealed.value = { entity, values }
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
|
|
377
396
|
if (onSaveSuccess) {
|
|
378
397
|
await onSaveSuccess(responseData, andClose)
|
|
379
398
|
}
|
|
@@ -410,6 +429,25 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
410
429
|
}
|
|
411
430
|
}
|
|
412
431
|
|
|
432
|
+
// ============ VALUES SHOWN ONCE (#5319) ============
|
|
433
|
+
|
|
434
|
+
// Component memory only: never in data, the snapshot, a payload or a store
|
|
435
|
+
const revealed = ref<RevealedValues | null>(null)
|
|
436
|
+
let pendingReveal: Record<string, unknown> | null = null
|
|
437
|
+
let revealResolve: (() => void) | null = null
|
|
438
|
+
|
|
439
|
+
function confirmRevealed(): void {
|
|
440
|
+
revealed.value = null
|
|
441
|
+
const resolve = revealResolve
|
|
442
|
+
revealResolve = null
|
|
443
|
+
resolve?.()
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
onUnmounted(() => {
|
|
447
|
+
revealed.value = null
|
|
448
|
+
revealResolve = null
|
|
449
|
+
})
|
|
450
|
+
|
|
413
451
|
// ============ DELETE ============
|
|
414
452
|
|
|
415
453
|
async function remove(): Promise<void> {
|
|
@@ -855,6 +893,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
855
893
|
errorSummary: showErrorSummary ? errorSummary.value : null,
|
|
856
894
|
submitted: submitted.value,
|
|
857
895
|
guardDialog,
|
|
896
|
+
revealed: revealed.value,
|
|
858
897
|
}))
|
|
859
898
|
|
|
860
899
|
const formEvents: FormPageEvents = {
|
|
@@ -862,6 +901,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
862
901
|
saveAndClose: () => submit(true),
|
|
863
902
|
cancel,
|
|
864
903
|
delete: confirmDelete,
|
|
904
|
+
revealConfirmed: confirmRevealed,
|
|
865
905
|
}
|
|
866
906
|
|
|
867
907
|
// ============ BUILDER API ============
|
|
@@ -958,6 +998,10 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
958
998
|
// Guard dialog
|
|
959
999
|
guardDialog,
|
|
960
1000
|
|
|
1001
|
+
// Values shown once (#5319)
|
|
1002
|
+
revealed,
|
|
1003
|
+
confirmRevealed,
|
|
1004
|
+
|
|
961
1005
|
// Title helpers
|
|
962
1006
|
entityLabel,
|
|
963
1007
|
pageTitle,
|
|
@@ -129,6 +129,14 @@ export interface FormPageProps {
|
|
|
129
129
|
errorSummary: ErrorSummaryItem[] | null
|
|
130
130
|
submitted: boolean
|
|
131
131
|
guardDialog: GuardDialogState | null
|
|
132
|
+
/** The values a create revealed once (#5319), shown until confirmed; null otherwise */
|
|
133
|
+
revealed: RevealedValues | null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The values a create response revealed once (#5319): the entity's name, and the values by key */
|
|
137
|
+
export interface RevealedValues {
|
|
138
|
+
entity: string
|
|
139
|
+
values: Record<string, unknown>
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
/**
|
|
@@ -139,6 +147,8 @@ export interface FormPageEvents {
|
|
|
139
147
|
saveAndClose: () => Promise<unknown>
|
|
140
148
|
cancel: () => void
|
|
141
149
|
delete: () => void
|
|
150
|
+
/** The user copied the values shown once (#5319) */
|
|
151
|
+
revealConfirmed: () => void
|
|
142
152
|
}
|
|
143
153
|
|
|
144
154
|
/**
|
|
@@ -358,6 +368,11 @@ export interface UseEntityItemFormPageReturn<T extends Record<string, unknown> =
|
|
|
358
368
|
// Guard dialog (for UnsavedChangesDialog - pass to PageLayout)
|
|
359
369
|
guardDialog: GuardDialogState | null
|
|
360
370
|
|
|
371
|
+
// Values shown once (#5319): set after a create whose response revealed some,
|
|
372
|
+
// until confirmRevealed(); submit() waits for it before navigating
|
|
373
|
+
revealed: Ref<RevealedValues | null>
|
|
374
|
+
confirmRevealed: () => void
|
|
375
|
+
|
|
361
376
|
// Title helpers
|
|
362
377
|
entityLabel: ComputedRef<string>
|
|
363
378
|
pageTitle: ComputedRef<string>
|
|
@@ -135,7 +135,9 @@ export function useLiveEntity(
|
|
|
135
135
|
|
|
136
136
|
// Local writes are the manager's own echo: it has already repaired its
|
|
137
137
|
// cache and the page that triggered the write reloads on its own path.
|
|
138
|
-
|
|
138
|
+
// 'app' is the app saying a record changed (`manager.invalidate`, #4959):
|
|
139
|
+
// news to this screen, like a change made elsewhere.
|
|
140
|
+
if (payload.source !== 'remote' && payload.source !== 'app') return
|
|
139
141
|
if (payload.entity !== entityName) return
|
|
140
142
|
|
|
141
143
|
if (options.id) {
|
|
@@ -377,10 +377,19 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
|
|
|
377
377
|
return route.params[parentConfig.value.param]
|
|
378
378
|
})
|
|
379
379
|
|
|
380
|
+
// A page of a tabbed item (#4963): the frame's tabs are its navigation, so
|
|
381
|
+
// the breadcrumb's sibling links would only repeat them (#4978). The frame
|
|
382
|
+
// is a matched record, which the breadcrumb (rendered above it) can read.
|
|
383
|
+
const inItemTabs = computed(() => {
|
|
384
|
+
const parent = parentConfig.value?.entity
|
|
385
|
+
if (!parent) return false
|
|
386
|
+
return route.matched.some((r) => (r.meta?.itemTabs as { entity?: string } | undefined)?.entity === parent)
|
|
387
|
+
})
|
|
388
|
+
|
|
380
389
|
const navlinks = computed(() => {
|
|
381
390
|
void i18nLocale.value // "Details" label re-resolves on locale change
|
|
382
391
|
|
|
383
|
-
if (!parentConfig.value) return []
|
|
392
|
+
if (!parentConfig.value || inItemTabs.value) return []
|
|
384
393
|
|
|
385
394
|
const { entity: parentEntity, param, itemRoute } = parentConfig.value
|
|
386
395
|
const parentManager = getManager(parentEntity)
|
|
@@ -523,7 +532,9 @@ export function useNavContext(_options: UseNavContextOptions = {}): UseNavContex
|
|
|
523
532
|
const manager = getManager(parentConfig.value.entity)
|
|
524
533
|
if (!manager?.routePrefix) return []
|
|
525
534
|
|
|
526
|
-
|
|
535
|
+
// In a tabbed item the Details tab is the View link; Edit has no tab
|
|
536
|
+
const targets = inItemTabs.value ? (['edit'] as const) : (['show', 'edit'] as const)
|
|
537
|
+
return targets
|
|
527
538
|
.map((target) => buildModeLink(manager, target, parentId.value, entityData.value))
|
|
528
539
|
.filter((link): link is BreadcrumbModeToggle => link !== null)
|
|
529
540
|
})
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* the navigation structure dynamically.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { routePermissions } from '../security/routeAccess'
|
|
12
13
|
import { computed, inject, ref, onMounted, type ComputedRef, type Ref } from 'vue'
|
|
13
14
|
import { useRoute, useRouter } from 'vue-router'
|
|
14
15
|
import { getNavSections, alterMenuSections, isMenuAltered } from '../module/moduleRegistry'
|
|
@@ -129,10 +130,8 @@ export function useNavigation(): UseNavigationReturn {
|
|
|
129
130
|
|
|
130
131
|
function routePermission(name: string): string | string[] | undefined {
|
|
131
132
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return p === undefined ? [] : Array.isArray(p) ? p : [p]
|
|
135
|
-
})
|
|
133
|
+
// The same reading as the router guard and PageNav (#4962)
|
|
134
|
+
return routePermissions(router.resolve({ name }))
|
|
136
135
|
} catch {
|
|
137
136
|
return undefined
|
|
138
137
|
}
|