@asteby/metacore-runtime-react 23.6.0 → 23.7.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.
@@ -0,0 +1,480 @@
1
+ // @vitest-environment happy-dom
2
+ //
3
+ // Custom stages coverage:
4
+ // 1. Pure helpers: splitCustomStages, mergeLaneStages, smartLaneParams,
5
+ // isCustomStageDraftValid, slugifyStageKey, customStageFilterFields.
6
+ // 2. AddStageColumn renders + fires onClick.
7
+ // 3. CustomStageDialog: create a NORMAL stage (mock onCreate), edit a SMART
8
+ // stage's condition value (mock onUpdate).
9
+ // 4. SmartLane queries the list endpoint with the lane's f_<field> params.
10
+ // 5. useCustomStages degrades to available=false when the endpoint 404s (the
11
+ // "+ Agregar etapa" affordance never renders → board intact).
12
+ import { afterEach, describe, expect, it, vi } from 'vitest'
13
+ import { cleanup, render, screen, fireEvent, waitFor } from '@testing-library/react'
14
+
15
+ const I18N_T = (k: string, opts?: Record<string, any>) => {
16
+ let s = (opts?.defaultValue as string) ?? k
17
+ if (opts) {
18
+ for (const [ok, ov] of Object.entries(opts)) {
19
+ if (ok === 'defaultValue') continue
20
+ s = s.replace(new RegExp(`{{${ok}}}`, 'g'), String(ov))
21
+ }
22
+ }
23
+ return s
24
+ }
25
+ const I18N = { language: 'es' }
26
+ const USE_TRANSLATION = { t: I18N_T, i18n: I18N }
27
+ vi.mock('react-i18next', () => ({
28
+ useTranslation: () => USE_TRANSLATION,
29
+ }))
30
+ vi.mock('sonner', () => ({
31
+ toast: { success: vi.fn(), error: vi.fn() },
32
+ }))
33
+ vi.mock('@tanstack/react-router', () => ({
34
+ useNavigate: () => () => {},
35
+ }))
36
+
37
+ import {
38
+ splitCustomStages,
39
+ mergeLaneStages,
40
+ resolveSmartLanes,
41
+ smartLaneParams,
42
+ isCustomStageDraftValid,
43
+ slugifyStageKey,
44
+ customStageFilterFields,
45
+ emptyCustomStageFilter,
46
+ AddStageColumn,
47
+ CustomStageDialog,
48
+ CustomStageDeleteDialog,
49
+ SmartLane,
50
+ useCustomStages,
51
+ type CustomStage,
52
+ } from '../custom-stages'
53
+ import type { SmartLaneMeta } from '../types'
54
+ import { ApiProvider, type ApiClient } from '../api-context'
55
+ import type { ColumnDefinition, StageMeta } from '../types'
56
+ import React from 'react'
57
+
58
+ afterEach(cleanup)
59
+
60
+ // ---------------------------------------------------------------------------
61
+ // Fixtures
62
+ // ---------------------------------------------------------------------------
63
+
64
+ const COLUMNS: ColumnDefinition[] = [
65
+ { key: 'title', label: 'Title', type: 'text', sortable: true, filterable: false },
66
+ { key: 'priority', label: 'Priority', type: 'text', sortable: false, filterable: false },
67
+ { key: 'id', label: 'ID', type: 'text', sortable: false, filterable: false },
68
+ { key: 'secret', label: 'Secret', type: 'text', sortable: false, filterable: false, hidden: true },
69
+ ]
70
+
71
+ const CUSTOM: CustomStage[] = [
72
+ {
73
+ id: 'c1',
74
+ model: 'issue',
75
+ key: 'review',
76
+ label: 'En revisión',
77
+ color: 'blue',
78
+ position: 5,
79
+ type: 'stage',
80
+ filters: [],
81
+ enabled: true,
82
+ },
83
+ {
84
+ id: 'c2',
85
+ model: 'issue',
86
+ key: 'urgent',
87
+ label: 'Urgentes',
88
+ color: 'red',
89
+ position: 6,
90
+ type: 'smart',
91
+ filters: [{ field: 'priority', op: 'eq', value: 'high' }],
92
+ enabled: true,
93
+ },
94
+ {
95
+ id: 'c3',
96
+ model: 'issue',
97
+ key: 'off',
98
+ label: 'Deshabilitada',
99
+ color: 'slate',
100
+ position: 7,
101
+ type: 'stage',
102
+ filters: [],
103
+ enabled: false,
104
+ },
105
+ ]
106
+
107
+ // ---------------------------------------------------------------------------
108
+ // 1. Pure helpers
109
+ // ---------------------------------------------------------------------------
110
+
111
+ describe('splitCustomStages', () => {
112
+ it('splits enabled stages by flavor and drops disabled ones', () => {
113
+ const { laneStages, smartStages } = splitCustomStages(CUSTOM)
114
+ expect(laneStages.map((s) => s.key)).toEqual(['review'])
115
+ expect(smartStages.map((s) => s.key)).toEqual(['urgent'])
116
+ })
117
+ it('tolerates undefined', () => {
118
+ expect(splitCustomStages(undefined)).toEqual({ laneStages: [], smartStages: [] })
119
+ })
120
+ })
121
+
122
+ describe('mergeLaneStages', () => {
123
+ const declared: StageMeta[] = [
124
+ { key: 'todo', label: 'Todo', order: 0 },
125
+ { key: 'done', label: 'Done', order: 10 },
126
+ ]
127
+ it('appends unknown-key custom lanes, sorted by order/position', () => {
128
+ const custom: CustomStage[] = [
129
+ { ...CUSTOM[0], key: 'review', position: 5 },
130
+ ]
131
+ const { lanes, customByKey } = mergeLaneStages(declared, custom)
132
+ expect(lanes.map((s) => s.key)).toEqual(['todo', 'review', 'done'])
133
+ expect(customByKey.get('review')?.label).toBe('En revisión')
134
+ })
135
+ it('does not duplicate a custom lane the metadata already surfaced', () => {
136
+ const custom: CustomStage[] = [{ ...CUSTOM[0], key: 'done' }]
137
+ const { lanes, customByKey } = mergeLaneStages(declared, custom)
138
+ expect(lanes.map((s) => s.key)).toEqual(['todo', 'done'])
139
+ // Still tagged as custom so the lane gets its edit/delete menu.
140
+ expect(customByKey.has('done')).toBe(true)
141
+ })
142
+ })
143
+
144
+ describe('smartLaneParams', () => {
145
+ it('encodes the operator as an OP: prefix on a single f_<field> param', () => {
146
+ expect(
147
+ smartLaneParams([
148
+ { field: 'priority', op: 'eq', value: 'high' },
149
+ { field: 'title', op: 'contains', value: 'bug' },
150
+ { field: 'state', op: 'neq', value: 'closed' },
151
+ { field: 'label', op: 'in', value: 'a,b' },
152
+ ]),
153
+ ).toEqual({
154
+ f_priority: 'EQ:high',
155
+ f_title: 'HAS:bug',
156
+ f_state: 'NEQ:closed',
157
+ f_label: 'IN:a,b',
158
+ })
159
+ })
160
+ it('skips empty fields/values and tolerates undefined', () => {
161
+ expect(smartLaneParams(undefined)).toEqual({})
162
+ expect(
163
+ smartLaneParams([
164
+ { field: '', op: 'eq', value: 'x' },
165
+ { field: 'a', op: 'eq', value: ' ' },
166
+ ]),
167
+ ).toEqual({})
168
+ })
169
+ })
170
+
171
+ describe('isCustomStageDraftValid', () => {
172
+ it('requires a label', () => {
173
+ expect(isCustomStageDraftValid({ label: '', type: 'stage', filters: [] })).toBe(false)
174
+ expect(isCustomStageDraftValid({ label: 'A', type: 'stage', filters: [] })).toBe(true)
175
+ })
176
+ it('requires at least one complete condition for smart lanes', () => {
177
+ expect(
178
+ isCustomStageDraftValid({ label: 'A', type: 'smart', filters: [emptyCustomStageFilter('x')] }),
179
+ ).toBe(false)
180
+ expect(
181
+ isCustomStageDraftValid({
182
+ label: 'A',
183
+ type: 'smart',
184
+ filters: [{ field: 'x', op: 'eq', value: '1' }],
185
+ }),
186
+ ).toBe(true)
187
+ })
188
+ })
189
+
190
+ describe('slugifyStageKey / customStageFilterFields', () => {
191
+ it('slugifies labels (accents, spaces, symbols)', () => {
192
+ expect(slugifyStageKey('En Revisión!')).toBe('en_revision')
193
+ })
194
+ it('offers visible non-id columns for the condition builder', () => {
195
+ expect(customStageFilterFields(COLUMNS).map((c) => c.key)).toEqual(['title', 'priority'])
196
+ })
197
+ })
198
+
199
+ // ---------------------------------------------------------------------------
200
+ // 2. AddStageColumn
201
+ // ---------------------------------------------------------------------------
202
+
203
+ describe('AddStageColumn', () => {
204
+ it('renders and fires onClick', () => {
205
+ const onClick = vi.fn()
206
+ render(<AddStageColumn onClick={onClick} />)
207
+ fireEvent.click(screen.getByTestId('kanban-add-stage'))
208
+ expect(onClick).toHaveBeenCalledTimes(1)
209
+ })
210
+ })
211
+
212
+ // ---------------------------------------------------------------------------
213
+ // 3. CustomStageDialog
214
+ // ---------------------------------------------------------------------------
215
+
216
+ describe('CustomStageDialog', () => {
217
+ it('creates a NORMAL stage with a slugified key and empty filters', async () => {
218
+ const onCreate = vi.fn(async () => {})
219
+ const onUpdate = vi.fn(async () => {})
220
+ render(
221
+ <CustomStageDialog
222
+ open
223
+ onOpenChange={() => {}}
224
+ model="issue"
225
+ columns={COLUMNS}
226
+ initial={null}
227
+ nextPosition={9}
228
+ onCreate={onCreate}
229
+ onUpdate={onUpdate}
230
+ />,
231
+ )
232
+ fireEvent.change(screen.getByTestId('custom-stage-name'), {
233
+ target: { value: 'En Progreso' },
234
+ })
235
+ fireEvent.click(screen.getByTestId('custom-stage-save'))
236
+ await waitFor(() => expect(onCreate).toHaveBeenCalledTimes(1))
237
+ expect(onCreate).toHaveBeenCalledWith({
238
+ model: 'issue',
239
+ key: 'en_progreso',
240
+ label: 'En Progreso',
241
+ color: 'slate',
242
+ position: 9,
243
+ type: 'stage',
244
+ filters: [],
245
+ enabled: true,
246
+ })
247
+ })
248
+
249
+ it('save is disabled until the stage has a name', () => {
250
+ render(
251
+ <CustomStageDialog
252
+ open
253
+ onOpenChange={() => {}}
254
+ model="issue"
255
+ columns={COLUMNS}
256
+ initial={null}
257
+ nextPosition={0}
258
+ onCreate={vi.fn()}
259
+ onUpdate={vi.fn()}
260
+ />,
261
+ )
262
+ expect((screen.getByTestId('custom-stage-save') as HTMLButtonElement).disabled).toBe(true)
263
+ })
264
+
265
+ it('edits a SMART stage: pre-fills conditions and updates the value', async () => {
266
+ const onUpdate = vi.fn(async () => {})
267
+ render(
268
+ <CustomStageDialog
269
+ open
270
+ onOpenChange={() => {}}
271
+ model="issue"
272
+ columns={COLUMNS}
273
+ initial={CUSTOM[1]}
274
+ nextPosition={0}
275
+ onCreate={vi.fn()}
276
+ onUpdate={onUpdate}
277
+ />,
278
+ )
279
+ // The smart lane's single condition renders pre-filled (value=high).
280
+ const valueInput = screen.getByTestId('custom-stage-condition-value-0') as HTMLInputElement
281
+ expect(valueInput.value).toBe('high')
282
+ fireEvent.change(valueInput, { target: { value: 'critical' } })
283
+ fireEvent.click(screen.getByTestId('custom-stage-save'))
284
+ await waitFor(() => expect(onUpdate).toHaveBeenCalledTimes(1))
285
+ // type/model/key are immutable → the patch omits them (ops #704).
286
+ expect(onUpdate).toHaveBeenCalledWith('c2', {
287
+ label: 'Urgentes',
288
+ color: 'red',
289
+ filters: [{ field: 'priority', op: 'eq', value: 'critical' }],
290
+ })
291
+ })
292
+
293
+ it('disables the type field when editing (type is immutable)', () => {
294
+ render(
295
+ <CustomStageDialog
296
+ open
297
+ onOpenChange={() => {}}
298
+ model="issue"
299
+ columns={COLUMNS}
300
+ initial={CUSTOM[1]}
301
+ nextPosition={0}
302
+ onCreate={vi.fn()}
303
+ onUpdate={vi.fn()}
304
+ />,
305
+ )
306
+ expect(
307
+ (screen.getByTestId('custom-stage-type') as HTMLButtonElement).disabled,
308
+ ).toBe(true)
309
+ })
310
+
311
+ it('adds and removes condition rows for a smart lane', () => {
312
+ render(
313
+ <CustomStageDialog
314
+ open
315
+ onOpenChange={() => {}}
316
+ model="issue"
317
+ columns={COLUMNS}
318
+ initial={CUSTOM[1]}
319
+ nextPosition={0}
320
+ onCreate={vi.fn()}
321
+ onUpdate={vi.fn()}
322
+ />,
323
+ )
324
+ expect(screen.getByTestId('custom-stage-condition-0')).toBeTruthy()
325
+ fireEvent.click(screen.getByTestId('custom-stage-add-condition'))
326
+ expect(screen.getByTestId('custom-stage-condition-1')).toBeTruthy()
327
+ fireEvent.click(screen.getByTestId('custom-stage-condition-remove-1'))
328
+ expect(screen.queryByTestId('custom-stage-condition-1')).toBeNull()
329
+ })
330
+ })
331
+
332
+ // ---------------------------------------------------------------------------
333
+ // 4. SmartLane
334
+ // ---------------------------------------------------------------------------
335
+
336
+ function fakeApi(over: Partial<ApiClient> = {}): ApiClient {
337
+ return {
338
+ get: vi.fn(async () => ({ data: { success: true, data: [], meta: { total: 0 } } })),
339
+ post: vi.fn(async () => ({ data: { success: true, data: null } })),
340
+ put: vi.fn(async () => ({ data: { success: true, data: null } })),
341
+ delete: vi.fn(async () => ({ data: { success: true, data: null } })),
342
+ ...over,
343
+ }
344
+ }
345
+
346
+ describe('SmartLane', () => {
347
+ it('queries the list endpoint with the lane f_<field> params', async () => {
348
+ const get = vi.fn(async () => ({
349
+ data: { success: true, data: [{ id: 1, title: 'Bug' }], meta: { total: 1 } },
350
+ }))
351
+ render(
352
+ <ApiProvider client={fakeApi({ get })}>
353
+ <SmartLane
354
+ stage={CUSTOM[1]}
355
+ model="issue"
356
+ endpoint="/data/issue/me"
357
+ defaultFilters={{ archived: false }}
358
+ isDark={false}
359
+ onEdit={() => {}}
360
+ onDelete={() => {}}
361
+ renderCard={(c) => <div data-testid={`smart-card-${c.id}`}>{c.title}</div>}
362
+ />
363
+ </ApiProvider>,
364
+ )
365
+ await waitFor(() => expect(get).toHaveBeenCalled())
366
+ const [url, cfg] = get.mock.calls[0] as [string, any]
367
+ expect(url).toBe('/data/issue/me')
368
+ expect(cfg.params).toMatchObject({ archived: false, f_priority: 'EQ:high' })
369
+ await waitFor(() => expect(screen.getByTestId('smart-card-1')).toBeTruthy())
370
+ })
371
+ })
372
+
373
+ // ---------------------------------------------------------------------------
374
+ // 4b. resolveSmartLanes — metadata-first with CRUD id fold-in
375
+ // ---------------------------------------------------------------------------
376
+
377
+ describe('resolveSmartLanes', () => {
378
+ const metaLanes: SmartLaneMeta[] = [
379
+ {
380
+ key: 'urgent',
381
+ label: 'Urgentes',
382
+ color: 'red',
383
+ order: 3,
384
+ filters: [{ field: 'priority', op: 'eq', value: 'high' }],
385
+ },
386
+ ]
387
+ it('maps metadata smart lanes, folding in the CRUD id by key', () => {
388
+ const out = resolveSmartLanes(metaLanes, [CUSTOM[1]], 'issue')
389
+ expect(out).toHaveLength(1)
390
+ expect(out[0]).toMatchObject({
391
+ id: 'c2', // folded in from the CRUD entry (metadata omits it)
392
+ key: 'urgent',
393
+ type: 'smart',
394
+ filters: [{ field: 'priority', op: 'eq', value: 'high' }],
395
+ })
396
+ })
397
+ it('synthesizes an id from the key when no CRUD match exists', () => {
398
+ expect(resolveSmartLanes(metaLanes, [], 'issue')[0].id).toBe('urgent')
399
+ })
400
+ it('falls back to CRUD smart stages when metadata omits smart_lanes', () => {
401
+ expect(resolveSmartLanes(undefined, [CUSTOM[1]], 'issue')).toEqual([CUSTOM[1]])
402
+ expect(resolveSmartLanes([], [CUSTOM[1]], 'issue')).toEqual([CUSTOM[1]])
403
+ })
404
+ })
405
+
406
+ // ---------------------------------------------------------------------------
407
+ // 4c. Delete dialog — 409 surfaces the card count + reassignment target
408
+ // ---------------------------------------------------------------------------
409
+
410
+ describe('CustomStageDeleteDialog', () => {
411
+ it('on 409 shows the card count and retries with a reassign target', async () => {
412
+ const onConfirm = vi
413
+ .fn()
414
+ .mockRejectedValueOnce({ response: { status: 409, data: { meta: { cards: 4 } } } })
415
+ .mockResolvedValueOnce(undefined)
416
+ render(
417
+ <CustomStageDeleteDialog
418
+ open
419
+ onOpenChange={() => {}}
420
+ stage={CUSTOM[0]}
421
+ reassignTargets={[
422
+ { key: 'review', label: 'En revisión' }, // same key → filtered out
423
+ { key: 'done', label: 'Done' },
424
+ ]}
425
+ onConfirm={onConfirm}
426
+ />,
427
+ )
428
+ // First attempt: plain delete, no reassign target.
429
+ fireEvent.click(screen.getByTestId('custom-stage-delete-confirm'))
430
+ await waitFor(() => expect(onConfirm).toHaveBeenCalledTimes(1))
431
+ expect(onConfirm).toHaveBeenLastCalledWith(CUSTOM[0], undefined)
432
+ // Conflict mode: the reassign select appears; the count is surfaced.
433
+ await waitFor(() => expect(screen.getByTestId('custom-stage-reassign')).toBeTruthy())
434
+ expect(screen.getByText(/4/)).toBeTruthy()
435
+ // Without a chosen target the confirm button stays a no-op (guarded).
436
+ fireEvent.click(screen.getByTestId('custom-stage-delete-confirm'))
437
+ expect(onConfirm).toHaveBeenCalledTimes(1)
438
+ })
439
+ })
440
+
441
+ // ---------------------------------------------------------------------------
442
+ // 5. Hook degrades gracefully when the endpoint is missing
443
+ // ---------------------------------------------------------------------------
444
+
445
+ function HookProbe({ model }: { model: string }) {
446
+ const c = useCustomStages(model)
447
+ return (
448
+ <div>
449
+ <span data-testid="available">{String(c.available)}</span>
450
+ <span data-testid="loading">{String(c.loading)}</span>
451
+ <span data-testid="count">{c.stages.length}</span>
452
+ </div>
453
+ )
454
+ }
455
+
456
+ describe('useCustomStages', () => {
457
+ it('loads stages when the endpoint is present', async () => {
458
+ render(
459
+ <ApiProvider client={fakeApi({ get: vi.fn(async () => ({ data: { success: true, data: CUSTOM } })) })}>
460
+ <HookProbe model="issue" />
461
+ </ApiProvider>,
462
+ )
463
+ await waitFor(() => expect(screen.getByTestId('available').textContent).toBe('true'))
464
+ expect(screen.getByTestId('count').textContent).toBe('3')
465
+ })
466
+
467
+ it('reports available=false when the endpoint 404s (no board break)', async () => {
468
+ const get = vi.fn(async () => {
469
+ throw { response: { status: 404 } }
470
+ })
471
+ render(
472
+ <ApiProvider client={fakeApi({ get })}>
473
+ <HookProbe model="issue" />
474
+ </ApiProvider>,
475
+ )
476
+ await waitFor(() => expect(screen.getByTestId('loading').textContent).toBe('false'))
477
+ expect(screen.getByTestId('available').textContent).toBe('false')
478
+ expect(screen.getByTestId('count').textContent).toBe('0')
479
+ })
480
+ })
@@ -26,7 +26,6 @@ import {
26
26
  Button,
27
27
  Input,
28
28
  Textarea,
29
- Label,
30
29
  Select,
31
30
  SelectContent,
32
31
  SelectItem,
@@ -44,6 +43,7 @@ import { DynamicSelectField } from './dynamic-select-field'
44
43
  import { DynamicDateField } from './dynamic-date-field'
45
44
  import { UploadField } from './upload-field'
46
45
  import { isLineItemsField, resolveWidget, resolveDependsValue, getDependsOn } from './dynamic-form-schema'
46
+ import { FieldGrid, FieldCell, FieldLabel } from './field-grid'
47
47
  import type { ActionFieldDef } from './types'
48
48
  // Canonical registry lives in @asteby/metacore-sdk
49
49
  import {
@@ -383,7 +383,7 @@ function GenericActionModal({ open, onOpenChange, action, model, record, endpoin
383
383
  is inline (guaranteed) since an arbitrary max-h-[90vh] class may be
384
384
  dropped by a consuming app's Tailwind scan. */}
385
385
  <DialogContent
386
- className={'flex max-h-[90vh] flex-col overflow-hidden ' + (widthPx ? '' : 'sm:max-w-lg')}
386
+ className={'flex max-h-[90vh] flex-col overflow-hidden ' + (widthPx ? '' : 'sm:max-w-xl')}
387
387
  style={{ maxHeight: '90vh', ...(widthPx ? { maxWidth: widthPx, width: '95vw' } : {}) }}
388
388
  >
389
389
  <DialogHeader className="shrink-0">
@@ -393,34 +393,33 @@ function GenericActionModal({ open, onOpenChange, action, model, record, endpoin
393
393
  </DialogTitle>
394
394
  {action.confirmMessage && <DialogDescription>{action.confirmMessage}</DialogDescription>}
395
395
  </DialogHeader>
396
- {/* Scrollable body. Responsive 2-column grid: scalar fields
397
- (journal, date, reference) flow side-by-side instead of one
398
- tall vertical stack; line-items grids and textareas span the
399
- full width. Mirrors DynamicForm driven only by field shape. */}
400
- <div className="-mx-1 grid min-h-0 flex-1 gap-4 overflow-y-auto px-1 py-4 sm:grid-cols-2">
401
- {action.fields?.map((field) => {
402
- const fullWidth =
403
- isLineItemsField(field) ||
404
- resolveWidget(field) === 'textarea' ||
405
- resolveWidget(field) === 'richtext'
406
- return (
407
- <div
408
- key={field.key}
409
- className={'grid gap-2 ' + (fullWidth ? 'sm:col-span-2' : '')}
410
- >
411
- <Label htmlFor={field.key}>
412
- {field.label}
413
- {field.required && <span className="text-red-500 ml-1">*</span>}
414
- </Label>
415
- {renderField(field, formData[field.key], (v: any) => updateField(field.key, v), formData)}
416
- </div>
417
- )
418
- })}
419
- {relations.length > 0 && (
420
- <div className="sm:col-span-2">
421
- <DynamicRelations record={record} relations={relations} />
422
- </div>
423
- )}
396
+ {/* Scrollable body. The shared FieldGrid lays scalar fields out
397
+ in two responsive columns (single column on phones); line-items
398
+ grids and textareas span the full width. `min-w-0` on each cell
399
+ (in FieldCell) keeps a long select/input value from blowing the
400
+ grid past the dialog and spawning a horizontal scrollbar. */}
401
+ <div className="-mx-1 min-h-0 flex-1 overflow-y-auto px-1 py-4">
402
+ <FieldGrid>
403
+ {action.fields?.map((field) => {
404
+ const fullWidth =
405
+ isLineItemsField(field) ||
406
+ resolveWidget(field) === 'textarea' ||
407
+ resolveWidget(field) === 'richtext'
408
+ return (
409
+ <FieldCell key={field.key} fullWidth={fullWidth}>
410
+ <FieldLabel htmlFor={field.key} required={field.required}>
411
+ {field.label}
412
+ </FieldLabel>
413
+ {renderField(field, formData[field.key], (v: any) => updateField(field.key, v), formData)}
414
+ </FieldCell>
415
+ )
416
+ })}
417
+ {relations.length > 0 && (
418
+ <FieldCell fullWidth>
419
+ <DynamicRelations record={record} relations={relations} />
420
+ </FieldCell>
421
+ )}
422
+ </FieldGrid>
424
423
  </div>
425
424
  <DialogFooter className="shrink-0">
426
425
  <Button variant="outline" onClick={() => onOpenChange(false)} disabled={executing}>