@quazardous/qdadm 2.49.0 → 2.50.1
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/package.json +1 -1
- 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 +1 -0
- package/src/components/lists/ActionButtons.vue +3 -0
- package/src/composables/confirmDelete.ts +17 -1
- package/src/composables/useEntityItemFormPage.ts +46 -2
- package/src/composables/useEntityItemFormPage.types.ts +15 -0
- package/src/composables/useEntityItemShowPage.ts +1 -1
- package/src/composables/useListPage.ts +9 -4
- package/src/composables/useListPage.types.ts +4 -0
- package/src/composables/useNavContext.ts +13 -2
- package/src/entity/EntityManager.crud.ts +48 -5
- package/src/entity/EntityManager.interface.ts +4 -0
- package/src/entity/EntityManager.ts +13 -0
- package/src/entity/EntityManager.types.ts +28 -0
- package/src/i18n/defaults/core.en.generated.ts +10 -0
- package/src/i18n/defaults/core.en.yml +10 -0
- package/src/i18n/defaults/core.fr.generated.ts +10 -0
- package/src/i18n/defaults/core.fr.yml +10 -0
- package/src/index.ts +1 -1
- package/src/utils/clipboard.ts +36 -0
package/package.json
CHANGED
|
@@ -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
|
@@ -67,6 +67,7 @@ export { default as SimpleDialog } from './dialogs/SimpleDialog.vue'
|
|
|
67
67
|
export { default as MultiStepDialog } from './dialogs/MultiStepDialog.vue'
|
|
68
68
|
export { default as BulkStatusDialog } from './dialogs/BulkStatusDialog.vue'
|
|
69
69
|
export { default as UnsavedChangesDialog } from './dialogs/UnsavedChangesDialog.vue'
|
|
70
|
+
export { default as QdRevealOnce } from './dialogs/QdRevealOnce.vue'
|
|
70
71
|
|
|
71
72
|
// Display
|
|
72
73
|
export { default as CardsGrid } from './display/CardsGrid.vue'
|
|
@@ -18,6 +18,8 @@ interface Action {
|
|
|
18
18
|
name: string
|
|
19
19
|
icon?: string
|
|
20
20
|
tooltip?: string
|
|
21
|
+
/** The button's accessible name: an icon alone has none (#5323) */
|
|
22
|
+
ariaLabel?: string
|
|
21
23
|
severity: string
|
|
22
24
|
handler: () => void | Promise<void>
|
|
23
25
|
isDisabled?: boolean
|
|
@@ -40,6 +42,7 @@ defineProps<Props>()
|
|
|
40
42
|
text
|
|
41
43
|
rounded
|
|
42
44
|
:disabled="action.isDisabled"
|
|
45
|
+
:aria-label="action.ariaLabel ?? action.tooltip"
|
|
43
46
|
@click="action.handler"
|
|
44
47
|
v-tooltip.top="action.tooltip"
|
|
45
48
|
/>
|
|
@@ -18,17 +18,33 @@ export interface ConfirmRequire {
|
|
|
18
18
|
header: string
|
|
19
19
|
icon: string
|
|
20
20
|
acceptClass?: string
|
|
21
|
+
acceptLabel?: string
|
|
22
|
+
rejectLabel?: string
|
|
23
|
+
acceptIcon?: string
|
|
24
|
+
rejectIcon?: string
|
|
25
|
+
rejectClass?: string
|
|
21
26
|
closeOnEscape?: boolean
|
|
22
27
|
accept: () => void
|
|
23
28
|
}) => void
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
/** The catalogue lookup of useI18n: a key, its English fallback */
|
|
32
|
+
export type TranslateOr = (key: string, fallback: string) => string
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The buttons say what they do, in the app's language (#5323): Delete / Cancel
|
|
36
|
+
* from the catalogue, not PrimeVue's own Yes / No.
|
|
37
|
+
*/
|
|
38
|
+
export function requireDeleteConfirmation(confirm: ConfirmRequire, tOr: TranslateOr, { message, header, accept }: DeleteConfirmation): void {
|
|
27
39
|
confirm.require({
|
|
28
40
|
message,
|
|
29
41
|
header,
|
|
30
42
|
icon: 'pi pi-exclamation-triangle',
|
|
31
43
|
acceptClass: 'p-button-danger',
|
|
44
|
+
acceptLabel: tOr('core.actions.delete', 'Delete'),
|
|
45
|
+
acceptIcon: 'pi pi-trash',
|
|
46
|
+
rejectLabel: tOr('core.actions.cancel', 'Cancel'),
|
|
47
|
+
rejectClass: 'p-button-secondary p-button-text',
|
|
32
48
|
closeOnEscape: true,
|
|
33
49
|
accept,
|
|
34
50
|
})
|
|
@@ -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> {
|
|
@@ -442,7 +480,7 @@ export function useEntityItemFormPage<T extends Record<string, unknown> = Record
|
|
|
442
480
|
|
|
443
481
|
function confirmDelete(): void {
|
|
444
482
|
const label = manager.getEntityLabel(data.value) || entityId.value
|
|
445
|
-
requireDeleteConfirmation(confirm, {
|
|
483
|
+
requireDeleteConfirmation(confirm, tOr, {
|
|
446
484
|
message: tOr('core.messages.confirmDeleteItem', 'Delete {entity} "{label}"?', { entity: entityName, label: String(label) }),
|
|
447
485
|
header: tOr('core.messages.confirmDeleteTitle', 'Confirm Delete'),
|
|
448
486
|
accept: remove,
|
|
@@ -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>
|
|
@@ -476,7 +476,7 @@ export function useEntityItemShowPage<T = Record<string, unknown>>(
|
|
|
476
476
|
severity: 'danger',
|
|
477
477
|
onClick: () => {
|
|
478
478
|
if (confirmDelete) {
|
|
479
|
-
requireDeleteConfirmation(confirm, {
|
|
479
|
+
requireDeleteConfirmation(confirm, tOr, {
|
|
480
480
|
message: tOr('core.messages.confirmDeleteThis', 'Are you sure you want to delete this {entity}?', { entity: manager.label || entity }),
|
|
481
481
|
header: tOr('core.messages.confirmDeleteTitle', 'Confirm Delete'),
|
|
482
482
|
accept: () => deleteEntity(),
|
|
@@ -764,6 +764,8 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
764
764
|
name: action.name,
|
|
765
765
|
icon: action.icon ? resolveValue(action.icon, row) : undefined,
|
|
766
766
|
tooltip: action.tooltip ? resolveValue(action.tooltip, row) : undefined,
|
|
767
|
+
// An icon alone has no name: the label read aloud, and the one a test finds it by (#5323)
|
|
768
|
+
ariaLabel: action.ariaLabel ? resolveValue(action.ariaLabel, row) : action.tooltip ? resolveValue(action.tooltip, row) : undefined,
|
|
767
769
|
severity: resolveValue(action.severity || 'secondary', row),
|
|
768
770
|
isDisabled: action.disabled ? action.disabled(row) : false,
|
|
769
771
|
handler: () => action.onClick(row),
|
|
@@ -1097,7 +1099,7 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1097
1099
|
|
|
1098
1100
|
function confirmDelete(item: unknown, labelField = 'name'): void {
|
|
1099
1101
|
const itemRecord = item as Record<string, unknown>
|
|
1100
|
-
requireDeleteConfirmation(confirm, {
|
|
1102
|
+
requireDeleteConfirmation(confirm, tOr, {
|
|
1101
1103
|
message: tOr('core.messages.confirmDeleteItem', 'Delete {entity} "{label}"?', {
|
|
1102
1104
|
entity: entityName,
|
|
1103
1105
|
label: String(itemRecord[labelField] || itemRecord[resolvedDataKey]),
|
|
@@ -1151,9 +1153,12 @@ export function useListPage<T = unknown>(config: UseListPageOptions<T>): UseList
|
|
|
1151
1153
|
|
|
1152
1154
|
function confirmBulkDelete(): void {
|
|
1153
1155
|
const count = selected.value.length
|
|
1154
|
-
requireDeleteConfirmation(confirm, {
|
|
1155
|
-
message:
|
|
1156
|
-
|
|
1156
|
+
requireDeleteConfirmation(confirm, tOr, {
|
|
1157
|
+
message: tOr('core.messages.confirmBulkDelete', 'Delete {count} {entities}?', {
|
|
1158
|
+
count,
|
|
1159
|
+
entities: count > 1 ? entityNamePlural : entityName,
|
|
1160
|
+
}),
|
|
1161
|
+
header: tOr('core.messages.confirmBulkDeleteTitle', 'Confirm Bulk Delete'),
|
|
1157
1162
|
accept: bulkDelete,
|
|
1158
1163
|
})
|
|
1159
1164
|
}
|
|
@@ -151,6 +151,8 @@ export interface ActionConfig {
|
|
|
151
151
|
name: string
|
|
152
152
|
icon?: string | ((row: unknown) => string)
|
|
153
153
|
tooltip?: string | ((row: unknown) => string)
|
|
154
|
+
/** The button's accessible name; the tooltip when absent (#5323) */
|
|
155
|
+
ariaLabel?: string | ((row: unknown) => string)
|
|
154
156
|
severity?: string | ((row: unknown) => string)
|
|
155
157
|
onClick: (row: unknown) => void | Promise<void>
|
|
156
158
|
visible?: (row: unknown) => boolean
|
|
@@ -164,6 +166,8 @@ export interface ResolvedAction {
|
|
|
164
166
|
name: string
|
|
165
167
|
icon: string | undefined
|
|
166
168
|
tooltip: string | undefined
|
|
169
|
+
/** The button's accessible name (#5323) */
|
|
170
|
+
ariaLabel: string | undefined
|
|
167
171
|
severity: string
|
|
168
172
|
isDisabled: boolean
|
|
169
173
|
handler: () => void | Promise<void>
|
|
@@ -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
|
})
|
|
@@ -414,6 +414,20 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
|
|
|
414
414
|
data: Partial<any>,
|
|
415
415
|
context?: RoutingContext
|
|
416
416
|
): Promise<any> {
|
|
417
|
+
// The values shown once are dropped here: a caller wanting them uses createRevealing()
|
|
418
|
+
return (await this.createRevealing(data, context)).entity
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Create a new entity, and hand back the values its response reveals once
|
|
423
|
+
* (#5319, `revealOnce`). They are taken out of the response before the
|
|
424
|
+
* cache, the postsave hooks and the signals see it.
|
|
425
|
+
*/
|
|
426
|
+
proto.createRevealing = async function (
|
|
427
|
+
this: Self,
|
|
428
|
+
data: Partial<any>,
|
|
429
|
+
context?: RoutingContext
|
|
430
|
+
): Promise<{ entity: any; revealed: Record<string, unknown> }> {
|
|
417
431
|
const { storage, endpoint } = this._normalizeResolveResult(
|
|
418
432
|
this.resolveStorage('create', context),
|
|
419
433
|
context
|
|
@@ -428,16 +442,17 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
|
|
|
428
442
|
await this._invokeHook('presave', presaveContext as unknown as Record<string, unknown>)
|
|
429
443
|
|
|
430
444
|
// Use request() with endpoint for multi-storage routing, otherwise use create()
|
|
431
|
-
let
|
|
445
|
+
let response: any
|
|
432
446
|
if (endpoint && storage.request) {
|
|
433
|
-
const
|
|
447
|
+
const raw = (await storage.request('POST', endpoint, {
|
|
434
448
|
data: presaveContext.record,
|
|
435
449
|
context,
|
|
436
450
|
})) as { data?: any }
|
|
437
|
-
|
|
451
|
+
response = (raw.data ?? raw)
|
|
438
452
|
} else {
|
|
439
|
-
|
|
453
|
+
response = await storage.create(presaveContext.record)
|
|
440
454
|
}
|
|
455
|
+
const { entity: result, revealed } = splitRevealed(response, this.revealOnce)
|
|
441
456
|
this.invalidateCache()
|
|
442
457
|
|
|
443
458
|
// Invoke postsave hooks (for side effects)
|
|
@@ -450,7 +465,7 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
|
|
|
450
465
|
id: result?.[this.idField],
|
|
451
466
|
})
|
|
452
467
|
this._emitDataInvalidate('created', result?.[this.idField] as string | number | undefined)
|
|
453
|
-
return result
|
|
468
|
+
return { entity: result, revealed }
|
|
454
469
|
}
|
|
455
470
|
throw new Error(`[EntityManager:${this.name}] create() not implemented`)
|
|
456
471
|
}
|
|
@@ -626,3 +641,31 @@ export function applyCrudMethods(EntityManagerClass: { prototype: any }): void {
|
|
|
626
641
|
this._orchestrator = orchestrator
|
|
627
642
|
}
|
|
628
643
|
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Take the values shown once out of a create response (#5319): the entity is
|
|
647
|
+
* `response[item]` when the config names one, else the response without them.
|
|
648
|
+
*/
|
|
649
|
+
export function splitRevealed(
|
|
650
|
+
response: unknown,
|
|
651
|
+
config: { keys: string[]; item?: string } | null
|
|
652
|
+
): { entity: any; revealed: Record<string, unknown> } {
|
|
653
|
+
if (!config || !response || typeof response !== 'object') return { entity: response, revealed: {} }
|
|
654
|
+
const source = response as Record<string, unknown>
|
|
655
|
+
const revealed: Record<string, unknown> = {}
|
|
656
|
+
for (const key of config.keys) {
|
|
657
|
+
if (source[key] !== undefined && source[key] !== null) revealed[key] = source[key]
|
|
658
|
+
}
|
|
659
|
+
if (config.item) {
|
|
660
|
+
const item = source[config.item]
|
|
661
|
+
if (item && typeof item === 'object') {
|
|
662
|
+
// The item itself never carries a revealed key either
|
|
663
|
+
const entity = { ...(item as Record<string, unknown>) }
|
|
664
|
+
for (const key of config.keys) delete entity[key]
|
|
665
|
+
return { entity, revealed }
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const entity = { ...source }
|
|
669
|
+
for (const key of config.keys) delete entity[key]
|
|
670
|
+
return { entity, revealed }
|
|
671
|
+
}
|
|
@@ -115,6 +115,10 @@ export interface EntityManagerCrud<T = unknown> extends EntityManagerRead<T> {
|
|
|
115
115
|
// getFieldConfig inherited (required) from EntityManagerRead since #1253
|
|
116
116
|
resolveReferenceOptions: (fieldName: string) => Promise<unknown[]>
|
|
117
117
|
create: (data: unknown, context?: unknown) => Promise<T>
|
|
118
|
+
/** What a create response reveals once (#5319), or null */
|
|
119
|
+
revealOnce?: { keys: string[]; item?: string } | null
|
|
120
|
+
/** create(), and the values its response reveals once (#5319) */
|
|
121
|
+
createRevealing?: (data: unknown, context?: unknown) => Promise<{ entity: T; revealed: Record<string, unknown> }>
|
|
118
122
|
update: (id: string | number, data: unknown, context?: unknown) => Promise<T>
|
|
119
123
|
patch: (id: string | number, data: unknown, context?: unknown) => Promise<T>
|
|
120
124
|
// Optional BY DESIGN (#1253): the severity/badge presentation capability —
|
|
@@ -50,6 +50,8 @@ export type {
|
|
|
50
50
|
SeverityMap,
|
|
51
51
|
EntityManagerOptions,
|
|
52
52
|
GetOptions,
|
|
53
|
+
RevealOnceConfig,
|
|
54
|
+
CreateRevealingResult,
|
|
53
55
|
} from './EntityManager.types'
|
|
54
56
|
|
|
55
57
|
// Import concrete types needed in method signatures
|
|
@@ -67,6 +69,8 @@ import type {
|
|
|
67
69
|
SeverityDescriptor,
|
|
68
70
|
EntityManagerOptions,
|
|
69
71
|
LiveEntityPolicy,
|
|
72
|
+
RevealOnceConfig,
|
|
73
|
+
CreateRevealingResult,
|
|
70
74
|
} from './EntityManager.types'
|
|
71
75
|
|
|
72
76
|
/**
|
|
@@ -102,6 +106,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
102
106
|
protected _detailCacheMaxSize: number
|
|
103
107
|
protected _detailInflight: Map<string, Promise<T>> = new Map()
|
|
104
108
|
protected _readOnly: boolean
|
|
109
|
+
protected _revealOnce: RevealOnceConfig | null
|
|
105
110
|
protected _warmup: boolean
|
|
106
111
|
protected _authSensitive: boolean
|
|
107
112
|
/** Reaction policy for changes made outside this session (#1888). */
|
|
@@ -175,6 +180,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
175
180
|
detailCacheTtlMs = 0,
|
|
176
181
|
detailCacheMaxSize = 0,
|
|
177
182
|
readOnly = false,
|
|
183
|
+
revealOnce = null,
|
|
178
184
|
warmup = true,
|
|
179
185
|
authSensitive,
|
|
180
186
|
live,
|
|
@@ -209,6 +215,7 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
209
215
|
this._detailCacheTtlMs = detailCacheTtlMs
|
|
210
216
|
this._detailCacheMaxSize = detailCacheMaxSize
|
|
211
217
|
this._readOnly = readOnly
|
|
218
|
+
this._revealOnce = revealOnce?.keys?.length ? revealOnce : null
|
|
212
219
|
this._warmup = warmup
|
|
213
220
|
this._authSensitive = authSensitive ?? this._getStorageRequiresAuth()
|
|
214
221
|
// Pre-wired defaults: the common case declares nothing.
|
|
@@ -673,6 +680,11 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
673
680
|
return this._readOnly
|
|
674
681
|
}
|
|
675
682
|
|
|
683
|
+
/** What a create response reveals once (#5319), or null */
|
|
684
|
+
get revealOnce(): RevealOnceConfig | null {
|
|
685
|
+
return this._revealOnce
|
|
686
|
+
}
|
|
687
|
+
|
|
676
688
|
/**
|
|
677
689
|
* Whether this entity is one the framework provides (roles, users). Owned
|
|
678
690
|
* by qdadm — see `EntityManagerOptions.system`.
|
|
@@ -1032,6 +1044,7 @@ export interface EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
1032
1044
|
get(id: string | number, context?: RoutingContext, options?: GetOptions): Promise<T>
|
|
1033
1045
|
getMany(ids: Array<string | number>, context?: RoutingContext): Promise<T[]>
|
|
1034
1046
|
create(data: Partial<T>, context?: RoutingContext): Promise<T>
|
|
1047
|
+
createRevealing(data: Partial<T>, context?: RoutingContext): Promise<CreateRevealingResult<T>>
|
|
1035
1048
|
update(id: string | number, data: Partial<T>, context?: RoutingContext): Promise<T>
|
|
1036
1049
|
patch(id: string | number, data: Partial<T>, context?: RoutingContext): Promise<T>
|
|
1037
1050
|
delete(id: string | number, context?: RoutingContext): Promise<void>
|
|
@@ -264,6 +264,26 @@ export interface LiveRefreshPolicy {
|
|
|
264
264
|
/** The notification entry `LiveEntityPolicy.describeUpdate` asks for (#2685). */
|
|
265
265
|
export type LiveUpdateEntry = Omit<NewNotification, 'severity'> & Partial<Pick<NewNotification, 'severity'>>
|
|
266
266
|
|
|
267
|
+
/**
|
|
268
|
+
* What a create response reveals once (#5319).
|
|
269
|
+
*
|
|
270
|
+
* POST /keys → { key: { name, scopes, … }, token: 'sbx_…' }
|
|
271
|
+
* revealOnce: { keys: ['token'], item: 'key' }
|
|
272
|
+
*/
|
|
273
|
+
export interface RevealOnceConfig {
|
|
274
|
+
/** The response keys shown once and never kept */
|
|
275
|
+
keys: string[]
|
|
276
|
+
/** Where the entity sits in the response; the rest of it when absent */
|
|
277
|
+
item?: string
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** What `createRevealing()` returns: the entity, and the values shown once */
|
|
281
|
+
export interface CreateRevealingResult<T> {
|
|
282
|
+
entity: T
|
|
283
|
+
/** The revealed values, by key; empty when the response carried none */
|
|
284
|
+
revealed: Record<string, unknown>
|
|
285
|
+
}
|
|
286
|
+
|
|
267
287
|
/**
|
|
268
288
|
* EntityManager constructor options
|
|
269
289
|
*/
|
|
@@ -302,6 +322,14 @@ export interface EntityManagerOptions<T extends EntityRecord = EntityRecord> {
|
|
|
302
322
|
/** Detail cache max size (0=unlimited (default), >0=max items). Oldest entries are evicted when exceeded. Only used when asymmetric=true. */
|
|
303
323
|
detailCacheMaxSize?: number
|
|
304
324
|
readOnly?: boolean
|
|
325
|
+
/**
|
|
326
|
+
* Values the create response carries once and that are never kept (#5319):
|
|
327
|
+
* a key's token, a generated password. `create()` takes them out of the
|
|
328
|
+
* response before anything else sees it (the cache, the signals, the
|
|
329
|
+
* postsave hooks); `createRevealing()` hands them to the caller, and the
|
|
330
|
+
* create form shows them once.
|
|
331
|
+
*/
|
|
332
|
+
revealOnce?: RevealOnceConfig
|
|
305
333
|
warmup?: boolean
|
|
306
334
|
authSensitive?: boolean
|
|
307
335
|
/**
|
|
@@ -65,6 +65,8 @@ export default `core:
|
|
|
65
65
|
confirmDeleteTitle: Confirm Delete
|
|
66
66
|
confirmDeleteItem: 'Delete {entity} "{label}"?'
|
|
67
67
|
confirmDeleteThis: Are you sure you want to delete this {entity}?
|
|
68
|
+
confirmBulkDelete: "Delete {count} {entities}?"
|
|
69
|
+
confirmBulkDeleteTitle: Confirm Bulk Delete
|
|
68
70
|
errors:
|
|
69
71
|
required: Required
|
|
70
72
|
tooShort: Too short (min {min})
|
|
@@ -363,6 +365,14 @@ export default `core:
|
|
|
363
365
|
moreKeys: "+{count} more"
|
|
364
366
|
takeTheirs: Load their version
|
|
365
367
|
keepMine: Keep mine and save over it
|
|
368
|
+
# Values a create reveals once: a key's token (QdRevealOnce, #5319)
|
|
369
|
+
revealOnce:
|
|
370
|
+
title: "{entity} created"
|
|
371
|
+
warning: Copy it now. It is shown only this once and cannot be read again.
|
|
372
|
+
copy: Copy
|
|
373
|
+
copied: Copied
|
|
374
|
+
copyFailed: "Copy failed: {error}"
|
|
375
|
+
confirm: I have copied it
|
|
366
376
|
# NotFoundPage
|
|
367
377
|
notFound:
|
|
368
378
|
title: Page not found
|
|
@@ -63,6 +63,8 @@ core:
|
|
|
63
63
|
confirmDeleteTitle: Confirm Delete
|
|
64
64
|
confirmDeleteItem: 'Delete {entity} "{label}"?'
|
|
65
65
|
confirmDeleteThis: Are you sure you want to delete this {entity}?
|
|
66
|
+
confirmBulkDelete: "Delete {count} {entities}?"
|
|
67
|
+
confirmBulkDeleteTitle: Confirm Bulk Delete
|
|
66
68
|
errors:
|
|
67
69
|
required: Required
|
|
68
70
|
tooShort: Too short (min {min})
|
|
@@ -361,6 +363,14 @@ core:
|
|
|
361
363
|
moreKeys: "+{count} more"
|
|
362
364
|
takeTheirs: Load their version
|
|
363
365
|
keepMine: Keep mine and save over it
|
|
366
|
+
# Values a create reveals once: a key's token (QdRevealOnce, #5319)
|
|
367
|
+
revealOnce:
|
|
368
|
+
title: "{entity} created"
|
|
369
|
+
warning: Copy it now. It is shown only this once and cannot be read again.
|
|
370
|
+
copy: Copy
|
|
371
|
+
copied: Copied
|
|
372
|
+
copyFailed: "Copy failed: {error}"
|
|
373
|
+
confirm: I have copied it
|
|
364
374
|
# NotFoundPage
|
|
365
375
|
notFound:
|
|
366
376
|
title: Page not found
|
|
@@ -65,6 +65,8 @@ export default `core:
|
|
|
65
65
|
confirmDeleteTitle: Confirmer la suppression
|
|
66
66
|
confirmDeleteItem: "Supprimer {entity} « {label} » ?"
|
|
67
67
|
confirmDeleteThis: "Êtes-vous sûr de vouloir supprimer cet élément ({entity}) ?"
|
|
68
|
+
confirmBulkDelete: "Supprimer {count} {entities} ?"
|
|
69
|
+
confirmBulkDeleteTitle: Confirmer la suppression groupée
|
|
68
70
|
errors:
|
|
69
71
|
required: Requis
|
|
70
72
|
tooShort: Trop court (min {min})
|
|
@@ -363,6 +365,14 @@ export default `core:
|
|
|
363
365
|
moreKeys: "+{count} autres"
|
|
364
366
|
takeTheirs: Charger sa version
|
|
365
367
|
keepMine: Garder la mienne et l'enregistrer par-dessus
|
|
368
|
+
# Values a create reveals once: a key's token (QdRevealOnce, #5319)
|
|
369
|
+
revealOnce:
|
|
370
|
+
title: "{entity} : création réussie"
|
|
371
|
+
warning: Copiez-la maintenant. Elle n'est montrée que cette fois et ne pourra plus être relue.
|
|
372
|
+
copy: Copier
|
|
373
|
+
copied: Copié
|
|
374
|
+
copyFailed: "Échec de la copie : {error}"
|
|
375
|
+
confirm: J'ai copié
|
|
366
376
|
# NotFoundPage
|
|
367
377
|
notFound:
|
|
368
378
|
title: Page introuvable
|
|
@@ -63,6 +63,8 @@ core:
|
|
|
63
63
|
confirmDeleteTitle: Confirmer la suppression
|
|
64
64
|
confirmDeleteItem: "Supprimer {entity} « {label} » ?"
|
|
65
65
|
confirmDeleteThis: "Êtes-vous sûr de vouloir supprimer cet élément ({entity}) ?"
|
|
66
|
+
confirmBulkDelete: "Supprimer {count} {entities} ?"
|
|
67
|
+
confirmBulkDeleteTitle: Confirmer la suppression groupée
|
|
66
68
|
errors:
|
|
67
69
|
required: Requis
|
|
68
70
|
tooShort: Trop court (min {min})
|
|
@@ -361,6 +363,14 @@ core:
|
|
|
361
363
|
moreKeys: "+{count} autres"
|
|
362
364
|
takeTheirs: Charger sa version
|
|
363
365
|
keepMine: Garder la mienne et l'enregistrer par-dessus
|
|
366
|
+
# Values a create reveals once: a key's token (QdRevealOnce, #5319)
|
|
367
|
+
revealOnce:
|
|
368
|
+
title: "{entity} : création réussie"
|
|
369
|
+
warning: Copiez-la maintenant. Elle n'est montrée que cette fois et ne pourra plus être relue.
|
|
370
|
+
copy: Copier
|
|
371
|
+
copied: Copié
|
|
372
|
+
copyFailed: "Échec de la copie : {error}"
|
|
373
|
+
confirm: J'ai copié
|
|
364
374
|
# NotFoundPage
|
|
365
375
|
notFound:
|
|
366
376
|
title: Page introuvable
|
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export { SSEBridge, createSSEBridge, SSE_SIGNALS } from './kernel/SSEBridge'
|
|
|
41
41
|
export type { SSEBridgeOptions } from './kernel/SSEBridge'
|
|
42
42
|
export { useLiveEntity } from './composables/useLiveEntity'
|
|
43
43
|
export type { UseLiveEntityOptions } from './composables/useLiveEntity'
|
|
44
|
-
export type { LiveEntityPolicy, LiveUpdateEntry, LiveRefreshRule, LiveRefreshPolicy } from './entity/EntityManager.types'
|
|
44
|
+
export type { LiveEntityPolicy, LiveUpdateEntry, LiveRefreshRule, LiveRefreshPolicy, RevealOnceConfig, CreateRevealingResult } from './entity/EntityManager.types'
|
|
45
45
|
export { LiveEntityRouter, createLiveEntityRouter } from './kernel/LiveEntityRouter'
|
|
46
46
|
export type {
|
|
47
47
|
LiveEntityRouterOptions,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Put text on the clipboard: `navigator.clipboard` when the page has it, a
|
|
3
|
+
* selected textarea otherwise (a page served over plain http has none).
|
|
4
|
+
* Throws when neither works.
|
|
5
|
+
*/
|
|
6
|
+
export async function copyText(text: string): Promise<void> {
|
|
7
|
+
try {
|
|
8
|
+
if (!navigator.clipboard?.writeText) throw new Error('no clipboard on this page (it needs HTTPS)')
|
|
9
|
+
await navigator.clipboard.writeText(text)
|
|
10
|
+
} catch (err) {
|
|
11
|
+
try {
|
|
12
|
+
copyByCommand(text)
|
|
13
|
+
} catch {
|
|
14
|
+
throw err
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function copyByCommand(text: string): void {
|
|
20
|
+
const area = document.createElement('textarea')
|
|
21
|
+
area.value = text
|
|
22
|
+
area.setAttribute('readonly', '')
|
|
23
|
+
area.style.position = 'fixed'
|
|
24
|
+
area.style.opacity = '0'
|
|
25
|
+
document.body.appendChild(area)
|
|
26
|
+
const focused = document.activeElement as HTMLElement | null
|
|
27
|
+
area.select()
|
|
28
|
+
try {
|
|
29
|
+
if (!document.execCommand?.('copy')) throw new Error('the browser refused to copy')
|
|
30
|
+
} finally {
|
|
31
|
+
// The textarea held the value: it goes at once
|
|
32
|
+
area.value = ''
|
|
33
|
+
area.remove()
|
|
34
|
+
focused?.focus?.()
|
|
35
|
+
}
|
|
36
|
+
}
|