@byline/admin 3.15.2 → 3.16.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/dist/fields/array/array-field.d.ts +8 -1
- package/dist/fields/array/array-field.js +3 -1
- package/dist/fields/field-renderer.js +2 -0
- package/dist/fields/group/group-field.d.ts +7 -1
- package/dist/fields/group/group-field.js +2 -1
- package/dist/fields/relation/relation-many-field.js +19 -11
- package/dist/fields/relation/relation-picker.d.ts +40 -17
- package/dist/fields/relation/relation-picker.js +84 -28
- package/dist/fields/relation/relation-picker.module.js +9 -0
- package/dist/fields/relation/relation-picker_module.css +41 -0
- package/dist/forms/form-context.d.ts +2 -2
- package/dist/forms/form-modals.d.ts +1 -1
- package/dist/forms/form-renderer.d.ts +2 -2
- package/dist/forms/tree-placement-widget.d.ts +1 -1
- package/dist/lib/create-command.d.ts +1 -1
- package/dist/modules/admin-activity/abilities.d.ts +1 -1
- package/dist/modules/admin-activity/index.d.ts +1 -1
- package/dist/modules/admin-permissions/abilities.d.ts +1 -1
- package/dist/modules/admin-users/repository.d.ts +1 -1
- package/dist/widgets/source-locale-badge/source-locale-badge.d.ts +1 -1
- package/package.json +5 -6
- package/src/fields/array/array-field.tsx +10 -0
- package/src/fields/field-renderer.tsx +2 -0
- package/src/fields/field-services-types.ts +1 -1
- package/src/fields/group/group-field.tsx +14 -1
- package/src/fields/relation/relation-many-field.tsx +22 -15
- package/src/fields/relation/relation-picker.module.css +49 -0
- package/src/fields/relation/relation-picker.tsx +130 -23
- package/src/forms/available-locales-reconcile.test.node.ts +1 -1
- package/src/forms/form-context.tsx +3 -3
- package/src/forms/form-modals.tsx +1 -1
- package/src/forms/form-renderer.tsx +4 -4
- package/src/forms/tree-placement-widget.tsx +1 -1
- package/src/lib/create-command.ts +1 -1
- package/src/modules/admin-activity/abilities.ts +1 -1
- package/src/modules/admin-activity/index.ts +1 -1
- package/src/modules/admin-permissions/abilities.ts +1 -1
- package/src/modules/admin-permissions/components/inspector.tsx +1 -1
- package/src/modules/admin-users/repository.ts +1 -1
- package/src/widgets/source-locale-badge/source-locale-badge.tsx +1 -1
|
@@ -29,12 +29,20 @@ export const ArrayField = ({
|
|
|
29
29
|
defaultValue,
|
|
30
30
|
path,
|
|
31
31
|
disableSorting = false,
|
|
32
|
+
collectionPath,
|
|
32
33
|
contentLocale,
|
|
33
34
|
}: {
|
|
34
35
|
field: ArrayFieldType
|
|
35
36
|
defaultValue: any
|
|
36
37
|
path: string
|
|
37
38
|
disableSorting?: boolean
|
|
39
|
+
/**
|
|
40
|
+
* Collection path forwarded to upload-capable fields (`file` / `image`)
|
|
41
|
+
* nested inside an array item, which need it to reach the `/upload`
|
|
42
|
+
* endpoint. Without it those fields fall back to their empty placeholder
|
|
43
|
+
* and never render an upload widget.
|
|
44
|
+
*/
|
|
45
|
+
collectionPath?: string
|
|
38
46
|
/**
|
|
39
47
|
* Active content locale, forwarded to each array item's fields so
|
|
40
48
|
* localized widgets nested inside an array (e.g. a `localized` richText)
|
|
@@ -205,6 +213,7 @@ export const ArrayField = ({
|
|
|
205
213
|
defaultValue={groupData[innerField.name]}
|
|
206
214
|
basePath={`${arrayElementPath}.${childField.name}`}
|
|
207
215
|
disableSorting={true}
|
|
216
|
+
collectionPath={collectionPath}
|
|
208
217
|
contentLocale={contentLocale}
|
|
209
218
|
/>
|
|
210
219
|
))}
|
|
@@ -219,6 +228,7 @@ export const ArrayField = ({
|
|
|
219
228
|
defaultValue={initial}
|
|
220
229
|
basePath={arrayElementPath}
|
|
221
230
|
disableSorting={true}
|
|
231
|
+
collectionPath={collectionPath}
|
|
222
232
|
contentLocale={contentLocale}
|
|
223
233
|
/>
|
|
224
234
|
)
|
|
@@ -254,6 +254,7 @@ export const FieldRenderer = ({
|
|
|
254
254
|
}
|
|
255
255
|
defaultValue={defaultValue}
|
|
256
256
|
path={path}
|
|
257
|
+
collectionPath={collectionPath}
|
|
257
258
|
contentLocale={contentLocale}
|
|
258
259
|
/>
|
|
259
260
|
)
|
|
@@ -275,6 +276,7 @@ export const FieldRenderer = ({
|
|
|
275
276
|
defaultValue={defaultValue}
|
|
276
277
|
path={path}
|
|
277
278
|
disableSorting={disableSorting}
|
|
279
|
+
collectionPath={collectionPath}
|
|
278
280
|
contentLocale={contentLocale}
|
|
279
281
|
/>
|
|
280
282
|
)
|
|
@@ -62,7 +62,7 @@ export type UploadFieldFn = (
|
|
|
62
62
|
createDocument?: boolean
|
|
63
63
|
) => Promise<UploadedFileResult>
|
|
64
64
|
|
|
65
|
-
// --- Document tree (the `tree: true` primitive — docs/
|
|
65
|
+
// --- Document tree (the `tree: true` primitive — docs/04-collections/03-document-trees.md) -----
|
|
66
66
|
|
|
67
67
|
/** One hydrated ancestor in a document's breadcrumb trail (root-first). */
|
|
68
68
|
export interface TreeAncestor {
|
|
@@ -32,6 +32,12 @@ interface GroupFieldProps {
|
|
|
32
32
|
field: GroupFieldType
|
|
33
33
|
defaultValue: any
|
|
34
34
|
path: string
|
|
35
|
+
/**
|
|
36
|
+
* Collection path forwarded to upload-capable child fields (`file` / `image`),
|
|
37
|
+
* which need it to reach the `/upload` endpoint. Without it those fields fall
|
|
38
|
+
* back to their empty placeholder and never render an upload widget.
|
|
39
|
+
*/
|
|
40
|
+
collectionPath?: string
|
|
35
41
|
/**
|
|
36
42
|
* Active content locale, forwarded to child fields so localized widgets
|
|
37
43
|
* nested inside the group (e.g. a `localized` richText) can render their
|
|
@@ -40,7 +46,13 @@ interface GroupFieldProps {
|
|
|
40
46
|
contentLocale?: string
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
export const GroupField = ({
|
|
49
|
+
export const GroupField = ({
|
|
50
|
+
field,
|
|
51
|
+
defaultValue,
|
|
52
|
+
path,
|
|
53
|
+
collectionPath,
|
|
54
|
+
contentLocale,
|
|
55
|
+
}: GroupFieldProps) => {
|
|
44
56
|
const fieldError = useFieldError(field.name)
|
|
45
57
|
// Default value for a group field is a plain object: { rating: 5, comment: '...' }
|
|
46
58
|
// Normalize to a plain object if not already one.
|
|
@@ -80,6 +92,7 @@ export const GroupField = ({ field, defaultValue, path, contentLocale }: GroupFi
|
|
|
80
92
|
defaultValue={groupData[innerField.name]}
|
|
81
93
|
basePath={path}
|
|
82
94
|
disableSorting={true}
|
|
95
|
+
collectionPath={collectionPath}
|
|
83
96
|
contentLocale={contentLocale}
|
|
84
97
|
/>
|
|
85
98
|
)
|
|
@@ -32,7 +32,7 @@ import cx from 'classnames'
|
|
|
32
32
|
|
|
33
33
|
import { useFieldError, useFieldValue, useFormContext } from '../../forms/form-context'
|
|
34
34
|
import styles from './relation-field.module.css'
|
|
35
|
-
import { RelationPicker } from './relation-picker'
|
|
35
|
+
import { RelationPicker, type RelationPickerSelection } from './relation-picker'
|
|
36
36
|
import { RelationSummary } from './relation-summary'
|
|
37
37
|
|
|
38
38
|
// A single stored item. On the edit path the loader's populate pass attaches
|
|
@@ -147,24 +147,29 @@ export const RelationManyField = ({ field, defaultValue, id, path }: RelationMan
|
|
|
147
147
|
return Array.isArray(defaultValue) ? (defaultValue as IncomingRelationValue[]) : []
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
const
|
|
151
|
-
targetDocumentId: string
|
|
152
|
-
targetCollectionId: string
|
|
153
|
-
record?: Record<string, any>
|
|
154
|
-
}) => {
|
|
150
|
+
const handleAddMany = (selections: RelationPickerSelection[]) => {
|
|
155
151
|
setPickerOpen(false)
|
|
156
152
|
const current = currentArray()
|
|
157
|
-
// Dedup — a target may appear at most
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
// Dedup the batch against the current array — a target may appear at most
|
|
154
|
+
// once. The picker already disables already-added rows, so this is a
|
|
155
|
+
// belt-and-braces guard for stale state (e.g. a concurrent remove).
|
|
156
|
+
const existing = new Set(current.map((v) => v.targetDocumentId))
|
|
157
|
+
const additions = selections.filter((s) => !existing.has(s.targetDocumentId))
|
|
158
|
+
if (additions.length === 0) return
|
|
159
|
+
const records = additions.filter((s) => s.record != null)
|
|
160
|
+
if (records.length > 0) {
|
|
161
|
+
setPickedRecords((prev) => {
|
|
162
|
+
const next = { ...prev }
|
|
163
|
+
for (const s of records) next[s.targetDocumentId] = s.record!
|
|
164
|
+
return next
|
|
165
|
+
})
|
|
161
166
|
}
|
|
162
167
|
setFieldValue(fieldPath, [
|
|
163
168
|
...current,
|
|
164
|
-
{
|
|
165
|
-
targetDocumentId:
|
|
166
|
-
targetCollectionId:
|
|
167
|
-
},
|
|
169
|
+
...additions.map((s) => ({
|
|
170
|
+
targetDocumentId: s.targetDocumentId,
|
|
171
|
+
targetCollectionId: s.targetCollectionId,
|
|
172
|
+
})),
|
|
168
173
|
])
|
|
169
174
|
}
|
|
170
175
|
|
|
@@ -260,11 +265,13 @@ export const RelationManyField = ({ field, defaultValue, id, path }: RelationMan
|
|
|
260
265
|
</div>
|
|
261
266
|
|
|
262
267
|
<RelationPicker
|
|
268
|
+
multiple
|
|
263
269
|
targetCollectionPath={field.targetCollection}
|
|
264
270
|
targetDefinition={targetDef}
|
|
265
271
|
displayField={field.displayField}
|
|
266
272
|
isOpen={pickerOpen}
|
|
267
|
-
|
|
273
|
+
excludeIds={items.map((v) => v.targetDocumentId)}
|
|
274
|
+
onSelectMany={handleAddMany}
|
|
268
275
|
onDismiss={() => setPickerOpen(false)}
|
|
269
276
|
/>
|
|
270
277
|
</>
|
|
@@ -108,6 +108,55 @@
|
|
|
108
108
|
border-left: 2px solid var(--primary-200);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/* Multi-select mode: rows lay out check indicator + content + trailing hint. */
|
|
112
|
+
.row-multi,
|
|
113
|
+
:global(.byline-field-relation-picker-row-multi) {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 0.625rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.check,
|
|
120
|
+
:global(.byline-field-relation-picker-check) {
|
|
121
|
+
flex: none;
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
width: 16px;
|
|
126
|
+
height: 16px;
|
|
127
|
+
border: 1px solid var(--gray-400);
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
color: transparent;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.check-checked,
|
|
133
|
+
:global(.byline-field-relation-picker-check-checked) {
|
|
134
|
+
background-color: var(--primary-200);
|
|
135
|
+
border-color: var(--primary-200);
|
|
136
|
+
color: #fff;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Already-added rows: inert, dimmed, no hover affordance. */
|
|
140
|
+
.row-added,
|
|
141
|
+
:global(.byline-field-relation-picker-row-added) {
|
|
142
|
+
opacity: 0.55;
|
|
143
|
+
cursor: default;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.row-added:hover,
|
|
147
|
+
:global(.byline-field-relation-picker-row-added):hover {
|
|
148
|
+
background-color: transparent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.added-hint,
|
|
152
|
+
:global(.byline-field-relation-picker-added-hint) {
|
|
153
|
+
margin-left: auto;
|
|
154
|
+
flex: none;
|
|
155
|
+
color: var(--gray-500);
|
|
156
|
+
font-size: var(--font-size-xs);
|
|
157
|
+
white-space: nowrap;
|
|
158
|
+
}
|
|
159
|
+
|
|
111
160
|
.row-cells,
|
|
112
161
|
:global(.byline-field-relation-picker-row-cells) {
|
|
113
162
|
display: flex;
|
|
@@ -11,7 +11,7 @@ import { useCallback, useEffect, useState } from 'react'
|
|
|
11
11
|
import type { CollectionAdminConfig, CollectionDefinition } from '@byline/core'
|
|
12
12
|
import { getCollectionAdminConfig, resolveItemViewColumns } from '@byline/core'
|
|
13
13
|
import { useTranslation } from '@byline/i18n/react'
|
|
14
|
-
import { Button, LoaderRing, Modal, Search } from '@byline/ui/react'
|
|
14
|
+
import { Button, CheckIcon, LoaderRing, Modal, Search } from '@byline/ui/react'
|
|
15
15
|
import cx from 'classnames'
|
|
16
16
|
|
|
17
17
|
import { useBylineFieldServices } from '../field-services-context'
|
|
@@ -39,7 +39,21 @@ import styles from './relation-picker.module.css'
|
|
|
39
39
|
*
|
|
40
40
|
* Paths 2–4 render a single-line label (primary) + `path` (secondary).
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* One confirmed pick. `record` is the raw document the picker row rendered —
|
|
44
|
+
* the caller can use it to show the selected value in its own tile without a
|
|
45
|
+
* refetch. The fields available on `record` are whatever `resolveSelectFields`
|
|
46
|
+
* asked the listing endpoint for (picker columns + `useAsTitle` +
|
|
47
|
+
* `displayField`), so any display surface downstream of the picker that also
|
|
48
|
+
* renders from those same columns will find the data it needs.
|
|
49
|
+
*/
|
|
50
|
+
export interface RelationPickerSelection {
|
|
51
|
+
targetDocumentId: string
|
|
52
|
+
targetCollectionId: string
|
|
53
|
+
record?: Record<string, any>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface RelationPickerBaseProps {
|
|
43
57
|
/** The target collection path (e.g. `'media'`). */
|
|
44
58
|
targetCollectionPath: string
|
|
45
59
|
/** The target collection definition (used for labels + displayField fallback). */
|
|
@@ -58,25 +72,38 @@ interface RelationPickerProps {
|
|
|
58
72
|
extraSelectFields?: string[]
|
|
59
73
|
/** Modal open/close state. */
|
|
60
74
|
isOpen: boolean
|
|
61
|
-
/**
|
|
62
|
-
* Called with the picked selection when the user confirms.
|
|
63
|
-
*
|
|
64
|
-
* `record` is the raw document the picker row rendered — the caller can
|
|
65
|
-
* use it to show the selected value in its own tile without a refetch.
|
|
66
|
-
* The fields available on `record` are whatever `resolveSelectFields`
|
|
67
|
-
* asked the listing endpoint for (picker columns + `useAsTitle` +
|
|
68
|
-
* `displayField`), so any display surface downstream of the picker that
|
|
69
|
-
* also renders from those same columns will find the data it needs.
|
|
70
|
-
*/
|
|
71
|
-
onSelect: (selection: {
|
|
72
|
-
targetDocumentId: string
|
|
73
|
-
targetCollectionId: string
|
|
74
|
-
record?: Record<string, any>
|
|
75
|
-
}) => void
|
|
76
75
|
/** Called when the user dismisses the modal. */
|
|
77
76
|
onDismiss: () => void
|
|
78
77
|
}
|
|
79
78
|
|
|
79
|
+
interface RelationPickerSingleProps extends RelationPickerBaseProps {
|
|
80
|
+
/** Single-select (default): clicking a row selects it; confirm returns one pick. */
|
|
81
|
+
multiple?: false
|
|
82
|
+
/** Called with the picked selection when the user confirms. */
|
|
83
|
+
onSelect: (selection: RelationPickerSelection) => void
|
|
84
|
+
onSelectMany?: never
|
|
85
|
+
excludeIds?: never
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface RelationPickerMultiProps extends RelationPickerBaseProps {
|
|
89
|
+
/**
|
|
90
|
+
* Multi-select mode (`hasMany` widgets): rows toggle a check state and the
|
|
91
|
+
* confirm action returns every selection in pick order — several picks in
|
|
92
|
+
* one trip instead of reopening the modal per item.
|
|
93
|
+
*/
|
|
94
|
+
multiple: true
|
|
95
|
+
/** Called with the full selection set (pick order) when the user confirms. */
|
|
96
|
+
onSelectMany: (selections: RelationPickerSelection[]) => void
|
|
97
|
+
onSelect?: never
|
|
98
|
+
/**
|
|
99
|
+
* Target ids already present on the caller's value. Rendered as disabled
|
|
100
|
+
* "already added" rows so the same target can't be picked twice.
|
|
101
|
+
*/
|
|
102
|
+
excludeIds?: string[]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type RelationPickerProps = RelationPickerSingleProps | RelationPickerMultiProps
|
|
106
|
+
|
|
80
107
|
const PAGE_SIZE = 15
|
|
81
108
|
|
|
82
109
|
export const RelationPicker = ({
|
|
@@ -85,13 +112,22 @@ export const RelationPicker = ({
|
|
|
85
112
|
displayField,
|
|
86
113
|
extraSelectFields,
|
|
87
114
|
isOpen,
|
|
115
|
+
multiple = false,
|
|
116
|
+
excludeIds,
|
|
88
117
|
onSelect,
|
|
118
|
+
onSelectMany,
|
|
89
119
|
onDismiss,
|
|
90
120
|
}: RelationPickerProps) => {
|
|
91
121
|
const [query, setQuery] = useState<string>('')
|
|
92
122
|
const [page, setPage] = useState<number>(1)
|
|
93
123
|
const { t } = useTranslation('byline-admin')
|
|
94
124
|
const [selectedDocumentId, setSelectedDocumentId] = useState<string | null>(null)
|
|
125
|
+
// Multi-select state. A Map keyed by target id preserves pick order (the
|
|
126
|
+
// confirmed batch appends in that order) and carries each row's record so
|
|
127
|
+
// picks survive page/search changes that swap out `documents`.
|
|
128
|
+
const [selectedMap, setSelectedMap] = useState<Map<string, Record<string, any> | undefined>>(
|
|
129
|
+
() => new Map()
|
|
130
|
+
)
|
|
95
131
|
const [loading, setLoading] = useState<boolean>(false)
|
|
96
132
|
const [error, setError] = useState<string | null>(null)
|
|
97
133
|
const [documents, setDocuments] = useState<any[]>([])
|
|
@@ -110,6 +146,7 @@ export const RelationPicker = ({
|
|
|
110
146
|
setQuery('')
|
|
111
147
|
setPage(1)
|
|
112
148
|
setSelectedDocumentId(null)
|
|
149
|
+
setSelectedMap(new Map())
|
|
113
150
|
setError(null)
|
|
114
151
|
}
|
|
115
152
|
}, [isOpen])
|
|
@@ -174,7 +211,7 @@ export const RelationPicker = ({
|
|
|
174
211
|
null
|
|
175
212
|
|
|
176
213
|
const handleSelect = useCallback(() => {
|
|
177
|
-
if (!selectedDocumentId || !collectionId) return
|
|
214
|
+
if (!selectedDocumentId || !collectionId || !onSelect) return
|
|
178
215
|
const record = documents.find((d) => d?.id === selectedDocumentId)
|
|
179
216
|
onSelect({
|
|
180
217
|
targetDocumentId: selectedDocumentId,
|
|
@@ -183,6 +220,30 @@ export const RelationPicker = ({
|
|
|
183
220
|
})
|
|
184
221
|
}, [selectedDocumentId, collectionId, documents, onSelect])
|
|
185
222
|
|
|
223
|
+
const handleSelectMany = useCallback(() => {
|
|
224
|
+
if (selectedMap.size === 0 || !collectionId || !onSelectMany) return
|
|
225
|
+
onSelectMany(
|
|
226
|
+
Array.from(selectedMap, ([targetDocumentId, record]) => ({
|
|
227
|
+
targetDocumentId,
|
|
228
|
+
targetCollectionId: collectionId,
|
|
229
|
+
record,
|
|
230
|
+
}))
|
|
231
|
+
)
|
|
232
|
+
}, [selectedMap, collectionId, onSelectMany])
|
|
233
|
+
|
|
234
|
+
const toggleSelected = useCallback((doc: Record<string, any>) => {
|
|
235
|
+
const id = doc.id as string
|
|
236
|
+
setSelectedMap((prev) => {
|
|
237
|
+
const next = new Map(prev)
|
|
238
|
+
if (next.has(id)) {
|
|
239
|
+
next.delete(id)
|
|
240
|
+
} else {
|
|
241
|
+
next.set(id, doc)
|
|
242
|
+
}
|
|
243
|
+
return next
|
|
244
|
+
})
|
|
245
|
+
}, [])
|
|
246
|
+
|
|
186
247
|
const title = t('fields.relation.selectPickerTitle', {
|
|
187
248
|
label: targetDefinition?.labels.singular ?? targetCollectionPath,
|
|
188
249
|
})
|
|
@@ -228,21 +289,55 @@ export const RelationPicker = ({
|
|
|
228
289
|
<ul className={cx('byline-field-relation-picker-rows', styles.rows)}>
|
|
229
290
|
{documents.map((doc) => {
|
|
230
291
|
const id = doc.id as string
|
|
231
|
-
const selected = selectedDocumentId === id
|
|
292
|
+
const selected = multiple ? selectedMap.has(id) : selectedDocumentId === id
|
|
293
|
+
const excluded = multiple && (excludeIds?.includes(id) ?? false)
|
|
232
294
|
return (
|
|
233
295
|
<li key={id}>
|
|
234
296
|
<button
|
|
235
297
|
type="button"
|
|
298
|
+
disabled={excluded}
|
|
299
|
+
aria-pressed={multiple ? selected : undefined}
|
|
300
|
+
title={excluded ? t('fields.relation.picker.alreadyAdded') : undefined}
|
|
236
301
|
className={cx(
|
|
237
302
|
'byline-field-relation-picker-row-button',
|
|
238
303
|
styles['row-button'],
|
|
304
|
+
multiple && [
|
|
305
|
+
'byline-field-relation-picker-row-multi',
|
|
306
|
+
styles['row-multi'],
|
|
307
|
+
],
|
|
239
308
|
selected && [
|
|
240
309
|
'byline-field-relation-picker-row-selected',
|
|
241
310
|
styles['row-selected'],
|
|
311
|
+
],
|
|
312
|
+
excluded && [
|
|
313
|
+
'byline-field-relation-picker-row-added',
|
|
314
|
+
styles['row-added'],
|
|
242
315
|
]
|
|
243
316
|
)}
|
|
244
|
-
onClick={() =>
|
|
317
|
+
onClick={() => {
|
|
318
|
+
if (excluded) return
|
|
319
|
+
if (multiple) {
|
|
320
|
+
toggleSelected(doc)
|
|
321
|
+
} else {
|
|
322
|
+
setSelectedDocumentId(id)
|
|
323
|
+
}
|
|
324
|
+
}}
|
|
245
325
|
>
|
|
326
|
+
{multiple && (
|
|
327
|
+
<span
|
|
328
|
+
aria-hidden="true"
|
|
329
|
+
className={cx(
|
|
330
|
+
'byline-field-relation-picker-check',
|
|
331
|
+
styles.check,
|
|
332
|
+
(selected || excluded) && [
|
|
333
|
+
'byline-field-relation-picker-check-checked',
|
|
334
|
+
styles['check-checked'],
|
|
335
|
+
]
|
|
336
|
+
)}
|
|
337
|
+
>
|
|
338
|
+
{(selected || excluded) && <CheckIcon width="12px" height="12px" />}
|
|
339
|
+
</span>
|
|
340
|
+
)}
|
|
246
341
|
{pickerColumns && pickerColumns.length > 0 ? (
|
|
247
342
|
<div
|
|
248
343
|
className={cx(
|
|
@@ -281,6 +376,16 @@ export const RelationPicker = ({
|
|
|
281
376
|
)}
|
|
282
377
|
</div>
|
|
283
378
|
)}
|
|
379
|
+
{excluded && (
|
|
380
|
+
<span
|
|
381
|
+
className={cx(
|
|
382
|
+
'byline-field-relation-picker-added-hint',
|
|
383
|
+
styles['added-hint']
|
|
384
|
+
)}
|
|
385
|
+
>
|
|
386
|
+
{t('fields.relation.picker.alreadyAdded')}
|
|
387
|
+
</span>
|
|
388
|
+
)}
|
|
284
389
|
</button>
|
|
285
390
|
</li>
|
|
286
391
|
)
|
|
@@ -331,10 +436,12 @@ export const RelationPicker = ({
|
|
|
331
436
|
className={cx('byline-field-relation-picker-action', styles.action)}
|
|
332
437
|
intent="primary"
|
|
333
438
|
type="button"
|
|
334
|
-
disabled={!selectedDocumentId}
|
|
335
|
-
onClick={handleSelect}
|
|
439
|
+
disabled={multiple ? selectedMap.size === 0 : !selectedDocumentId}
|
|
440
|
+
onClick={multiple ? handleSelectMany : handleSelect}
|
|
336
441
|
>
|
|
337
|
-
{
|
|
442
|
+
{multiple
|
|
443
|
+
? t('fields.relation.picker.addSelected', { count: selectedMap.size })
|
|
444
|
+
: t('common.actions.select')}
|
|
338
445
|
</Button>
|
|
339
446
|
</Modal.Actions>
|
|
340
447
|
</Modal.Container>
|
|
@@ -14,7 +14,7 @@ import { reconcileLocaleState } from './available-locales-reconcile.js'
|
|
|
14
14
|
* The widget's reconciliation is expressed purely as Checkbox intent +
|
|
15
15
|
* disabled state — no per-row text. `reconcileLocaleState` is the pure heart
|
|
16
16
|
* of that mapping; the four cells below are the full truth table from
|
|
17
|
-
* docs/
|
|
17
|
+
* docs/07-internationalization/index.md.
|
|
18
18
|
*/
|
|
19
19
|
describe('reconcileLocaleState', () => {
|
|
20
20
|
it('ledger-complete + advertised → green, enabled (advertised & complete)', () => {
|
|
@@ -64,7 +64,7 @@ const sameLocaleSet = (a: string[], b: string[]): boolean => {
|
|
|
64
64
|
* Save button. `content` mints a new version (normal workflow). `direct-write`
|
|
65
65
|
* is an immediate, non-versioned write of the document-grain system fields
|
|
66
66
|
* (path / advertised locales) that does NOT reset workflow status. `both` does
|
|
67
|
-
* each through its own write path. See docs/
|
|
67
|
+
* each through its own write path. See docs/07-internationalization/index.md.
|
|
68
68
|
*/
|
|
69
69
|
export type DirtyReason = 'none' | 'content' | 'direct-write' | 'both'
|
|
70
70
|
|
|
@@ -103,7 +103,7 @@ interface FormContextType {
|
|
|
103
103
|
/**
|
|
104
104
|
* Partition the current dirty state into content vs. system-field (path /
|
|
105
105
|
* advertised-locales) writes so the Save button can branch. See
|
|
106
|
-
* docs/
|
|
106
|
+
* docs/07-internationalization/index.md.
|
|
107
107
|
*/
|
|
108
108
|
getDirtyBreakdown: () => DirtyBreakdown
|
|
109
109
|
subscribeField: (name: string, listener: FieldListener) => () => void
|
|
@@ -349,7 +349,7 @@ export const FormProvider = ({
|
|
|
349
349
|
// button can route each piece correctly: content → versioned write; the
|
|
350
350
|
// document-grain system fields (path / advertised locales) → immediate,
|
|
351
351
|
// non-versioned direct write that leaves workflow status untouched.
|
|
352
|
-
// See docs/
|
|
352
|
+
// See docs/07-internationalization/index.md.
|
|
353
353
|
const getDirtyBreakdown = useCallback((): DirtyBreakdown => {
|
|
354
354
|
const keys = dirtyFields.current
|
|
355
355
|
const pathDirty = keys.has(SYSTEM_PATH_DIRTY_KEY)
|
|
@@ -54,7 +54,7 @@ export const UnsavedChangesModal = ({ onClose }: { onClose: () => void }) => {
|
|
|
54
54
|
* Confirms an immediate, non-versioned write of the document-grain system
|
|
55
55
|
* fields (path / advertised locales) — which does NOT reset workflow status.
|
|
56
56
|
* When content is also dirty, the copy reassures that content edits still
|
|
57
|
-
* follow the normal revision + publish workflow. See docs/
|
|
57
|
+
* follow the normal revision + publish workflow. See docs/07-internationalization/index.md.
|
|
58
58
|
*/
|
|
59
59
|
export const SystemFieldsConfirmModal = ({
|
|
60
60
|
contentDirty,
|
|
@@ -56,7 +56,7 @@ export interface PublishedVersionInfo {
|
|
|
56
56
|
* patches) alongside the document-grain system fields (path / advertised
|
|
57
57
|
* locales) and per-bucket dirty flags so the host can route each piece to the
|
|
58
58
|
* right write path — versioned for content, immediate/non-versioned for the
|
|
59
|
-
* system fields. See docs/
|
|
59
|
+
* system fields. See docs/07-internationalization/index.md.
|
|
60
60
|
*/
|
|
61
61
|
export interface SystemFieldsSubmitPayload {
|
|
62
62
|
// biome-ignore lint/suspicious/noExplicitAny: data is collection-specific
|
|
@@ -134,7 +134,7 @@ export interface FormRendererProps {
|
|
|
134
134
|
* Opts the document-tree placement widget into the sidebar (above the
|
|
135
135
|
* available-locales widget). Sourced from `CollectionDefinition.tree` by the
|
|
136
136
|
* caller. Renders only in edit mode (placement needs a persisted document)
|
|
137
|
-
* and only when the host wires the tree services. See docs/
|
|
137
|
+
* and only when the host wires the tree services. See docs/04-collections/03-document-trees.md.
|
|
138
138
|
*/
|
|
139
139
|
tree?: boolean
|
|
140
140
|
headingLabel?: string
|
|
@@ -235,7 +235,7 @@ const FormContent = ({
|
|
|
235
235
|
const [showUnsavedModal, setShowUnsavedModal] = useState(false)
|
|
236
236
|
// Holds the pending Save payload while the editor confirms an immediate,
|
|
237
237
|
// non-versioned system-field write (path / advertised locales). Non-null
|
|
238
|
-
// means the confirmation modal is open. See docs/
|
|
238
|
+
// means the confirmation modal is open. See docs/07-internationalization/index.md.
|
|
239
239
|
const [pendingSystemFieldsSubmit, setPendingSystemFieldsSubmit] =
|
|
240
240
|
useState<SystemFieldsSubmitPayload | null>(null)
|
|
241
241
|
const [contentLocale, setContentLocale] = useState(initialLocale ?? defaultLocale)
|
|
@@ -532,7 +532,7 @@ const FormContent = ({
|
|
|
532
532
|
{/* Source-locale anchor indicator removed pending heading-layout work.
|
|
533
533
|
To re-enable: render `<SourceLocaleBadge locale={sourceLocale} />`
|
|
534
534
|
here from `initialData.sourceLocale` (mismatch-only is the intended
|
|
535
|
-
end state). See docs/
|
|
535
|
+
end state). See docs/07-internationalization/index.md. */}
|
|
536
536
|
{headerSlot}
|
|
537
537
|
</div>
|
|
538
538
|
<div className={cx('byline-form-status-bar', styles['status-bar'])}>
|
|
@@ -30,7 +30,7 @@ export interface TreePlacementWidgetProps {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Sidebar widget for placing the current document within its collection's
|
|
33
|
-
* single-parent document tree (the `tree: true` primitive — docs/
|
|
33
|
+
* single-parent document tree (the `tree: true` primitive — docs/04-collections/03-document-trees.md).
|
|
34
34
|
*
|
|
35
35
|
* The tree is document-grain and **unversioned**, so changes here write
|
|
36
36
|
* immediately (independent of the form's content save). The editor picks a
|
|
@@ -16,7 +16,7 @@ import { assertAdminActor, requireAdminActor } from './assert-admin-actor.js'
|
|
|
16
16
|
* contract (validate → authorise → invoke → shape) into a single
|
|
17
17
|
* declaration.
|
|
18
18
|
*
|
|
19
|
-
* Implements Phase 1 of `docs/
|
|
19
|
+
* Implements Phase 1 of `docs/03-architecture/02-core-composition.md`. Today's scope is
|
|
20
20
|
* `@byline/admin`-internal: it gates against admin actor identity using
|
|
21
21
|
* the existing `assertAdminActor` / `requireAdminActor` helpers, which
|
|
22
22
|
* inherit the super-admin bypass from `AdminAuth.assertAbility`.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { AbilityRegistry } from '@byline/auth'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Ability keys for the admin-activity module (docs/
|
|
12
|
+
* Ability keys for the admin-activity module (docs/06-auth-and-security/02-auditability.md — Workstream 4).
|
|
13
13
|
*
|
|
14
14
|
* `read` gates the system-wide activity area — the `/admin/activity` report
|
|
15
15
|
* over the version-stream + audit-log union. It is deliberately a **separate**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* `@byline/admin/admin-activity` — the system-wide activity area
|
|
11
|
-
* (docs/
|
|
11
|
+
* (docs/06-auth-and-security/02-auditability.md — Workstream 4).
|
|
12
12
|
*
|
|
13
13
|
* Unlike the other admin modules this one owns no table and no AdminStore
|
|
14
14
|
* repository: the activity feed is a read over the document db adapter's
|
|
@@ -11,7 +11,7 @@ import type { AbilityRegistry } from '@byline/auth'
|
|
|
11
11
|
/**
|
|
12
12
|
* Ability keys for the admin-permissions module.
|
|
13
13
|
*
|
|
14
|
-
* `read` gates the inspector view (see docs/
|
|
14
|
+
* `read` gates the inspector view (see docs/06-auth-and-security/01-authn-authz.md).
|
|
15
15
|
* `update` will gate the per-role ability editor mounted on the
|
|
16
16
|
* admin-roles role detail page — declared here so the role editor can
|
|
17
17
|
* assert against it once that surface lands. The per-role editor shares
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Read-only abilities inspector — see docs/
|
|
12
|
+
* Read-only abilities inspector — see docs/06-auth-and-security/01-authn-authz.md.
|
|
13
13
|
*
|
|
14
14
|
* Top level: a collapsible group per ability source (collections.docs,
|
|
15
15
|
* admin.users, etc.), each containing the abilities that group
|
|
@@ -128,7 +128,7 @@ export interface AdminUsersRepository {
|
|
|
128
128
|
getById(id: string): Promise<AdminUserRow | null>
|
|
129
129
|
/**
|
|
130
130
|
* Bulk lookup for audit actor-label resolution (the `actors`
|
|
131
|
-
* map on admin document reads — see docs/
|
|
131
|
+
* map on admin document reads — see docs/06-auth-and-security/02-auditability.md, Workstream 1). Ids
|
|
132
132
|
* with no matching row are simply absent from the result; callers
|
|
133
133
|
* render a tombstone label for them.
|
|
134
134
|
*/
|
|
@@ -27,7 +27,7 @@ export interface SourceLocaleBadgeProps {
|
|
|
27
27
|
* NOTE: currently rendered for *every* document so the anchor is visible during
|
|
28
28
|
* development. The intended end state is to show it only when `locale` differs
|
|
29
29
|
* from the system's current default content locale (a normal single-default
|
|
30
|
-
* install then shows nothing). See docs/
|
|
30
|
+
* install then shows nothing). See docs/07-internationalization/index.md.
|
|
31
31
|
*
|
|
32
32
|
* Stable override handle: `.byline-source-locale-badge`.
|
|
33
33
|
*/
|